From cb3a1b232fefa2a81bf177be93e6105f39cc4f19 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 25 May 2021 11:10:34 +0200 Subject: [PATCH] =?UTF-8?q?On=20d=C3=A9finit=20STAFF=5FENTRANCE=5FYEAR=20d?= =?UTF-8?q?ans=20le=20mod=C3=A8le=20CASAccount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- authens/models.py | 3 +++ authens/utils.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/authens/models.py b/authens/models.py index a1cbd25..b68b7d0 100644 --- a/authens/models.py +++ b/authens/models.py @@ -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") diff --git a/authens/utils.py b/authens/utils.py index 733cf10..7306506 100644 --- a/authens/utils.py +++ b/authens/utils.py @@ -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))