@@ -524,12 +524,8 @@ class PatchChangeNotification(models.Model):
last_modified = models.DateTimeField(default = datetime.datetime.now)
orig_state = models.ForeignKey(State)
-def _patch_change_callback(sender, instance, **kwargs):
- # we only want notification of modified patches
- if instance.pk is None:
- return
-
- if instance.project is None or not instance.project.send_notifications:
+def _patch_queue_notifications(instance):
+ if not instance.project.send_notifications:
return
try:
@@ -560,4 +556,14 @@ def _patch_change_callback(sender, instance, **kwargs):
notification.last_modified = datetime.datetime.now()
notification.save()
+def _patch_change_callback(sender, instance, **kwargs):
+ # we only want notification of modified patches
+ if instance.pk is None:
+ return
+
+ if instance.project is None:
+ return;
+
+ _patch_queue_notifications(instance)
+
models.signals.pre_save.connect(_patch_change_callback, sender = Patch)
I want to add Series state update on patch change, so start by factoring out the notification code that was already there so we can add the series update at the same level. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> --- patchwork/models.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)