From b3e35b639a195b8b5a03ac953942f62ae616d005 Mon Sep 17 00:00:00 2001 From: Julien Malka Date: Mon, 29 Nov 2021 22:22:54 +0100 Subject: [PATCH] Removed possibility to access kpsul when not adherent --- gestioncof/templates/gestioncof/home.html | 2 +- kfet/decorators.py | 2 +- kfet/models.py | 7 ++++++- kfet/templates/kfet/base_nav.html | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gestioncof/templates/gestioncof/home.html b/gestioncof/templates/gestioncof/home.html index 45b3e225..72d5613e 100644 --- a/gestioncof/templates/gestioncof/home.html +++ b/gestioncof/templates/gestioncof/home.html @@ -51,7 +51,7 @@ {# TODO: Since Django 1.9, we can store result with "as", allowing proper value management (if None) #}
  • Page d'accueil
  • Calendrier
  • - {% if perms.kfet.is_team %} + {% if perms.kfet.is_team and user.profile.is_cof %}
  • K-Psul
  • {% endif %} diff --git a/kfet/decorators.py b/kfet/decorators.py index 70848820..643fbe1b 100644 --- a/kfet/decorators.py +++ b/kfet/decorators.py @@ -2,7 +2,7 @@ from django.contrib.auth.decorators import user_passes_test def kfet_is_team(user): - return user.has_perm("kfet.is_team") + return user.has_perm("kfet.is_team") and user.profile.is_cof or user.username == 'kfet_genericteam' teamkfet_required = user_passes_test(kfet_is_team) diff --git a/kfet/models.py b/kfet/models.py index 7a0ec777..a20c0988 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -44,7 +44,12 @@ class AccountManager(models.Manager): if password is None: raise self.model.DoesNotExist - return self.get(password=hash_password(password)) + result = self.get(password=hash_password(password)) + if result.cofprofile.is_cof: + return result + else: + return None + class Account(models.Model): diff --git a/kfet/templates/kfet/base_nav.html b/kfet/templates/kfet/base_nav.html index 1cded20b..3b9fda0e 100644 --- a/kfet/templates/kfet/base_nav.html +++ b/kfet/templates/kfet/base_nav.html @@ -72,7 +72,7 @@ {% url "kfet.account.read" user.profile.account_kfet.trigramme as url_my_account %} {% include "kfet/nav_item.html" with href=url_my_account glyphicon="user" text="Mon compte" %} {% endif %} - {% if perms.kfet.is_team %} + {% if perms.kfet.is_team and user.profile.is_cof or user.username == 'kfet_genericteam'%} {% include "kfet/nav_item.html" with url="kfet.kpsul" glyphicon="shopping-cart" text="K-Psul" %} {% include "kfet/nav_item.html" with url="kfet.transfers" glyphicon="transfer" text="Transferts" %} {% include "kfet/nav_item.html" with url="kfet.history" glyphicon="th-list" text="Historique" %}