Display banners when a user is no more a BDE or Kfet member

This commit is contained in:
Yohann D'ANELLO 2020-10-07 11:46:43 +02:00
parent 4a78328717
commit e5e758f9d9
6 changed files with 83 additions and 16 deletions

View File

View File

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

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2020-09-13 12:39+0200\n"
"Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n" "Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n"
"Language-Team: \n" "Language-Team: \n"
@ -3058,13 +3058,23 @@ msgstr "Anmelden"
#: note_kfet/templates/base.html:156 #: note_kfet/templates/base.html:156
msgid "" 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 " "Your e-mail address is not validated. Please check your mail inbox and click "
"on the validation link." "on the validation link."
msgstr "" msgstr ""
"Ihre E-Mail-Adresse ist nicht validiert. Bitte überprüfen Sie Ihren " "Ihre E-Mail-Adresse ist nicht validiert. Bitte überprüfen Sie Ihren "
"Posteingang und klicken Sie auf den Validierungslink." "Posteingang und klicken Sie auf den Validierungslink."
#: note_kfet/templates/base.html:161 #: note_kfet/templates/base.html:171
msgid "" msgid ""
"You declared that you opened a bank account in the Société générale. The " "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 " "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." "you go to the end of the account creation."
msgstr "" msgstr ""
#: note_kfet/templates/base.html:184 #: note_kfet/templates/base.html:194
msgid "Contact us" msgid "Contact us"
msgstr "Kontakt" msgstr "Kontakt"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2020-09-19 14:56+0200\n"
"Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n" "Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n"
"Language-Team: \n" "Language-Team: \n"
@ -3040,13 +3040,23 @@ msgstr "Conectarse"
#: note_kfet/templates/base.html:156 #: note_kfet/templates/base.html:156
msgid "" 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 " "Your e-mail address is not validated. Please check your mail inbox and click "
"on the validation link." "on the validation link."
msgstr "" msgstr ""
"Su correo electrónico no fue validado. Por favor mire en sus correos y haga " "Su correo electrónico no fue validado. Por favor mire en sus correos y haga "
"clic en el enlace de validación." "clic en el enlace de validación."
#: note_kfet/templates/base.html:161 #: note_kfet/templates/base.html:171
msgid "" msgid ""
"You declared that you opened a bank account in the Société générale. The " "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 " "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." "you go to the end of the account creation."
msgstr "" msgstr ""
#: note_kfet/templates/base.html:184 #: note_kfet/templates/base.html:194
msgid "Contact us" msgid "Contact us"
msgstr "Contactarnos" msgstr "Contactarnos"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: 2020-09-13 12:36+0200\n"
"Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n" "Last-Translator: elkmaennchen <elkmaennchen@crans.org>\n"
"Language-Team: \n" "Language-Team: \n"
@ -3057,13 +3057,27 @@ msgstr "Se connecter"
#: note_kfet/templates/base.html:156 #: note_kfet/templates/base.html:156
msgid "" 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 " "Your e-mail address is not validated. Please check your mail inbox and click "
"on the validation link." "on the validation link."
msgstr "" msgstr ""
"Votre adresse e-mail n'est pas validée. Merci de vérifier votre boîte mail " "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." "et de cliquer sur le lien de validation."
#: note_kfet/templates/base.html:161 #: note_kfet/templates/base.html:171
msgid "" msgid ""
"You declared that you opened a bank account in the Société générale. The " "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 " "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 " "durer quelques jours. Merci de vous assurer de bien aller au bout de vos "
"démarches." "démarches."
#: note_kfet/templates/base.html:184 #: note_kfet/templates/base.html:194
msgid "Contact us" msgid "Contact us"
msgstr "Nous contacter" msgstr "Nous contacter"

View File

@ -1,4 +1,4 @@
{% load static i18n pretty_money static getenv perms %} {% load static i18n pretty_money static getenv perms memberinfo %}
{% comment %} {% comment %}
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %} {% 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> <a class="nav-link {% if request.path_info == url %}active{% endif %}" href="{{ url }}"><i class="fa fa-coffee"></i> {% trans 'Consumptions' %}</a>
</li> </li>
{% endif %} {% endif %}
{# FIXME Find a better solution to check if a user has the right to see the transfer page #} {% if user.is_authenticated and user|is_member:"Kfet" %}
{% if "note.alias"|model_list_length >= 2 %}
<li class="nav-item"> <li class="nav-item">
{% url 'note:transfer' as url %} {% 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> <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> </nav>
<div class="{% block containertype %}container{% endblock %} my-3"> <div class="{% block containertype %}container{% endblock %} my-3">
<div id="messages"> <div id="messages">
{% if request.user.is_authenticated and not request.user.profile.email_confirmed %} {% if user.is_authenticated %}
<div class="alert alert-warning"> {% if not user|is_member:"BDE" %}
{% trans "Your e-mail address is not validated. Please check your mail inbox and click on the validation link." %} <div class="alert alert-danger">
</div> {% 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 %} {% endif %}
{% if user.sogecredit and not user.sogecredit.valid %} {% if user.sogecredit and not user.sogecredit.valid %}
<div class="alert alert-info"> <div class="alert alert-info">