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