members/models: moved head count calculations inside freizeit model

pull/119/head
mariusrklein 11 months ago
parent 324d42b92c
commit aa2f9f3257

@ -925,10 +925,10 @@ class MemberOnListInline(CommonAdminInlineMixin, GenericTabularInline):
def people_count(self, obj): def people_count(self, obj):
if isinstance(obj, Freizeit): if isinstance(obj, Freizeit):
# Number of organizers who are also in the Memberlist # Number of organizers who are also in the Memberlist
organizer_count = len(obj.staff_on_memberlist) organizer_count = obj.staff_on_memberlist_count
# Total number of people in the Memberlist # Total number of people in the Memberlist
total_people = obj.participant_count + organizer_count total_people = obj.head_count
else: # fallback if no activity was found else: # fallback if no activity was found
total_people = 0 total_people = 0

@ -1146,12 +1146,20 @@ class Freizeit(CommonModel):
jls = set(self.jugendleiter.distinct()) jls = set(self.jugendleiter.distinct())
return ps.intersection(jls) return ps.intersection(jls)
@property
def staff_on_memberlist_count(self):
return len(self.staff_on_memberlist)
@property @property
def participant_count(self): def participant_count(self):
ps = set(map(lambda x: x.member, self.membersonlist.distinct())) ps = set(map(lambda x: x.member, self.membersonlist.distinct()))
jls = set(self.jugendleiter.distinct()) jls = set(self.jugendleiter.distinct())
return len(ps - jls) return len(ps - jls)
@property
def head_count(self):
return self.staff_on_memberlist_count + self.participant_count
@property @property
def approved_staff_count(self): def approved_staff_count(self):
"""Number of approved youth leaders for this excursion. The base number is calculated """Number of approved youth leaders for this excursion. The base number is calculated

Loading…
Cancel
Save