Compare commits

...

2 commits

Author SHA1 Message Date
Julien Malka
eb70e8a273 Fixed wrong return type 2021-11-30 23:07:13 +01:00
Julien Malka
b3e35b639a Removed possibility to access kpsul when not adherent 2021-11-29 22:22:54 +01:00
4 changed files with 10 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) #}
<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>
{% 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>
{% endif %}
</ul>

View file

@ -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)

View file

@ -44,7 +44,13 @@ 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:
raise self.model.DoesNotExist
class Account(models.Model):

View file

@ -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" %}