diff --git a/apps/member/templatetags/__init__.py b/apps/member/templatetags/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/apps/member/templatetags/memberinfo.py b/apps/member/templatetags/memberinfo.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b4986a0a3528c46f75796d7d45da98530043f6 --- /dev/null +++ b/apps/member/templatetags/memberinfo.py @@ -0,0 +1,22 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from datetime import date + +from django import template +from django.contrib.auth.models import User + +from ..models import Club, Membership + + +def is_member(user, club): + if isinstance(user, str): + club = User.objects.get(username=user) + if isinstance(club, str): + club = Club.objects.get(name=club) + return Membership.objects\ + .filter(user=user, club=club, date_start__lte=date.today(), date_end__gte=date.today()).exists() + + +register = template.Library() +register.filter("is_member", is_member) diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index f464ca99b22ec9ecff5f6446a142536f7ef99632..90f9928367b2fc24c830fe44e25b4fa63d4b9132 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-10-07 10:55+0200\n" +"POT-Creation-Date: 2020-10-07 11:42+0200\n" "PO-Revision-Date: 2020-09-13 12:39+0200\n" "Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n" "Language-Team: \n" @@ -3058,13 +3058,23 @@ msgstr "Anmelden" #: note_kfet/templates/base.html:156 msgid "" +"You are not a BDE member anymore. Please renew your membership if you want " +"to use the note." +msgstr "" + +#: note_kfet/templates/base.html:160 +msgid "You are not a Kfet member, so you can't use your note account." +msgstr "" + +#: note_kfet/templates/base.html:166 +msgid "" "Your e-mail address is not validated. Please check your mail inbox and click " "on the validation link." msgstr "" "Ihre E-Mail-Adresse ist nicht validiert. Bitte überprüfen Sie Ihren " "Posteingang und klicken Sie auf den Validierungslink." -#: note_kfet/templates/base.html:161 +#: note_kfet/templates/base.html:171 msgid "" "You declared that you opened a bank account in the Société générale. The " "bank did not validate the creation of the account to the BDE, so the " @@ -3073,7 +3083,7 @@ msgid "" "you go to the end of the account creation." msgstr "" -#: note_kfet/templates/base.html:184 +#: note_kfet/templates/base.html:194 msgid "Contact us" msgstr "Kontakt" diff --git a/locale/es/LC_MESSAGES/django.po b/locale/es/LC_MESSAGES/django.po index 0ad5c21bb6a9c589e8a3bc89493510c5cfefa31d..2b3b47a50f9fd3ad8f150fd4871aa80193591973 100644 --- a/locale/es/LC_MESSAGES/django.po +++ b/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-10-07 10:55+0200\n" +"POT-Creation-Date: 2020-10-07 11:42+0200\n" "PO-Revision-Date: 2020-09-19 14:56+0200\n" "Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n" "Language-Team: \n" @@ -3040,13 +3040,23 @@ msgstr "Conectarse" #: note_kfet/templates/base.html:156 msgid "" +"You are not a BDE member anymore. Please renew your membership if you want " +"to use the note." +msgstr "" + +#: note_kfet/templates/base.html:160 +msgid "You are not a Kfet member, so you can't use your note account." +msgstr "" + +#: note_kfet/templates/base.html:166 +msgid "" "Your e-mail address is not validated. Please check your mail inbox and click " "on the validation link." msgstr "" "Su correo electrónico no fue validado. Por favor mire en sus correos y haga " "clic en el enlace de validación." -#: note_kfet/templates/base.html:161 +#: note_kfet/templates/base.html:171 msgid "" "You declared that you opened a bank account in the Société générale. The " "bank did not validate the creation of the account to the BDE, so the " @@ -3055,7 +3065,7 @@ msgid "" "you go to the end of the account creation." msgstr "" -#: note_kfet/templates/base.html:184 +#: note_kfet/templates/base.html:194 msgid "Contact us" msgstr "Contactarnos" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 9ed194a788158d38d2e12e3f958d4418977bd25e..5b36834c5e1ce0d2b68429b5f3a18c307c3b4081 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-10-07 10:55+0200\n" +"POT-Creation-Date: 2020-10-07 11:42+0200\n" "PO-Revision-Date: 2020-09-13 12:36+0200\n" "Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n" "Language-Team: \n" @@ -3057,13 +3057,27 @@ msgstr "Se connecter" #: note_kfet/templates/base.html:156 msgid "" +"You are not a BDE member anymore. Please renew your membership if you want " +"to use the note." +msgstr "" +"Vous n'êtes plus adhérent BDE. Merci de réadhérer si vous voulez profiter de " +"la note." + +#: note_kfet/templates/base.html:160 +msgid "You are not a Kfet member, so you can't use your note account." +msgstr "" +"Vous n'êtes pas adhérent Kfet, vous ne pouvez par conséquent pas utiliser " +"votre compte note." + +#: note_kfet/templates/base.html:166 +msgid "" "Your e-mail address is not validated. Please check your mail inbox and click " "on the validation link." msgstr "" "Votre adresse e-mail n'est pas validée. Merci de vérifier votre boîte mail " "et de cliquer sur le lien de validation." -#: note_kfet/templates/base.html:161 +#: note_kfet/templates/base.html:171 msgid "" "You declared that you opened a bank account in the Société générale. The " "bank did not validate the creation of the account to the BDE, so the " @@ -3078,7 +3092,7 @@ msgstr "" "durer quelques jours. Merci de vous assurer de bien aller au bout de vos " "démarches." -#: note_kfet/templates/base.html:184 +#: note_kfet/templates/base.html:194 msgid "Contact us" msgstr "Nous contacter" diff --git a/note_kfet/templates/base.html b/note_kfet/templates/base.html index 1e740012d690c3efdc6f608bf203728f66147359..71e19f832569c052db2253e54b151c9818077ad1 100644 --- a/note_kfet/templates/base.html +++ b/note_kfet/templates/base.html @@ -1,4 +1,4 @@ -{% load static i18n pretty_money static getenv perms %} +{% load static i18n pretty_money static getenv perms memberinfo %} {% comment %} SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} @@ -64,8 +64,7 @@ SPDX-License-Identifier: GPL-3.0-or-later <a class="nav-link {% if request.path_info == url %}active{% endif %}" href="{{ url }}"><i class="fa fa-coffee"></i> {% trans 'Consumptions' %}</a> </li> {% endif %} - {# FIXME Find a better solution to check if a user has the right to see the transfer page #} - {% if "note.alias"|model_list_length >= 2 %} + {% if user.is_authenticated and user|is_member:"Kfet" %} <li class="nav-item"> {% url 'note:transfer' as url %} <a class="nav-link {% if request.path_info == url %}active{% endif %}" href="{{ url }}"><i class="fa fa-exchange"></i> {% trans 'Transfer' %} </a> @@ -152,10 +151,22 @@ SPDX-License-Identifier: GPL-3.0-or-later </nav> <div class="{% block containertype %}container{% endblock %} my-3"> <div id="messages"> - {% if request.user.is_authenticated and not request.user.profile.email_confirmed %} - <div class="alert alert-warning"> - {% trans "Your e-mail address is not validated. Please check your mail inbox and click on the validation link." %} - </div> + {% if user.is_authenticated %} + {% if not user|is_member:"BDE" %} + <div class="alert alert-danger"> + {% trans "You are not a BDE member anymore. Please renew your membership if you want to use the note." %} + </div> + {% elif not user|is_member:"Kfet" %} + <div class="alert alert-warning"> + {% trans "You are not a Kfet member, so you can't use your note account." %} + </div> + {% endif %} + + {% if not user.profile.email_confirmed %} + <div class="alert alert-warning"> + {% trans "Your e-mail address is not validated. Please check your mail inbox and click on the validation link." %} + </div> + {% endif %} {% endif %} {% if user.sogecredit and not user.sogecredit.valid %} <div class="alert alert-info">