On définit STAFF_ENTRANCE_YEAR dans le modèle CASAccount

This commit is contained in:
Tom Hubrecht 2021-05-25 11:10:34 +02:00
parent e6bc3d25dc
commit cb3a1b232f
2 changed files with 5 additions and 2 deletions

View file

@ -30,6 +30,9 @@ class CASAccount(models.Model):
verbose_name=_("année de création du compte CAS"), blank=False, null=False
)
# The entrance year 0 is used for members of staff
STAFF_ENTRANCE_YEAR = 0
class Meta:
verbose_name = _("Compte CAS")
verbose_name_plural = _("Comptes CAS")

View file

@ -6,6 +6,7 @@ from cas import CASClient
from django.conf import settings
from authens import conf as default_conf
from authens.models import CASAccount
def get_cas_client(request):
@ -35,9 +36,8 @@ def parse_entrance_year(home_dir):
settings, "AUTHENS_ALLOW_STAFF", default_conf.AUTHENS_ALLOW_STAFF
)
# The staff members have an entrance year set to 0
if allow_staff and dirs[:3] == ["", "users", "staffs"]:
return 0
return CASAccount.STAFF_ENTRANCE_YEAR
if len(dirs) < 3 or not dirs[2].isdecimal() or dirs[1] != "users":
raise ValueError("Invalid home directory: {}".format(home_dir))