From 9c9c490d1c98b8c534b53b7505d0cf3b3edd87fa Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Fri, 6 Oct 2017 19:05:11 +0200
Subject: [PATCH] Fix: stream signal referenced from instance

---
 production/signals.py | 5 ++---
 production/views.py   | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/production/signals.py b/production/signals.py
index 2d17c3a33..31327d531 100644
--- a/production/signals.py
+++ b/production/signals.py
@@ -46,9 +46,8 @@ def notify_stream_completed(sender, instance, **kwargs):
     """
     Notify the production team about a Production Stream being completed.
     """
-    stream = instance.stream
-    notify.send(sender=sender, recipient=stream.officer.user,
+    notify.send(sender=sender, recipient=instance.officer.user,
                 actor=sender, verb=' marked Production Stream as completed.', target=instance)
 
-    notify.send(sender=sender, recipient=stream.supervisor.user,
+    notify.send(sender=sender, recipient=instance.supervisor.user,
                 actor=sender, verb=' marked Production Stream as completed.', target=instance)
diff --git a/production/views.py b/production/views.py
index 9c86ca0c9..64b7d4eb2 100644
--- a/production/views.py
+++ b/production/views.py
@@ -217,6 +217,7 @@ class DeleteEventView(DeleteView):
 
 @is_production_user()
 @permission_required('scipost.can_publish_accepted_submission', raise_exception=True)
+@transaction.atomic
 def mark_as_completed(request, stream_id):
     stream = get_object_or_404(ProductionStream.objects.ongoing(), pk=stream_id)
     stream.status = PRODUCTION_STREAM_COMPLETED
-- 
GitLab