The objective of this interface is the ability to get data from an Admidio installation and use them in python. Currently Users, groups and events are integrated
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
983 B

6 years ago
  1. from exceptions import MemberNotFoundException
  2. class Group:
  3. def __init__(self, db, group_id, name, admidio):
  4. self.__c = db.cursor()
  5. self.id = group_id
  6. self.name = name
  7. self.admidio = admidio
  8. self.members = list()
  9. self.leaders = list()
  10. sql = ("""SELECT mem_usr_id, mem_leader FROM adm_members"""
  11. f""" WHERE mem_rol_id = {self.id}""")
  12. self.__c.execute(sql)
  13. for row in self.__c.fetchall():
  14. try:
  15. if row[1] == 1:
  16. self.leaders.append(admidio.getMemberFromID(row[0]))
  17. else:
  18. self.members.append(admidio.getMemberFromID(row[0]))
  19. except MemberNotFoundException:
  20. print(
  21. f"Member with id {row[0]} not found, group id: {self.id}")
  22. def getAllMembers(self):
  23. """Return leaders and members in group, combined"""
  24. return self.leaders.append(self.members)