From a4db79353bd3c7b688e1a8f597a101210ca96c9f Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 26 Jan 2021 15:35:10 +0100 Subject: [PATCH] =?UTF-8?q?On=20utilise=20get=5Fusername=20=C3=A0=20la=20p?= =?UTF-8?q?lace=20de=20base=5Fusername?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elections/models.py | 5 ++--- elections/templates/elections/upload_voters.html | 2 +- elections/utils.py | 2 +- shared/templates/base.html | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/elections/models.py b/elections/models.py index 849cb7f..7b22daf 100644 --- a/elections/models.py +++ b/elections/models.py @@ -102,9 +102,8 @@ class User(AbstractUser): ) full_name = models.CharField(_("Nom et Prénom"), max_length=150, blank=True) - @property - def base_username(self): - return self.username.split("__")[-1] + def get_username(self): + return "__".join(self.username.split("__")[1:]) def can_vote(self, election): # Si c'est un·e utilisateur·ice CAS, iel peut voter dans les élections diff --git a/elections/templates/elections/upload_voters.html b/elections/templates/elections/upload_voters.html index d7873c5..ae7a12d 100644 --- a/elections/templates/elections/upload_voters.html +++ b/elections/templates/elections/upload_voters.html @@ -110,7 +110,7 @@ {% for v in voters %} - {{ v.base_username }} + {{ v.get_username }} {{ v.full_name }} {{ v.email }} diff --git a/elections/utils.py b/elections/utils.py index 8c59921..9beda7d 100644 --- a/elections/utils.py +++ b/elections/utils.py @@ -103,7 +103,7 @@ def send_mail(election, mail_form): body=mail_form.cleaned_data["message"].format( full_name=v.full_name, election_url=url, - username=v.base_username, + username=v.get_username, password=password, ), to=[v.email], diff --git a/shared/templates/base.html b/shared/templates/base.html index b32c4ea..dc74653 100644 --- a/shared/templates/base.html +++ b/shared/templates/base.html @@ -50,7 +50,7 @@ {% if user.is_authenticated %}
- {% blocktrans with name=user.base_username connection=user.connection_method %}Connecté·e en tant que {{ name }} par {{ connection }}{% endblocktrans %} + {% blocktrans with name=user.get_username connection=user.connection_method %}Connecté·e en tant que {{ name }} par {{ connection }}{% endblocktrans %}