Bug fix when sending email on a new note.

This commit is contained in:
Gregory Trullemans 2023-10-31 12:34:53 +01:00
parent 2386e5e3eb
commit 1b69bab40c
1 changed files with 12 additions and 8 deletions

View File

@ -498,20 +498,24 @@ def note_create_or_update(request, note_id=None, gymnast_id=None):
and ((not note_id) or (note_id and note.status == 0)) and ((not note_id) or (note_id and note.status == 0))
and new_note.status == 1 and new_note.status == 1
): ):
url = request.build_absolute_uri(
reverse("gymnast_details_tab", args=(new_note.gymnast.id, "event"))
)
send_mail( send_mail(
"Nouvelle note", "Nouvelle note",
"Une nouvelle note vous a été envoyée", "Une nouvelle note vous a été envoyée",
settings.EMAIL_HOST_USER, settings.EMAIL_HOST_USER,
[new_note.gymnast.user.email, new_note.gymnast.email_trainer], [new_note.gymnast.user.email, new_note.gymnast.email_trainer],
fail_silently=False, fail_silently=False,
html_message="""<p>Bonjour,</p> html_message=f"""<p>Bonjour,</p>
<p>Une nouvelle note vous a été envoyée. Vous pouvez la consulter en cliquant <a href='" <p>
+ request.build_absolute_uri( Une nouvelle note vous a été envoyée.
reverse( Vous pouvez la consulter en cliquant <a href='{url}'>ici</a>.
"gymnast_details_tab", args=(new_note.gymnast.id, "event") </p>
) <br /><p>Excellente journée</p>
) <p>Jarvis</p>""",
+ "'>ici</a>.</p><br /><p>Excellente journée</p><p>Jarvis</p>""",
) )
return HttpResponseRedirect( return HttpResponseRedirect(
reverse("gymnast_details_tab", args=(new_note.gymnast.id, "event")) reverse("gymnast_details_tab", args=(new_note.gymnast.id, "event"))