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.

40 lines
1.4 KiB

  1. from exceptions import MemberNotFoundException
  2. class Event():
  3. def __init__(self, db, event_id, rol_id, name, start_time, end_time,
  4. description, location, country, admidio):
  5. self.__c = db.cursor()
  6. self.id = event_id
  7. self.rol_id = rol_id
  8. self.name = name
  9. self.start_time = start_time
  10. self.end_time = end_time
  11. self.description = description
  12. self.location = location
  13. self.country = country
  14. self.admidio = admidio
  15. self.participants = list()
  16. self.leaders = list()
  17. self.number_of_guests = 0
  18. sql = ("""SELECT mem_usr_id, mem_leader, mem_count_guests
  19. FROM adm_members"""
  20. f""" WHERE mem_rol_id = {self.rol_id}""")
  21. self.__c.execute(sql)
  22. for row in self.__c.fetchall():
  23. try:
  24. self.number_of_guests += row[2]
  25. if row[1] == 1:
  26. self.leaders.append(self.admidio.getMemberFromID(row[0]))
  27. else:
  28. self.participants.append(
  29. self.admidio.getMemberFromID(row[0]))
  30. except MemberNotFoundException:
  31. print(
  32. f"Member with id {row[0]} not found, group id: {self.id}")
  33. def getAllMembers(self):
  34. """Return leaders and members in group, combined"""
  35. return self.leaders.append(self.members)