From b8ab1b3242b64efcf2e223b86f97de968384776c Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Mon, 12 Jun 2023 13:17:14 +0200 Subject: [PATCH] Update note form --- jarvis/followup/forms.py | 8 ++++- jarvis/followup/templates/notes/create.html | 12 +++++-- jarvis/followup/views.py | 40 ++++++++++----------- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/jarvis/followup/forms.py b/jarvis/followup/forms.py index 6294bad..5fc2f34 100644 --- a/jarvis/followup/forms.py +++ b/jarvis/followup/forms.py @@ -504,10 +504,16 @@ class PlanForm(forms.ModelForm): class NoteForm(forms.ModelForm): class Meta: model = Note - fields = ("gymnast", "coach", "status", "informations", "date") + fields = ("gymnast", "coach", "title", "status", "informations", "date") widgets = { "gymnast": forms.HiddenInput(), "coach": forms.HiddenInput(), + "title": forms.TextInput( + attrs={ + "class": "form-control", + "placeholder": "Note of the week", + } + ), "status": forms.Select(attrs={"class": "form-control selectpicker"}), "date": forms.TextInput( attrs={ diff --git a/jarvis/followup/templates/notes/create.html b/jarvis/followup/templates/notes/create.html index 2255949..a2ee865 100644 --- a/jarvis/followup/templates/notes/create.html +++ b/jarvis/followup/templates/notes/create.html @@ -19,17 +19,25 @@
+ class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% if form.jumper.errors %}has-danger{% endif %}"> {{ form.gymnast }} {{ form.gymnast_related }} {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{ error }}{% endfor %}{% endif %}
+
+ +
+ {{ form.title }} + {% if form.title.errors %} {% for error in form.title.errors %}{{ error }}{% endfor %}{% endif %} +
+
+ class="col-8 col-sm-6 col-md-4 col-lg-4 col-xl-3 {% if form.date.errors %}has-danger{% endif %}"> {{ form.date }} {% if form.date.errors %}{% for error in form.date.errors %}{{ error }}{% endfor %}{% endif %}
diff --git a/jarvis/followup/views.py b/jarvis/followup/views.py index 226fdc1..7008812 100644 --- a/jarvis/followup/views.py +++ b/jarvis/followup/views.py @@ -493,26 +493,26 @@ def note_create_or_update(request, note_id=None, gymnast_id=None): if form.is_valid(): new_note = form.save() - if ( - (new_note.gymnast.user.email or new_note.gymnast.email_trainer) - and ((not note_id) or (note_id and note.status == 0)) - and new_note.status == 1 - ): - send_mail( - "Nouvelle note", - "Une nouvelle note vous a été envoyée", - settings.EMAIL_HOST_USER, - [new_note.gymnast.user.email, new_note.gymnast.email_trainer], - fail_silently=False, - html_message="""

Bonjour,

-

Une nouvelle note vous a été envoyée. Vous pouvez la consulter en liquant ici.


Excellente journée

Jarvis

""", - ) + # if ( + # (new_note.gymnast.user.email or new_note.gymnast.email_trainer) + # and ((not note_id) or (note_id and note.status == 0)) + # and new_note.status == 1 + # ): + # send_mail( + # "Nouvelle note", + # "Une nouvelle note vous a été envoyée", + # settings.EMAIL_HOST_USER, + # [new_note.gymnast.user.email, new_note.gymnast.email_trainer], + # fail_silently=False, + # html_message="""

Bonjour,

+ #

Une nouvelle note vous a été envoyée. Vous pouvez la consulter en liquant ici.


Excellente journée

Jarvis

""", + # ) return HttpResponseRedirect( reverse("gymnast_details_tab", args=(new_note.gymnast.id, "event")) )