Rajoute le nom complet

This commit is contained in:
Tom Hubrecht 2020-12-23 18:04:39 +01:00
parent 40762af938
commit b44f150cf9
4 changed files with 26 additions and 2 deletions

View file

@ -0,0 +1,20 @@
# Generated by Django 2.2.17 on 2020-12-23 17:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("elections", "0004_auto_20201220_1847"),
]
operations = [
migrations.AddField(
model_name="user",
name="full_name",
field=models.CharField(
blank=True, max_length=150, verbose_name="Nom et Prénom"
),
),
]

View file

@ -87,6 +87,7 @@ class User(AbstractUser):
blank=True,
on_delete=models.CASCADE,
)
full_name = models.CharField(_("Nom et Prénom"), max_length=150, blank=True)
@property
def base_username(self):

View file

@ -15,7 +15,7 @@ def create_users(election, csv_file):
reader = csv.reader(io.StringIO(csv_file.read().decode("utf-8")), dialect)
for (username, full_name, email) in reader:
election.registered_voters.create(
username=f"{election.id}__{username}", email=email
username=f"{election.id}__{username}", email=email, full_name=full_name
)

View file

@ -37,6 +37,7 @@ class ENSCASBackend:
"""
email = attributes.get("email")
name = attributes.get("name")
try:
user = UserModel.objects.get(username=cas_login)
@ -44,7 +45,9 @@ class ENSCASBackend:
user = None
if user is None:
user = UserModel.objects.create_user(username=cas_login, email=email)
user = UserModel.objects.create_user(
username=cas_login, email=email, full_name=name
)
return user
# Django boilerplate.