From b47d14f5a5d6ae9b8b424a4f2911c1b01e05eea9 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Tue, 13 Feb 2018 11:48:34 +0100
Subject: [PATCH] Save on the right time

---
 submissions/views.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/submissions/views.py b/submissions/views.py
index 1e1cc60d5..1f6c89352 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -490,6 +490,9 @@ def assignment_request(request, assignment_id):
             assignment.submission.reporting_deadline = deadline
             assignment.submission.open_for_commenting = True
             assignment.submission.latest_activity = timezone.now()
+            # Save assignment and submission
+            assignment.save()
+            assignment.submission.save()
 
             SubmissionUtils.load({'assignment': assignment})
             SubmissionUtils.deprecate_other_assignments()
@@ -505,11 +508,12 @@ def assignment_request(request, assignment_id):
             assignment.accepted = False
             assignment.refusal_reason = form.cleaned_data['refusal_reason']
             assignment.submission.status = 'unassigned'
+
+            # Save assignment and submission
+            assignment.save()
+            assignment.submission.save()
             msg = 'Thank you for considering'
             url = reverse('submissions:pool')
-        # Save assignment and submission
-        assignment.save()
-        assignment.submission.save()
 
         # Form submitted, redirect user
         messages.success(request, msg)
-- 
GitLab