Abstract connection method

This commit is contained in:
Tom Hubrecht 2021-01-27 14:55:28 +01:00
parent 92fe03d81c
commit fd80f23112
2 changed files with 11 additions and 6 deletions

View file

@ -3,6 +3,8 @@ from django.contrib.auth.models import AbstractUser
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from .staticdefs import CONNECTION_METHODS
# ############################################################################# # #############################################################################
# Models regarding an election # Models regarding an election
# ############################################################################# # #############################################################################
@ -114,9 +116,5 @@ class User(AbstractUser):
return election.restricted and (self.election == election) return election.restricted and (self.election == election)
def connection_method(self): def connection_method(self):
if self.election is None: method = self.username.split("__")[0]
if self.username.split("__")[0] == "pwd": return CONNECTION_METHODS.get(method, _("identifiants spécifiques"))
return _("mot de passe")
return _("CAS")
return _("identifiants spécifiques")

View file

@ -1,3 +1,5 @@
from django.utils.translation import gettext_lazy as _
MAIL_VOTERS = ( MAIL_VOTERS = (
"Dear {full_name},\n" "Dear {full_name},\n"
"\n" "\n"
@ -10,3 +12,8 @@ MAIL_VOTERS = (
"-- \n" "-- \n"
"Kadenios" "Kadenios"
) )
CONNECTION_METHODS = {
"pwd": _("mot de passe"),
"cas": _("CAS"),
}