forked from DGNum/gestioCOF
Merge branch 'thubrecht/contact-soiree' into 'master'
feat(kfet): Ajout d'un formulaire de demande de soirée See merge request klub-dev-ens/gestioCOF!523
This commit is contained in:
commit
4fc9902cf6
5 changed files with 110 additions and 0 deletions
|
@ -58,6 +58,34 @@ class ContactForm(forms.Form):
|
|||
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
|
||||
# -----
|
||||
|
|
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 }}
|
|
@ -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
|
||||
# -----
|
||||
|
|
|
@ -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
|
||||
# -----
|
||||
|
|
Loading…
Reference in a new issue