diff --git a/scipost_django/production/management/commands/advance_git_repos.py b/scipost_django/production/management/commands/advance_git_repos.py index fff380e393a0dcec61d03f0632f3ef67db8090bf..ae1ec0bae52cc3d30872751488fc22ffaa89ffc9 100644 --- a/scipost_django/production/management/commands/advance_git_repos.py +++ b/scipost_django/production/management/commands/advance_git_repos.py @@ -3,7 +3,7 @@ __license__ = "AGPL v3" from datetime import datetime from functools import reduce -from itertools import cycle +from itertools import chain, cycle from typing import Any, Callable, Dict, List, Tuple from time import sleep @@ -197,8 +197,19 @@ class Command(BaseCommand): "{ROOT}/Templates/Base".format(ROOT=settings.GITLAB_ROOT) ) - base_actions = self._get_project_cloning_actions(base_template_project) - journal_actions = self._get_project_cloning_actions(journal_template_project) + all_actions = [] + # Add "Base" and Journal specific templates to the repo + all_actions.append(self._get_project_cloning_actions(base_template_project)) + all_actions.append(self._get_project_cloning_actions(journal_template_project)) + + # Add the "Selected" template if the submission has been accepted in Selections + if "Selections" in repo.stream.submission.editorial_decision.for_journal.name: + selected_template_project = self.GL.projects.get( + "{ROOT}/Templates/Selected".format(ROOT=settings.GITLAB_ROOT) + ) + all_actions.append( + self._get_project_cloning_actions(selected_template_project) + ) # Add some delays to avoid: # - Commiting the files before the branch has finished being created @@ -209,7 +220,7 @@ class Command(BaseCommand): { "branch": "main", "commit_message": "copy pure templates", - "actions": base_actions + journal_actions, + "actions": list(chain(*all_actions)), } ) sleep(3) @@ -379,6 +390,12 @@ class Command(BaseCommand): "<|ACCEPTED|>": (format_date_human_readable, paper_acceptance_date), } + # Replace the logo if the submission has been accepted in Selections + if "Selections" in repo.stream.submission.editorial_decision.for_journal.name: + default_logo_img = r"[width=20mm]{logo_scipost_with_bgd.pdf}" + selections_logo_img = r"[width=34.55mm]{logo_select.pdf}" + replacements_dict[default_logo_img] = (lambda _: selections_logo_img, None) + # Define a helper function to try to format and replace a placeholder # which catches any errors and prints them to the console non-intrusively def try_format_replace( diff --git a/scipost_django/production/models.py b/scipost_django/production/models.py index 98395469224914d4e3f747efdba665bc2dc4f200..2b6fbd92542f7d53b0398dc791217382874f0721 100644 --- a/scipost_django/production/models.py +++ b/scipost_django/production/models.py @@ -16,6 +16,7 @@ from django.db.models.functions import Concat from django.conf import settings from common.utils import latinise +from journals.models import Journal from submissions.models.decision import EditorialDecision from .constants import ( @@ -342,7 +343,21 @@ class ProofsRepository(models.Model): @property def journal_abbrev(self) -> str: # The DOI label is used to determine the path of the repository and template - return self.stream.submission.editorial_decision.for_journal.doi_label + """ + Returns the journal abbreviation for publication. The journal is the + one associated with the submission's editorial decision, or, in the event of + a Selections paper, it is the flagship journal of the college. + """ + + decision_journal = self.stream.submission.editorial_decision.for_journal + + if "Selections" in decision_journal.name: + paper_field = self.stream.submission.acad_field + college = paper_field.colleges.order_by("order").first() + flagship_journal = college.journals.order_by("list_order").first() + return flagship_journal.doi_label + else: + return decision_journal.doi_label @property def journal_subdivision(self) -> str: diff --git a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html index e00ea49a7831016a0a3be010371b8e4e1c7e1bd4..b6d3530c45569321eb90a8ca91e5589f9c756a94 100644 --- a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html +++ b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html @@ -57,6 +57,9 @@ {% endif %} {% else %} {{ productionstream.submission.editorial_decision.for_journal }} + {% if "Selections" in productionstream.submission.editorial_decision.for_journal.name %} + - {{ productionstream.submission.acad_field }} + {% endif %} {% endif %} </div>