minimal simplification

MK/finance_workflow
Christian Merten 8 months ago
parent 2ede2040ce
commit 4f38b5bd3c
Signed by: christian.merten
GPG Key ID: D953D69721B948B3

@ -1278,14 +1278,14 @@ class Freizeit(CommonModel):
return sum([i.duration for i in self.ljpproposal.intervention_set.all()])
else:
return 0
@property
def total_seminar_days(self):
"""calculate seminar days based on intervention hours in every day"""
# TODO: add tests for this
if hasattr(self, 'ljpproposal'):
hours_per_day = (
Intervention.objects
.filter(ljp_proposal_id=self.ljpproposal.id)
self.ljpproposal.intervention_set
.annotate(day=TruncDate('date_start')) # Extract the date (without time)
.values('day') # Group by day
.annotate(total_duration=Sum('duration')) # Sum durations for each day
@ -1302,17 +1302,17 @@ class Freizeit(CommonModel):
def ljp_duration(self):
"""calculate the duration in days for the LJP"""
return min(self.duration, self.total_seminar_days)
@property
def staff_count(self):
return self.jugendleiter.count()
@property
def staff_on_memberlist(self):
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)
@ -1322,7 +1322,7 @@ class Freizeit(CommonModel):
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

Loading…
Cancel
Save