Removed possibility to access kpsul when not adherent

This commit is contained in:
Julien Malka 2021-11-29 22:22:54 +01:00
parent 65eb95a3c9
commit b3e35b639a
4 changed files with 9 additions and 4 deletions

View file

@ -51,7 +51,7 @@
{# TODO: Since Django 1.9, we can store result with "as", allowing proper value management (if None) #} {# TODO: Since Django 1.9, we can store result with "as", allowing proper value management (if None) #}
<li><a href="{% slugurl "k-fet" %}">Page d'accueil</a></li> <li><a href="{% slugurl "k-fet" %}">Page d'accueil</a></li>
<li><a href="https://cof.ens.fr/gestion/k-fet/le-calendrier/">Calendrier</a></li> <li><a href="https://cof.ens.fr/gestion/k-fet/le-calendrier/">Calendrier</a></li>
{% if perms.kfet.is_team %} {% if perms.kfet.is_team and user.profile.is_cof %}
<li><a href="{% url 'kfet.kpsul' %}">K-Psul</a></li> <li><a href="{% url 'kfet.kpsul' %}">K-Psul</a></li>
{% endif %} {% endif %}
</ul> </ul>

View file

@ -2,7 +2,7 @@ from django.contrib.auth.decorators import user_passes_test
def kfet_is_team(user): 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) teamkfet_required = user_passes_test(kfet_is_team)

View file

@ -44,7 +44,12 @@ class AccountManager(models.Manager):
if password is None: if password is None:
raise self.model.DoesNotExist 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): class Account(models.Model):

View file

@ -72,7 +72,7 @@
{% url "kfet.account.read" user.profile.account_kfet.trigramme as url_my_account %} {% 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" %} {% include "kfet/nav_item.html" with href=url_my_account glyphicon="user" text="Mon compte" %}
{% endif %} {% 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.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.transfers" glyphicon="transfer" text="Transferts" %}
{% include "kfet/nav_item.html" with url="kfet.history" glyphicon="th-list" text="Historique" %} {% include "kfet/nav_item.html" with url="kfet.history" glyphicon="th-list" text="Historique" %}