update mail notification

This commit is contained in:
Gregory Trullemans 2023-11-18 18:29:18 +01:00
parent e873ebeaa0
commit ef55eaf65c
1 changed files with 33 additions and 10 deletions

View File

@ -14,6 +14,14 @@ from jarvis.people.models import Gymnast
from jarvis.planning.models import Event
from jarvis.objective.models import Skill
from .models import (
CHRONO_TYPE_CHOICE,
SCORE_TYPE_CHOICE,
INJURY_MECHANISM_CHOICE,
INJURY_BODY_SIDE_CHOICE,
INJURY_TYPE_CHOICE,
INJURY_LOCATION_CHOICE,
)
from .models import (
Plan,
Note,
@ -592,7 +600,7 @@ def chrono_create_or_update(request, chrono_id=None, gymnast_id=None):
receiver,
fail_silently=False,
html_message=f"""<p>Bonjour,</p>
<p>Nouveau chrono pour {gymnast} : {chrono_type} - {score} ({score_type}).</p><br />
<p>Nouveau chrono pour {gymnast} : {CHRONO_TYPE_CHOICE[chrono_type]} - {score} ({SCORE_TYPE_CHOICE[score_type]}).</p><br />
<p>Excellente journée</p><p>Jarvis</p>""",
)
@ -862,6 +870,11 @@ def injury_create_or_update(request, injury_id=None, gymnast_id=None):
# notification
receiver = []
gymnast = Gymnast.objects.get(pk=form.cleaned_data["gymnast"].id)
location = form.cleaned_data["location"]
injury_type = form.cleaned_data["injury_type"]
body_side = form.cleaned_data["body_side"]
mechanism = form.cleaned_data["mechanism"]
date = form.cleaned_data["date"]
functionality = ContentType.objects.get(model="injury")
for notification in gymnast.notifications.filter(
functionality=functionality
@ -875,8 +888,16 @@ def injury_create_or_update(request, injury_id=None, gymnast_id=None):
receiver,
fail_silently=False,
html_message=f"""<p>Bonjour,</p>
<p>Un nouvelle blessure enregistrée pour {gymnast}.</p><br />
<p>Excellente journée</p><p>Jarvis</p>""",
<p>Un nouvelle blessure enregistrée pour {gymnast} pour le {date.strftime('%d %B %Y')}:</p>
<ul>
<li>{INJURY_LOCATION_CHOICE[mechanism]},</li>
<li>{INJURY_BODY_SIDE_CHOICE[injury_type]},</li>
<li>{INJURY_MECHANISM_CHOICE[location]},</li>
<li>{INJURY_TYPE_CHOICE[body_side]},</li>
</ul>
<br />
<p>Excellente journée</p>
<p>Jarvis</p>""",
)
return HttpResponseRedirect(reverse("injury_details", args=(injury.pk,)))
@ -982,7 +1003,7 @@ def wellbeing_create_or_update(
<li>Sleep: {sleep}</li>
<li>Stress: {stress}</li>
<li>Fatigue: {fatigue}</li>
<li>Muscle_soreness: {muscle_soreness}</li>
<li>Muscle soreness: {muscle_soreness}</li>
</ul>
<br />
<p>Excellente journée</p><p>Jarvis</p>""",
@ -1407,6 +1428,7 @@ def intensity_create_or_update(request, intensity_id=None, gymnast_id=None):
difficulty = form.cleaned_data["difficulty"]
quantity_of_skill = form.cleaned_data["quantity_of_skill"]
number_of_passes = form.cleaned_data["number_of_passes"]
skill_by_time = quantity_of_skill / time
skill_by_passe = quantity_of_skill / number_of_passes
diff_by_skill = difficulty / quantity_of_skill
diff_by_passe = difficulty / number_of_passes
@ -1430,14 +1452,15 @@ def intensity_create_or_update(request, intensity_id=None, gymnast_id=None):
<li>{number_of_passes} passages</li>
<li>{time} minutes</li>
<li>{quantity_of_skill} figures</li>
<li>{difficulty} diff.</li>
<li>{difficulty / 10} diff.</li>
</ul>
<p><u>Statistiques :</u></p>
<p><u>Statistics :</u></p>
<ul>
<li>Average passe time : {time_by_passe}</li>
<li>Skill by passe : {skill_by_passe}</li>
<li>Diff by passe : {diff_by_passe}</li>
<li>Diff by skill : {diff_by_skill}</li>
<li>Time/passe: {time_by_passe:.2f}</li>
<li>Skill/time: {skill_by_time:.2f}</li>
<li>Skill/passe: {skill_by_passe:.2f}</li>
<li>Diff/passe: {diff_by_passe:.2f}</li>
<li>Diff/skill: {diff_by_skill:.2f}</li>
</ul>
<br />
<p>Excellente journée</p>