Browse Source

Checks if rol id exists. Fixes #3

master
Rick 6 years ago
parent
commit
bd325511f1
1 changed files with 24 additions and 19 deletions
  1. +24
    -19
      event.py

+ 24
- 19
event.py View File

@ -18,29 +18,34 @@ class Event():
self.participants = list()
self.leaders = list()
self.number_of_guests = 0
self.event_with_registration = False
sql = f"""SELECT mem_usr_id, mem_leader, mem_count_guests, mem_approved
if self.rol_id:
# Admidio only assigns a rol id when you can register for it
self.event_with_registration = True
sql = f"""SELECT mem_usr_id, mem_leader, mem_count_guests, mem_approved
FROM {self.admidio.prefix}_members
WHERE mem_rol_id = {self.rol_id}
AND mem_end = '9999-12-31'"""
self.__c.execute(sql)
for row in self.__c.fetchall():
try:
self.number_of_guests += row[2]
# Distinguish between members that will attend, not
# attend, or will maybe attend.
if row[1] == 1:
self.leaders.append(
[row[3], self.admidio.getMemberFromID(row[0])])
else:
self.participants.append(
[row[3], self.admidio.getMemberFromID(row[0])])
except MemberNotFoundException:
print(
f"Member with id {row[0]} not found, group id: {self.id}")
self.__c.execute(sql)
for row in self.__c.fetchall():
try:
self.number_of_guests += row[2]
# Distinguish between members that will attend, not
# attend, or will maybe attend.
if row[1] == 1:
self.leaders.append(
[row[3], self.admidio.getMemberFromID(row[0])])
else:
self.participants.append(
[row[3], self.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"""


Loading…
Cancel
Save