forked from DGNum/gestioCOF
Merge branch 'master' into 'Production'
Version 0.15 See merge request klub-dev-ens/gestioCOF!524
This commit is contained in:
commit
a4494c3648
9 changed files with 199 additions and 10 deletions
|
@ -27,6 +27,14 @@ adhérents ni des cotisations.
|
||||||
|
|
||||||
## Version ??? - ??/??/????
|
## 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
|
## Version 0.14 - 19/05/2023
|
||||||
|
|
||||||
- Répare les dépendances en spécifiant toutes les versions
|
- Répare les dépendances en spécifiant toutes les versions
|
||||||
|
|
|
@ -45,6 +45,47 @@ class DateTimeWidget(forms.DateTimeInput):
|
||||||
js = ("kfet/vendor/bootstrap/bootstrap-datetimepicker.min.js",)
|
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 <k-fet@ens.psl.eu>"
|
||||||
|
|
||||||
|
|
||||||
|
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
|
# Account forms
|
||||||
# -----
|
# -----
|
||||||
|
|
|
@ -26,8 +26,9 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# On n'envoie des mails qu'aux comptes qui ont un négatif vraiment actif
|
# On n'envoie des mails qu'aux comptes qui ont un négatif vraiment actif
|
||||||
# et dont la balance est négative
|
# 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_negatives = AccountNegative.objects.filter(
|
||||||
account__balance__lt=0
|
account__balance__lt=0, account__is_frozen=False
|
||||||
).exclude(end__lte=now)
|
).exclude(end__lte=now)
|
||||||
|
|
||||||
accounts_first_mail = account_negatives.filter(
|
accounts_first_mail = account_negatives.filter(
|
||||||
|
@ -43,7 +44,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
for neg in accounts_periodic_mail:
|
for neg in accounts_periodic_mail:
|
||||||
neg.send_rappel()
|
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()):
|
if not (accounts_first_mail.exists() or accounts_periodic_mail.exists()):
|
||||||
self.stdout.write("Aucun mail à envoyer.")
|
self.stdout.write("Aucun mail à envoyer.")
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
{% load wagtailcore_tags %}
|
{% load wagtailcore_tags %}
|
||||||
|
|
||||||
{% with "k-fet@ens.fr" as kfet_mail %}
|
|
||||||
|
|
||||||
<footer class="row">
|
<footer class="row">
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<span>
|
<span>
|
||||||
<a href="{% slugurl "mentions-legales" %}">Mentions légales</a>
|
<b><a href="{% url "kfet.contact" %}">Formulaire de contact</a></b>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
|
||||||
<span>
|
<span>
|
||||||
En cas de pépin : <a href="mailto:{{ kfet_mail }}"><tt>{{ kfet_mail }}</tt></a>
|
<a href="{% slugurl "mentions-legales" %}">Mentions légales</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</footer>
|
||||||
|
|
||||||
{% endwith %}
|
|
||||||
|
|
36
kfet/templates/kfet/contact.html
Normal file
36
kfet/templates/kfet/contact.html
Normal file
|
@ -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 %}
|
||||||
|
|
||||||
|
<div class="messages">
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<b>Votre message sera envoyé aux Chef·fe·s et aux Wo·men K-Fêt.</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<form action="" method="post" class="form-horizontal" autocomplete="off">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% include 'kfet/form_snippet.html' %}
|
||||||
|
|
||||||
|
{% include 'kfet/form_submit_snippet.html' with value="Envoyer" %}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
28
kfet/templates/kfet/demande_soiree.html
Normal file
28
kfet/templates/kfet/demande_soiree.html
Normal file
|
@ -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 %}
|
||||||
|
|
||||||
|
<form action="" method="post" class="form-horizontal" autocomplete="off">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% include 'kfet/form_snippet.html' %}
|
||||||
|
|
||||||
|
{% include 'kfet/form_submit_snippet.html' with value="Envoyer" %}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
16
kfet/templates/kfet/mails/demande_soiree.txt
Normal file
16
kfet/templates/kfet/mails/demande_soiree.txt
Normal file
|
@ -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 }}
|
|
@ -9,6 +9,10 @@ register_converter(converters.TrigrammeConverter, "trigramme")
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("login/generic", views.login_generic, name="kfet.login.generic"),
|
path("login/generic", views.login_generic, name="kfet.login.generic"),
|
||||||
path("history", views.history, name="kfet.history"),
|
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
|
# Account urls
|
||||||
# -----
|
# -----
|
||||||
|
|
|
@ -13,6 +13,7 @@ from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||||
from django.contrib.auth.models import Permission, User
|
from django.contrib.auth.models import Permission, User
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.core.exceptions import SuspiciousOperation
|
from django.core.exceptions import SuspiciousOperation
|
||||||
|
from django.core.mail import EmailMessage
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import (
|
from django.db.models import (
|
||||||
Count,
|
Count,
|
||||||
|
@ -34,6 +35,7 @@ from django.http import (
|
||||||
JsonResponse,
|
JsonResponse,
|
||||||
)
|
)
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
|
from django.template import loader
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
|
@ -63,6 +65,8 @@ from kfet.forms import (
|
||||||
CheckoutStatementCreateForm,
|
CheckoutStatementCreateForm,
|
||||||
CheckoutStatementUpdateForm,
|
CheckoutStatementUpdateForm,
|
||||||
CofForm,
|
CofForm,
|
||||||
|
ContactForm,
|
||||||
|
DemandeSoireeForm,
|
||||||
FilterHistoryForm,
|
FilterHistoryForm,
|
||||||
InventoryArticleForm,
|
InventoryArticleForm,
|
||||||
KFetConfigForm,
|
KFetConfigForm,
|
||||||
|
@ -113,6 +117,61 @@ def put_cleaned_data_in_dict(dict, form):
|
||||||
dict[field] = form.cleaned_data[field]
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
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
|
# Account views
|
||||||
# -----
|
# -----
|
||||||
|
@ -361,7 +420,7 @@ def account_update(request, trigramme):
|
||||||
user_info_form = UserInfoForm(instance=account.user)
|
user_info_form = UserInfoForm(instance=account.user)
|
||||||
account_form = AccountForm(instance=account)
|
account_form = AccountForm(instance=account)
|
||||||
group_form = UserGroupForm(instance=account.user)
|
group_form = UserGroupForm(instance=account.user)
|
||||||
frozen_form = AccountFrozenForm(request.POST, instance=account)
|
frozen_form = AccountFrozenForm(instance=account)
|
||||||
pwd_form = AccountPwdForm()
|
pwd_form = AccountPwdForm()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
|
Loading…
Reference in a new issue