Update note form
This commit is contained in:
parent
a5cc4c7b7f
commit
b8ab1b3242
|
@ -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={
|
||||
|
|
|
@ -19,17 +19,25 @@
|
|||
<label for="id_date" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Gymnast
|
||||
<span class="text-danger"><b>*</b></span></label>
|
||||
<div
|
||||
class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4 {% if form.jumper.errors %}has-danger{% endif %}">
|
||||
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 %} <span class="btn btn-sm btn-danger-outline">{% for error in form.gymnast.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row {% if form.title.errors %}has-error has-feedback{% endif %}">
|
||||
<label for="id_title" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Title <span
|
||||
class="text-danger"><b>*</b></label>
|
||||
<div class="col-8 col-md-9 col-lg-6 col-lg-4 col-xl-4">
|
||||
{{ form.title }}
|
||||
{% if form.title.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.title.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_date" class="col-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 col-form-label">Date <span
|
||||
class="text-danger"><b>*</b></span></label>
|
||||
<div
|
||||
class="col-8 col-sm-6 col-md-4 col-lg-4 col-xl-4 {% if form.date.errors %}has-danger{% 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 %}<span class="btn btn-sm btn-danger-outline">{% for error in form.date.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -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="""<p>Bonjour,</p>
|
||||
<p>Une nouvelle note vous a été envoyée. Vous pouvez la consulter en liquant <a href='"
|
||||
+ request.build_absolute_uri(
|
||||
reverse(
|
||||
"gymnast_details_tab", args=(new_note.gymnast.id, "event")
|
||||
)
|
||||
)
|
||||
+ "'>ici</a>.</p><br /><p>Excellente journée</p><p>Jarvis</p>""",
|
||||
)
|
||||
# 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="""<p>Bonjour,</p>
|
||||
# <p>Une nouvelle note vous a été envoyée. Vous pouvez la consulter en liquant <a href='"
|
||||
# + request.build_absolute_uri(
|
||||
# reverse(
|
||||
# "gymnast_details_tab", args=(new_note.gymnast.id, "event")
|
||||
# )
|
||||
# )
|
||||
# + "'>ici</a>.</p><br /><p>Excellente journée</p><p>Jarvis</p>""",
|
||||
# )
|
||||
return HttpResponseRedirect(
|
||||
reverse("gymnast_details_tab", args=(new_note.gymnast.id, "event"))
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue