Add display name (first_name) shown instead of username on user-facing UI
All checks were successful
Docker / build (release) Successful in 8s
All checks were successful
Docker / build (release) Successful in 8s
This commit is contained in:
parent
28f279a4ab
commit
b57f9092aa
5 changed files with 21 additions and 3 deletions
|
|
@ -8,6 +8,12 @@ from django.utils.translation import gettext_lazy as _
|
|||
|
||||
|
||||
class CustomSignupForm(SignupForm):
|
||||
first_name = forms.CharField(
|
||||
label=_("Display name"),
|
||||
max_length=150,
|
||||
required=True,
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
|
@ -16,6 +22,12 @@ class CustomSignupForm(SignupForm):
|
|||
"Please enter a valid email address ending with `@ens-rennes.fr`"
|
||||
)
|
||||
|
||||
def save(self, request):
|
||||
user = super().save(request)
|
||||
user.first_name = self.cleaned_data["first_name"]
|
||||
user.save()
|
||||
return user
|
||||
|
||||
def clean_email(self):
|
||||
"""
|
||||
Check that the email address ends with a trusted domain.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue