diff --git a/scipost_django/profiles/forms.py b/scipost_django/profiles/forms.py index 1a461b96e45834bf615002411c38df0fc255a73e..b3af602d1b93fd1ca1e55868d792b04f8b1db896 100644 --- a/scipost_django/profiles/forms.py +++ b/scipost_django/profiles/forms.py @@ -35,6 +35,8 @@ class ProfileForm(forms.ModelForm): "title", "first_name", "last_name", + "first_name_original", + "last_name_original", "orcid_id", "webpage", "acad_field", diff --git a/scipost_django/profiles/migrations/0040_profile_first_name_original_and_more.py b/scipost_django/profiles/migrations/0040_profile_first_name_original_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..8b45c93edbf084d551450b98734835a57f83b9f2 --- /dev/null +++ b/scipost_django/profiles/migrations/0040_profile_first_name_original_and_more.py @@ -0,0 +1,34 @@ +# Generated by Django 4.2.10 on 2024-04-04 12:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("profiles", "0039_alter_profileemail_profile"), + ] + + operations = [ + migrations.AddField( + model_name="profile", + name="first_name_original", + field=models.CharField( + blank=True, + default="", + help_text="Name in original script (if not using the Latin alphabet)", + max_length=64, + verbose_name="First name (original)", + ), + ), + migrations.AddField( + model_name="profile", + name="last_name_original", + field=models.CharField( + blank=True, + default="", + help_text="Name in original script (if not using the Latin alphabet)", + max_length=64, + verbose_name="Last name (original)", + ), + ), + ] diff --git a/scipost_django/profiles/models.py b/scipost_django/profiles/models.py index 052b9762efc2f77f9c2218e4fa39c940d6b701dc..9c851d6fb9224ae5bd34318ce8717a6959d38eed 100644 --- a/scipost_django/profiles/models.py +++ b/scipost_django/profiles/models.py @@ -58,6 +58,21 @@ class Profile(models.Model): first_name = models.CharField(max_length=64) last_name = models.CharField(max_length=64) + first_name_original = models.CharField( + max_length=64, + blank=True, + default="", + verbose_name="First name (original)", + help_text="Name in original script (if not using the Latin alphabet)", + ) + last_name_original = models.CharField( + max_length=64, + blank=True, + default="", + verbose_name="Last name (original)", + help_text="Name in original script (if not using the Latin alphabet)", + ) + orcid_id = models.CharField( max_length=20, verbose_name="ORCID id", blank=True, validators=[orcid_validator] ) @@ -103,6 +118,10 @@ class Profile(models.Model): def full_name(self): return f"{self.first_name} {self.last_name}" + @property + def full_name_original(self): + return f"{self.first_name_original} {self.last_name_original}" + @property def roles(self): try: diff --git a/scipost_django/scipost/forms.py b/scipost_django/scipost/forms.py index 7c3efdfd35019f001c7755b1d5aed6e9c701d92d..9c733c24d01ca9b1c30f6f2ecec67432eeda37f5 100644 --- a/scipost_django/scipost/forms.py +++ b/scipost_django/scipost/forms.py @@ -112,10 +112,24 @@ class RegistrationForm(forms.Form): are thus separately handled here. """ - title = forms.ChoiceField(choices=TITLE_CHOICES, label="* Title") - first_name = forms.CharField(label="* First name", max_length=100) - last_name = forms.CharField(label="* Last name", max_length=100) - email = forms.EmailField(label="* Email address") + required_css_class = "required-asterisk" + + title = forms.ChoiceField(choices=TITLE_CHOICES, label="Title") + email = forms.EmailField(label="Email address") + first_name = forms.CharField(label="First name", max_length=64) + last_name = forms.CharField(label="Last name", max_length=64) + first_name_original = forms.CharField( + label="First name (original script)", + max_length=64, + required=False, + help_text="Name in original script (if not using the Latin alphabet)", + ) + last_name_original = forms.CharField( + label="Last name (original script)", + max_length=64, + required=False, + help_text="Name in original script (if not using the Latin alphabet)", + ) invitation_key = forms.CharField( max_length=40, widget=forms.HiddenInput(), required=False ) @@ -149,7 +163,7 @@ class RegistrationForm(forms.Form): widget=autocomplete.ModelSelect2( url="/organizations/organization-autocomplete", attrs={"data-html": True} ), - label="* Current affiliation", + label="Current affiliation", help_text=( "Start typing, then select in the popup; " "if you do not find the organization you seek, " @@ -173,19 +187,19 @@ class RegistrationForm(forms.Form): ), ) username = forms.CharField( - label="* Username", + label="Username", max_length=100, validators=[ UnicodeUsernameValidator, ], ) - password = forms.CharField(label="* Password", widget=forms.PasswordInput()) + password = forms.CharField(label="Password", widget=forms.PasswordInput()) password_verif = forms.CharField( - label="* Verify password", + label="Verify password", widget=forms.PasswordInput(), help_text="Your password must contain at least 8 characters", ) - captcha = ReCaptchaField(label="* Please verify to continue:") + captcha = ReCaptchaField(label="Please verify to continue:") subscribe = forms.BooleanField( required=False, initial=False, @@ -271,6 +285,8 @@ class RegistrationForm(forms.Form): title=self.cleaned_data["title"], first_name=self.cleaned_data["first_name"], last_name=self.cleaned_data["last_name"], + first_name_original=self.cleaned_data["first_name_original"], + last_name_original=self.cleaned_data["last_name_original"], acad_field=self.cleaned_data["acad_field"], orcid_id=self.cleaned_data["orcid_id"], webpage=self.cleaned_data["webpage"],