SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 0bb94c2e authored by George Katsikas's avatar George Katsikas :goat:
Browse files

fix repo creation for authors with accents

parent 2caaf863
No related branches found
No related tags found
1 merge request!52New Production page fixes and oversights
......@@ -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",
)
......
......@@ -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,
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment