add a rerun field to diffusion; fix minor bug that can happen on new year's eve

This commit is contained in:
bkfox
2015-11-17 15:45:29 +01:00
parent 64c59f22ab
commit 44fc4dae31
5 changed files with 90 additions and 19 deletions

View File

@ -23,16 +23,20 @@ from aircox_programs.models import *
class Actions:
@staticmethod
def update (date):
items = []
for schedule in Schedule.objects.filter(program__active = True):
items += schedule.diffusions_of_month(date, exclude_saved = True)
count = 0
for schedule in Schedule.objects.filter(program__active = True) \
.order_by('rerun'):
# in order to allow rerun links between diffusions, we save items
# by schedule;
items = schedule.diffusions_of_month(date, exclude_saved = True)
count += len(items)
Diffusion.objects.bulk_create(items)
print('> {} new diffusions for schedule #{} ({})'.format(
len(items), schedule.id, str(schedule)
))
print('total of {} diffusions will be created. To be used, they need '
'manual approval.'.format(len(items)))
Diffusion.objects.bulk_create(items)
print('total of {} diffusions have been created. They need a '
'manual approval.'.format(count))
@staticmethod
def clean (date):