diff --git a/elections/models.py b/elections/models.py index 7b22daf..065558f 100644 --- a/elections/models.py +++ b/elections/models.py @@ -3,6 +3,8 @@ from django.contrib.auth.models import AbstractUser from django.db import models from django.utils.translation import gettext_lazy as _ +from .staticdefs import CONNECTION_METHODS + # ############################################################################# # Models regarding an election # ############################################################################# @@ -114,9 +116,5 @@ class User(AbstractUser): return election.restricted and (self.election == election) def connection_method(self): - if self.election is None: - if self.username.split("__")[0] == "pwd": - return _("mot de passe") - return _("CAS") - - return _("identifiants spécifiques") + method = self.username.split("__")[0] + return CONNECTION_METHODS.get(method, _("identifiants spécifiques")) diff --git a/elections/staticdefs.py b/elections/staticdefs.py index c35708c..6699d54 100644 --- a/elections/staticdefs.py +++ b/elections/staticdefs.py @@ -1,3 +1,5 @@ +from django.utils.translation import gettext_lazy as _ + MAIL_VOTERS = ( "Dear {full_name},\n" "\n" @@ -10,3 +12,8 @@ MAIL_VOTERS = ( "-- \n" "Kadenios" ) + +CONNECTION_METHODS = { + "pwd": _("mot de passe"), + "cas": _("CAS"), +}