From dd7cfe65779b54e3f97cc38fec0f77be6bb5b98b Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Mon, 26 Jun 2023 17:16:00 +0200 Subject: [PATCH] add trying to determine submitting author order --- scipost_django/submissions/forms/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scipost_django/submissions/forms/__init__.py b/scipost_django/submissions/forms/__init__.py index 714b97048..61a5391cc 100644 --- a/scipost_django/submissions/forms/__init__.py +++ b/scipost_django/submissions/forms/__init__.py @@ -1546,10 +1546,24 @@ class SubmissionForm(forms.ModelForm): submission.save() + # Try to match the submitting author's last name to a position from the author list. + try: + submitting_author_order = list( + map( + lambda x: self.requested_by.contributor.profile.last_name + in x.strip(), + submission.author_list.split(","), + ) + ).index(True) + except ValueError: + # Otherwise, assume the submitting author is the first author. + submitting_author_order = 1 + # Add the submitter's AuthorProfile: author_profile = SubmissionAuthorProfile( submission=submission, profile=self.requested_by.contributor.profile, + order=submitting_author_order, ) author_profile.save() submission.author_profiles.add(author_profile) -- GitLab