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.
 

29 lines
1006 B

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)