fix bugs on signals

This commit is contained in:
bkfox
2016-11-14 13:35:15 +01:00
parent 45268cd699
commit b8d6c435d2
103 changed files with 47 additions and 32 deletions

5
aircox/signals.py Normal file → Executable file
View File

@ -12,6 +12,7 @@ import aircox.utils as utils
@receiver(post_save, sender=models.Schedule)
def schedule_post_saved(sender, instance, created, *args, **kwargs):
# TODO: case instance.program has changed
if not instance.program.sync:
return
@ -19,8 +20,12 @@ def schedule_post_saved(sender, instance, created, *args, **kwargs):
if not initial or not instance.changed(['date','duration', 'frequency']):
return
if not initial.get('date') or not initial.get('duration') or not initial.get('frequency'):
return
# old schedule and timedelta
old_sched = models.Schedule(
program = instance.program,
date = initial['date'],
duration = initial['duration'],
frequency = initial['frequency'],