Commit 489a6b93 authored by fred's avatar fred

add special case for daily program with same-day rerun

parent eb1d9047
......@@ -184,7 +184,12 @@ class EpisodeNewForm(EpisodeForm):
def get_diffusion_fields(self, emission):
if emission:
schedules = Schedule.objects.filter(emission=emission, rerun=True).count() + 1
schedules = list(Schedule.objects.filter(emission=emission).order_by('datetime'))
if len(schedules) > 1 and schedules[0].datetime.date() == schedules[1].datetime.date():
# special case for daily program with same-day rerun
schedules = 2
else:
schedules = len([x for x in schedules if x.rerun]) + 1
else:
schedules = 1
fields = ['first_diffusion']
......
......@@ -237,6 +237,9 @@ class Schedule(models.Model, WeekdayMixin):
else:
return self.emission.duration
def end_datetime(self):
return self.datetime + datetime.timedelta(minutes=self.get_duration())
def match_week(self, week_no):
if week_no == 4:
# this is the fifth week of the month, only return True for
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment