From 30d0d6b68ac48b45de1cc97270e733e4ab8af240 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Thu, 12 Apr 2018 12:13:52 +0200
Subject: [PATCH] Clean up logic order in coauthorship checks

---
 submissions/views.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/submissions/views.py b/submissions/views.py
index 8e6375aed..910111727 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -445,10 +445,6 @@ def assign_submission(request, arxiv_identifier_w_vn_nr):
                                    arxiv_identifier_w_vn_nr=arxiv_identifier_w_vn_nr)
     form = EditorialAssignmentForm(request.POST or None, submission=submission)
 
-    fellows_with_expertise = submission.fellows.filter(
-        contributor__expertises__contains=[submission.subject_area])
-    coauthorships = submission.flag_coauthorships_arxiv(fellows_with_expertise)
-
     if form.is_valid():
         ed_assignment = form.save()
         SubmissionUtils.load({'assignment': ed_assignment})
@@ -456,6 +452,10 @@ def assign_submission(request, arxiv_identifier_w_vn_nr):
         messages.success(request, 'Your assignment request has been sent successfully.')
         return redirect('submissions:pool')
 
+    fellows_with_expertise = submission.fellows.filter(
+        contributor__expertises__contains=[submission.subject_area])
+    coauthorships = submission.flag_coauthorships_arxiv(fellows_with_expertise)
+
     context = {
         'submission_to_assign': submission,
         'fellows_with_expertise': fellows_with_expertise,
@@ -1396,10 +1396,6 @@ def prepare_for_voting(request, rec_id):
     recommendation = get_object_or_404(
         EICRecommendation.objects.active().filter(submission__in=submissions), id=rec_id)
 
-    fellows_with_expertise = recommendation.submission.fellows.filter(
-        contributor__expertises__contains=[recommendation.submission.subject_area])
-
-    coauthorships = {}
     eligibility_form = VotingEligibilityForm(request.POST or None, instance=recommendation)
     if eligibility_form.is_valid():
         eligibility_form.save()
@@ -1412,6 +1408,8 @@ def prepare_for_voting(request, rec_id):
         return redirect(reverse('submissions:editorial_page',
                                 args=[recommendation.submission.arxiv_identifier_w_vn_nr]))
     else:
+        fellows_with_expertise = recommendation.submission.fellows.filter(
+            contributor__expertises__contains=[recommendation.submission.subject_area])
         coauthorships = recommendation.submission.flag_coauthorships_arxiv(fellows_with_expertise)
 
     context = {
-- 
GitLab