From 85f6ebf125bfefc5954c92370ed88075601a8b87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org>
Date: Tue, 24 Jan 2023 11:45:44 +0100
Subject: [PATCH] Proceedings: populate fellows only with relevant (guest) ones

---
 scipost_django/submissions/forms/__init__.py | 27 ++++++++++----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/scipost_django/submissions/forms/__init__.py b/scipost_django/submissions/forms/__init__.py
index 7e5f6b770..eb501fe3e 100644
--- a/scipost_django/submissions/forms/__init__.py
+++ b/scipost_django/submissions/forms/__init__.py
@@ -1523,22 +1523,23 @@ class SubmissionForm(forms.ModelForm):
         Set the default set of (guest) Fellows for this Submission.
         """
         qs = Fellowship.objects.active()
-        fellows = (
-            qs.regular_or_senior()
-            .filter(
-                college=submission.submitted_to.college,
-                contributor__profile__specialties__in=submission.specialties.all(),
-            )
-            .return_active_for_submission(submission)
-        )
-        submission.fellows.set(fellows)
-
         if submission.proceedings:
-            # Add (Regular or Guest) Fellowships if the Submission is a Proceedings manuscript
-            guest_fellows = qs.filter(
+            # Add only Proceedings-related Fellowships
+            fellows = qs.filter(
                 proceedings=submission.proceedings
             ).return_active_for_submission(submission)
-            submission.fellows.add(*guest_fellows)
+            submission.fellows.set(fellows)
+
+        else:
+            fellows = (
+                qs.regular_or_senior()
+                .filter(
+                    college=submission.submitted_to.college,
+                    contributor__profile__specialties__in=submission.specialties.all(),
+                )
+                .return_active_for_submission(submission)
+            )
+            submission.fellows.set(fellows)
 
 
 class SubmissionReportsForm(forms.ModelForm):
-- 
GitLab