Commit decb0e28 authored by fred's avatar fred

include rerun dates in "add diffusion" datetimes

parent 0b594926
......@@ -275,7 +275,7 @@ class DiffusionDateTimeWidget(forms.Select):
since = dates[-1] + datetime.timedelta(minutes=10)
else:
since = datetime.datetime.now() - datetime.timedelta(days=1)
dates.append(emission.get_next_planned_date(since))
dates.append(emission.get_next_planned_date(since, include_rerun=True))
for date in dates:
yield (date, date.strftime('%d/%m/%Y %H:%M'))
......
......@@ -192,8 +192,11 @@ class Emission(models.Model):
def get_sorted_newsitems(self):
return self.newsitem_set.select_related().order_by('-date')
def get_next_planned_date_and_schedule(self, since=None):
schedules = self.schedule_set.filter(rerun=False)
def get_next_planned_date_and_schedule(self, since=None, include_rerun=False):
if include_rerun:
schedules = self.schedule_set.all()
else:
schedules = self.schedule_set.filter(rerun=False)
if not schedules:
return None
if since is None:
......@@ -204,12 +207,14 @@ class Emission(models.Model):
possible_dates.sort(key=lambda x: x[0])
return possible_dates[0]
def get_next_planned_date(self, since=None):
result = self.get_next_planned_date_and_schedule(since=since)
def get_next_planned_date(self, since=None, include_rerun=False):
result = self.get_next_planned_date_and_schedule(since=since,
include_rerun=include_rerun)
return result[0] if result else None
def get_next_planned_duration(self, since=None):
result = self.get_next_planned_date_and_schedule(since=since)
def get_next_planned_duration(self, since=None, include_rerun=False):
result = self.get_next_planned_date_and_schedule(since=since,
include_rerun=include_rerun)
if not result:
return None
return result[1].duration or self.duration
......
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