from .exceptions import MemberNotFoundException class Group: def __init__(self, group_id, name, admidio): self.__c = admidio.db.cursor() self.id = group_id self.name = name self.admidio = admidio self.members = list() self.leaders = list() sql = f"""SELECT mem_usr_id, mem_leader FROM {self.admidio.prefix}_members WHERE mem_rol_id = {self.id} AND mem_end = '9999-12-31'""" self.__c.execute(sql) for row in self.__c.fetchall(): try: if row[1] == 1: self.leaders.append(admidio.getMemberFromID(row[0])) else: self.members.append(admidio.getMemberFromID(row[0])) except MemberNotFoundException: print( f"Member with id {row[0]} not found, group id: {self.id}") def getAllMembers(self): """Return leaders and members in group, combined""" return self.leaders.append(self.members)