diff --git a/scipost_django/production/management/commands/advance_git_repos.py b/scipost_django/production/management/commands/advance_git_repos.py index c9640dfa9a3068a82b8b5c5e3ad888ea8ddc2e5c..00c16f2d1cd10fc55f4a0ee20298ec1950e93751 100644 --- a/scipost_django/production/management/commands/advance_git_repos.py +++ b/scipost_django/production/management/commands/advance_git_repos.py @@ -42,7 +42,7 @@ class Command(BaseCommand): def add_arguments(self, parser: CommandParser) -> None: parser.add_argument( "--id", - type=int, + type=str, required=False, help="The submission preprint identifier to handle a specific submission, leave blank to handle all", ) diff --git a/scipost_django/production/models.py b/scipost_django/production/models.py index 55023d88c41ae8ba26ab1e94985dcd628fdd3e3e..1840901a7fa02daf372c5c7bdb0acdcd234131b4 100644 --- a/scipost_django/production/models.py +++ b/scipost_django/production/models.py @@ -15,6 +15,8 @@ from django.db.models import Value from django.db.models.functions import Concat from django.conf import settings +from common.utils import latinise + from .constants import ( PRODUCTION_STREAM_STATUS, PRODUCTION_STREAM_INITIATED, @@ -312,8 +314,11 @@ class ProofsRepository(models.Model): first_author_last_name = first_author_str.split(" ")[-1] else: first_author_last_name = first_author_profile.last_name - # Keep only the last of the last names - first_author_last_name = first_author_last_name.split(" ")[-1] + + # Remove accents from the last name to avoid encoding issues + # and join multiple last names into one + first_author_last_name = latinise(first_author_last_name).strip() + first_author_last_name = first_author_last_name.replace(" ", "-") return "{preprint_id}_{last_name}".format( preprint_id=self.stream.submission.preprint.identifier_w_vn_nr, diff --git a/scipost_django/production/tests/test_models.py b/scipost_django/production/tests/test_models.py index e35c6d72e48182c4ed96b86204e5deeeaf51c62d..78a12ca5f3a62aebb84143c3235e223f80e6d7cb 100644 --- a/scipost_django/production/tests/test_models.py +++ b/scipost_django/production/tests/test_models.py @@ -153,7 +153,7 @@ class TestProofRepository(TestCase): user_profile.last_name = "Usable User" user_profile.save() - self.assertEqual(proofs_repo.name, "scipost_202101_00001v1_User") + self.assertEqual(proofs_repo.name, "scipost_202101_00001v1_Usable-User") def test_repo_name_two_authors(self): proofs_repo = ProofsRepository.objects.get( @@ -166,6 +166,20 @@ class TestProofRepository(TestCase): self.assertEqual(proofs_repo.name, "scipost_202101_00001v1_Person") + def test_repo_name_accented_authors(self): + proofs_repo = ProofsRepository.objects.get( + stream__submission__preprint__identifier_w_vn_nr="scipost_202101_00001v1" + ) + + user_profile = Contributor.objects.get(user__username="testuser").profile + user_profile.first_name = "Some" + user_profile.last_name = "Pérsønüsær (陈)" + user_profile.save() + + proofs_repo.stream.submission.author_list = "Some Pérsønüsær (陈)" + + self.assertEqual(proofs_repo.name, "scipost_202101_00001v1_Personusaer") + def test_repo_paths_scipostphys(self): proofs_repo = ProofsRepository.objects.get( stream__submission__preprint__identifier_w_vn_nr="scipost_202101_00001v1"