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):
if isinstance(obj, Freizeit):
# 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_people = obj.participant_count + organizer_count
total_people = obj.head_count
else: # fallback if no activity was found
total_people = 0

@ -1145,12 +1145,20 @@ class Freizeit(CommonModel):
ps = set(map(lambda x: x.member, self.membersonlist.distinct()))
jls = set(self.jugendleiter.distinct())
return ps.intersection(jls)
@property
def staff_on_memberlist_count(self):
return len(self.staff_on_memberlist)
@property
def participant_count(self):
ps = set(map(lambda x: x.member, self.membersonlist.distinct()))
jls = set(self.jugendleiter.distinct())
return len(ps - jls)
@property
def head_count(self):
return self.staff_on_memberlist_count + self.participant_count
@property
def approved_staff_count(self):

Loading…
Cancel
Save