from exceptions import MemberNotFoundException
|
|
|
|
|
|
class Group:
|
|
def __init__(self, db, group_id, name, admidio):
|
|
self.__c = db.cursor()
|
|
self.id = group_id
|
|
self.name = name
|
|
self.admidio = admidio
|
|
self.members = list()
|
|
self.leaders = list()
|
|
sql = ("""SELECT mem_usr_id, mem_leader FROM adm_members"""
|
|
f""" WHERE mem_rol_id = {self.id}""")
|
|
self.__c.execute(sql)
|
|
|
|
for row in self.__c.fetchall():
|
|
print(row)
|
|
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)
|