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.

41 lines
1.5 KiB

  1. from admidio_python_api.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 = f"""SELECT mem_usr_id, mem_leader, mem_count_guests
  19. FROM {self.admidio.prefix}_members
  20. WHERE mem_rol_id = {self.rol_id}
  21. AND mem_end = '9999-12-31'"""
  22. self.__c.execute(sql)
  23. for row in self.__c.fetchall():
  24. try:
  25. self.number_of_guests += row[2]
  26. if row[1] == 1:
  27. self.leaders.append(self.admidio.getMemberFromID(row[0]))
  28. else:
  29. self.participants.append(
  30. self.admidio.getMemberFromID(row[0]))
  31. except MemberNotFoundException:
  32. print(
  33. f"Member with id {row[0]} not found, group id: {self.id}")
  34. def getAllMembers(self):
  35. """Return leaders and members in group, combined"""
  36. return self.leaders.append(self.members)