diff --git a/greg/signals.py b/greg/signals.py index 9cf2a8ea5fcd96e141a3aaca98ed62bdf0205eb8..5780e614f0735add171167a836264e4982bcb815 100644 --- a/greg/signals.py +++ b/greg/signals.py @@ -129,19 +129,23 @@ def save_notification_callback(sender, instance, created, *args, **kwargs): return # Queue future notifications on start and end date for roles if isinstance(instance, Role): - if instance.start_date: + if ( + "start_date" in instance._changed_fields # pylint: disable=protected-access + and instance.start_date + ): Schedule.objects.create( func="greg.signals._queue_role_start_notification", args=f"{instance.id},True", next_run=date_to_datetime_midnight(instance.start_date), schedule_type=Schedule.ONCE, ) - Schedule.objects.create( - func="greg.signals._queue_role_end_notification", - args=f"{instance.id},True", - next_run=date_to_datetime_midnight(instance.end_date), - schedule_type=Schedule.ONCE, - ) + if "end_date" in instance._changed_fields: # pylint: disable=protected-access + Schedule.objects.create( + func="greg.signals._queue_role_end_notification", + args=f"{instance.id},True", + next_run=date_to_datetime_midnight(instance.end_date), + schedule_type=Schedule.ONCE, + ) meta = _create_metadata(instance) operation = "add" if created else "update" _store_notification(