From 2571cc955e42aa3874c2b864ea6e0a232760ad83 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 22 May 2023 18:23:50 +0200 Subject: [PATCH 1/5] =?UTF-8?q?feat(kfet):=20D=C3=A9sactive=20l'envoi=20de?= =?UTF-8?q?s=20mails=20pour=20les=20comptes=20gel=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On utilise la fonctionnalité `is_frozen` pour marquer les comptes qui n'ont plus d'adresse valide, et on répare le formulaire de màj de compte. --- kfet/management/commands/sendrappelsnegatifs.py | 3 ++- kfet/views.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kfet/management/commands/sendrappelsnegatifs.py b/kfet/management/commands/sendrappelsnegatifs.py index 4e2f67c3..29776284 100644 --- a/kfet/management/commands/sendrappelsnegatifs.py +++ b/kfet/management/commands/sendrappelsnegatifs.py @@ -26,8 +26,9 @@ class Command(BaseCommand): # On n'envoie des mails qu'aux comptes qui ont un négatif vraiment actif # et dont la balance est négative + # On ignore les comptes gelés qui signinfient une adresse mail plus valide account_negatives = AccountNegative.objects.filter( - account__balance__lt=0 + account__balance__lt=0, account__is_frozen=False ).exclude(end__lte=now) accounts_first_mail = account_negatives.filter( diff --git a/kfet/views.py b/kfet/views.py index 4ef2692e..a189d94a 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -361,7 +361,7 @@ def account_update(request, trigramme): user_info_form = UserInfoForm(instance=account.user) account_form = AccountForm(instance=account) group_form = UserGroupForm(instance=account.user) - frozen_form = AccountFrozenForm(request.POST, instance=account) + frozen_form = AccountFrozenForm(instance=account) pwd_form = AccountPwdForm() if request.method == "POST": From c36dd30bce298839c8ca007f5ce199dbf4bab0df Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 22 May 2023 18:26:24 +0200 Subject: [PATCH 2/5] fix(kfet): Affiche la bonne information --- kfet/management/commands/sendrappelsnegatifs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfet/management/commands/sendrappelsnegatifs.py b/kfet/management/commands/sendrappelsnegatifs.py index 29776284..a1a8b7bc 100644 --- a/kfet/management/commands/sendrappelsnegatifs.py +++ b/kfet/management/commands/sendrappelsnegatifs.py @@ -44,7 +44,7 @@ class Command(BaseCommand): for neg in accounts_periodic_mail: neg.send_rappel() - self.stdout.write("Mail de rappel pour {neg.account} envoyé avec succès.") + self.stdout.write(f"Mail de rappel pour {neg.account} envoyé avec succès.") if not (accounts_first_mail.exists() or accounts_periodic_mail.exists()): self.stdout.write("Aucun mail à envoyer.") From e50249355d45e4a6f014065b0a5523b874d0e0a9 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Fri, 19 May 2023 20:15:50 +0200 Subject: [PATCH 3/5] feat(kfet): Ajoute un formulaire de contact --- kfet/forms.py | 13 ++++++++++ kfet/templates/kfet/base_footer.html | 10 +++----- kfet/templates/kfet/contact.html | 36 ++++++++++++++++++++++++++++ kfet/urls.py | 1 + kfet/views.py | 24 +++++++++++++++++++ 5 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 kfet/templates/kfet/contact.html diff --git a/kfet/forms.py b/kfet/forms.py index db8404ef..ccc2ecbf 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -45,6 +45,19 @@ class DateTimeWidget(forms.DateTimeInput): js = ("kfet/vendor/bootstrap/bootstrap-datetimepicker.min.js",) +class ContactForm(forms.Form): + from_email = forms.EmailField( + label="Adresse mail", + help_text="Si aucune adresse mail n'est renseignée, la soumission sera anonyme.", + required=False, + ) + subject = forms.CharField(label="Objet", required=True) + message = forms.CharField(widget=forms.Textarea, required=True) + + def clean_from_email(self): + return self.cleaned_data["from_email"] or "Anonyme " + + # ----- # Account forms # ----- diff --git a/kfet/templates/kfet/base_footer.html b/kfet/templates/kfet/base_footer.html index c5333476..7a016705 100644 --- a/kfet/templates/kfet/base_footer.html +++ b/kfet/templates/kfet/base_footer.html @@ -1,17 +1,13 @@ {% load wagtailcore_tags %} -{% with "k-fet@ens.fr" as kfet_mail %} - diff --git a/kfet/templates/kfet/contact.html b/kfet/templates/kfet/contact.html new file mode 100644 index 00000000..2e0c63b6 --- /dev/null +++ b/kfet/templates/kfet/contact.html @@ -0,0 +1,36 @@ +{% extends "kfet/base_form.html" %} + +{% block extra_head %} +{{ negative_form.media }} +{% endblock %} + +{% block title %} + Contacter la K-Fêt +{% endblock %} + +{% block header-title %} + Contacter la K-Fêt +{% endblock %} + +{% block footer %} +{% include "kfet/base_footer.html" %} +{% endblock %} + +{% block main %} + +
+
+ Votre message sera envoyé aux Chef·fe·s et aux Wo·men K-Fêt. +
+
+ +
+ +
+ {% csrf_token %} + {% include 'kfet/form_snippet.html' %} + + {% include 'kfet/form_submit_snippet.html' with value="Envoyer" %} +
+ +{% endblock %} diff --git a/kfet/urls.py b/kfet/urls.py index 7a9498ed..57a68f32 100644 --- a/kfet/urls.py +++ b/kfet/urls.py @@ -9,6 +9,7 @@ register_converter(converters.TrigrammeConverter, "trigramme") urlpatterns = [ path("login/generic", views.login_generic, name="kfet.login.generic"), path("history", views.history, name="kfet.history"), + path("contact", views.ContactView.as_view(), name="kfet.contact"), # ----- # Account urls # ----- diff --git a/kfet/views.py b/kfet/views.py index 4ef2692e..0be6fcce 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -13,6 +13,7 @@ from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.models import Permission, User from django.contrib.messages.views import SuccessMessageMixin from django.core.exceptions import SuspiciousOperation +from django.core.mail import EmailMessage from django.db import transaction from django.db.models import ( Count, @@ -63,6 +64,7 @@ from kfet.forms import ( CheckoutStatementCreateForm, CheckoutStatementUpdateForm, CofForm, + ContactForm, FilterHistoryForm, InventoryArticleForm, KFetConfigForm, @@ -113,6 +115,28 @@ def put_cleaned_data_in_dict(dict, form): dict[field] = form.cleaned_data[field] +class ContactView(FormView): + template_name = "kfet/contact.html" + form_class = ContactForm + success_url = reverse_lazy("kfet.contact") + + def form_valid(self, form): + # Envoie un mail lorsque le formulaire est valide + EmailMessage( + form.cleaned_data["subject"], + form.cleaned_data["message"], + from_email=form.cleaned_data["from_email"], + to=("chefs-k-fet@ens.psl.eu",), + ).send() + + messages.success( + self.request, + "Votre message a bien été envoyé aux Wo·men K-Fêt.", + ) + + return super().form_valid(form) + + # ----- # Account views # ----- From 7164cfa37a049b550481f4bd2d2f03cbef86a49e Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 22 May 2023 20:12:47 +0200 Subject: [PATCH 4/5] =?UTF-8?q?feat(kfet):=20Ajout=20d'un=20formulaire=20d?= =?UTF-8?q?e=20demande=20de=20soir=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kfet/forms.py | 28 ++++++++++++++++ kfet/templates/kfet/demande_soiree.html | 28 ++++++++++++++++ kfet/templates/kfet/mails/demande_soiree.txt | 16 +++++++++ kfet/urls.py | 3 ++ kfet/views.py | 35 ++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 kfet/templates/kfet/demande_soiree.html create mode 100644 kfet/templates/kfet/mails/demande_soiree.txt diff --git a/kfet/forms.py b/kfet/forms.py index ccc2ecbf..29442cf8 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -58,6 +58,34 @@ class ContactForm(forms.Form): return self.cleaned_data["from_email"] or "Anonyme " +class DemandeSoireeForm(forms.Form): + HORAIRE_CHOICES = map(lambda s: (s, s), ("22h", "23h", "00h", "01h", "02h", "03h")) + SERVICE_CHOICES = ( + ("K-Fêt", "K-Fêt standard (L'équipe K-Fêt fait le service normal au bar)"), + ("Kalô", "Type Kalô (Vous ramenez vos propres boissons et servez vous-mêmes)"), + ) + + nom = forms.CharField() + from_email = forms.EmailField(label="Adresse mail de contact") + + contact_boum = forms.BooleanField(label="Contacter le Boum", required=False) + contact_pls = forms.BooleanField(label="Contacter PLS", required=False) + + theme = forms.CharField(label="Thème de la soirée") + horaire_fin = forms.ChoiceField(label="Horaire de fin", choices=HORAIRE_CHOICES) + service = forms.ChoiceField(label="Mode de service", choices=SERVICE_CHOICES) + date = forms.CharField(label="Date souhaitée") + + respo1 = forms.CharField(label="Nom de la personne respo n°1") + respo2 = forms.CharField(label="Nom de la personne respo n°2") + respo3 = forms.CharField(label="Nom de la personne respo n°3") + respo4 = forms.CharField(label="Nom de la personne respo n°4") + + remarques = forms.CharField( + label="Remarques supplémentaires", widget=forms.Textarea + ) + + # ----- # Account forms # ----- diff --git a/kfet/templates/kfet/demande_soiree.html b/kfet/templates/kfet/demande_soiree.html new file mode 100644 index 00000000..0ac0dd69 --- /dev/null +++ b/kfet/templates/kfet/demande_soiree.html @@ -0,0 +1,28 @@ +{% extends "kfet/base_form.html" %} + +{% block extra_head %} +{{ negative_form.media }} +{% endblock %} + +{% block title %} + Effectuer une demande de soirée +{% endblock %} + +{% block header-title %} + Effectuer une demande de soirée +{% endblock %} + +{% block footer %} +{% include "kfet/base_footer.html" %} +{% endblock %} + +{% block main %} + +
+ {% csrf_token %} + {% include 'kfet/form_snippet.html' %} + + {% include 'kfet/form_submit_snippet.html' with value="Envoyer" %} +
+ +{% endblock %} diff --git a/kfet/templates/kfet/mails/demande_soiree.txt b/kfet/templates/kfet/mails/demande_soiree.txt new file mode 100644 index 00000000..9fd6d635 --- /dev/null +++ b/kfet/templates/kfet/mails/demande_soiree.txt @@ -0,0 +1,16 @@ +Bonjour, + +J'aimerais organiser une soirée le {{ date }}, au thème « {{ theme|safe }} », en K-Fêt. +Elle se terminerait à {{ horaire_fin }}, et le service serait en mode {{ service }}. + +Les 4 responsables de la soirée seraient : +- {{ respo1 }} +- {{ respo2 }} +- {{ respo3 }} +- {{ respo4 }} + +Quelques remarques supplémentaires : +{{ remarques|safe }} + +Bien cordialement, +{{ nom|safe }} diff --git a/kfet/urls.py b/kfet/urls.py index 57a68f32..f33cea03 100644 --- a/kfet/urls.py +++ b/kfet/urls.py @@ -10,6 +10,9 @@ urlpatterns = [ path("login/generic", views.login_generic, name="kfet.login.generic"), path("history", views.history, name="kfet.history"), path("contact", views.ContactView.as_view(), name="kfet.contact"), + path( + "demande-soiree", views.DemandeSoireeView.as_view(), name="kfet.demande-soiree" + ), # ----- # Account urls # ----- diff --git a/kfet/views.py b/kfet/views.py index ad320a7f..94e9e5fe 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -35,6 +35,7 @@ from django.http import ( JsonResponse, ) from django.shortcuts import get_object_or_404, redirect, render +from django.template import loader from django.urls import reverse, reverse_lazy from django.utils import timezone from django.utils.decorators import method_decorator @@ -65,6 +66,7 @@ from kfet.forms import ( CheckoutStatementUpdateForm, CofForm, ContactForm, + DemandeSoireeForm, FilterHistoryForm, InventoryArticleForm, KFetConfigForm, @@ -137,6 +139,39 @@ class ContactView(FormView): return super().form_valid(form) +class DemandeSoireeView(FormView): + template_name = "kfet/demande_soiree.html" + form_class = DemandeSoireeForm + success_url = reverse_lazy("kfet.demande-soiree") + + def form_valid(self, form): + destinataires = ["chefs-k-fet@ens.psl.eu"] + + if form.cleaned_data["contact_boum"]: + destinataires.append("boum@ens.psl.eu") + + if form.cleaned_data["contact_pls"]: + destinataires.append("pls@ens.psl.eu") + + # Envoie un mail lorsque le formulaire est valide + EmailMessage( + f"Demande de soirée le {form.cleaned_data['date']}", + loader.render_to_string( + "kfet/mails/demande_soiree.txt", context=form.cleaned_data + ), + from_email=form.cleaned_data["from_email"], + to=destinataires, + cc=[form.cleaned_data["from_email"]], + ).send() + + messages.success( + self.request, + "Votre demande de soirée a bien été envoyée.", + ) + + return super().form_valid(form) + + # ----- # Account views # ----- From b32a07fc227cd1751eb45eea4d5989b43b74dfb4 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Mon, 22 May 2023 20:42:23 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Version=200.15=20et=20mise=20=C3=A0=20jour?= =?UTF-8?q?=20du=20Changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 121b9c03..5a1a65f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,14 @@ adhérents ni des cotisations. ## Version ??? - ??/??/???? +## Version 0.15 - 22/05/2023 + +### K-Fêt + +- Rajoute un formulaire de contact +- Rajoute un formulaire de demande de soirée +- Désactive les mails d'envoi de négatifs sur les comptes gelés + ## Version 0.14 - 19/05/2023 - Répare les dépendances en spécifiant toutes les versions