From 26988f357ba2a4a5c16b62b06388ffd67797a053 Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Wed, 9 Aug 2023 17:07:13 +0300
Subject: [PATCH] search profiles only when matching authors

---
 scipost_django/edadmin/views/preassignment.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scipost_django/edadmin/views/preassignment.py b/scipost_django/edadmin/views/preassignment.py
index c7f99ce80..20fb718e4 100644
--- a/scipost_django/edadmin/views/preassignment.py
+++ b/scipost_django/edadmin/views/preassignment.py
@@ -121,12 +121,12 @@ def _hx_author_profile_action(
     submission = get_object_or_404(
         Submission, preprint__identifier_w_vn_nr=identifier_w_vn_nr
     )
-    profile = get_object_or_404(Profile, pk=profile_id)
     author_profile, created = SubmissionAuthorProfile.objects.get_or_create(
         submission=submission,
         order=order,
     )
     if action == "match":
+        profile = get_object_or_404(Profile, pk=profile_id)
         author_profile.profile = profile
         # add Submission's topics to profile:
         profile.topics.add(*submission.topics.all())
-- 
GitLab