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.

44 lines
1.4 KiB

from .exceptions import MemberNotFoundException
import hashlib
class Group:
def __init__(self, group_id, name, admidio):
self.__c = admidio.db.cursor() = group_id = 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 = {}
AND mem_end = '9999-12-31'"""
for row in self.__c.fetchall():
if row[1] == 1:
except MemberNotFoundException:
print(f"Member with id {row[0]} not found, group id: {}")
def __eq__(self, other):
if isinstance(other, Group):
return self.hash() == other.hash()
def hash(self):
return hashlib.md5(
+ ("".join(str(x) for x in self.members) or "")
+ ("".join(str(x) for x in self.leaders) or "")
def getAllMembers(self):
"""Return leaders and members in group, combined"""
return self.leaders + self.members