Update height/weight email and Wellbeing JS
This commit is contained in:
parent
ed9579bf45
commit
3a94fe636f
|
@ -99,11 +99,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="id_information" class="col-4 col-sm-2 col-md-4 col-lg-4 col-xl-3 col-form-label">Informations</label>
|
<label class="col-12 text-center text-danger" id="note_info"><b>Merci de mettre une information complémentaire.</b></label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row ">
|
||||||
|
<label for="id_information" class="col-4 col-sm-2 col-md-4 col-lg-4 col-xl-3 col-form-label">Informations <span class="text-danger" id="span_info_required"><b>*</b></span></label>
|
||||||
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-9 {% if form.id_information.errors %}has-danger{% endif %}">
|
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-9 {% if form.id_information.errors %}has-danger{% endif %}">
|
||||||
{{ form.informations }}
|
{{ form.informations }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-center">
|
<div class="form-group text-center">
|
||||||
<input type="submit" value="{% if mindstate_id %}Save{% else %}Add{% endif %}" class="btn btn-warning" />
|
<input type="submit" value="{% if mindstate_id %}Save{% else %}Add{% endif %}" class="btn btn-warning" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -116,15 +120,64 @@
|
||||||
|
|
||||||
{% block footerscript %}
|
{% block footerscript %}
|
||||||
<script type="text/javascript" >
|
<script type="text/javascript" >
|
||||||
$(function(){
|
$().ready(function(){
|
||||||
blackDashboard.initDateTimePicker();
|
// blackDashboard.init.DateTimePicker();
|
||||||
|
|
||||||
|
$('#id_mindstate').on('change', function(){
|
||||||
|
if($(this).val() <= 5) {
|
||||||
|
$("#note_info").show();
|
||||||
|
$("#span_info_required").show();
|
||||||
|
} else {
|
||||||
|
$("#note_info").hide();
|
||||||
|
$("#span_info_required").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#id_sleep').on('change', function(){
|
||||||
|
if($(this).val() <= 5) {
|
||||||
|
$("#note_info").show();
|
||||||
|
$("#span_info_required").show();
|
||||||
|
} else {
|
||||||
|
$("#note_info").hide();
|
||||||
|
$("#span_info_required").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#id_stress').on('change', function(){
|
||||||
|
if($(this).val() >= 5) {
|
||||||
|
$("#note_info").show();
|
||||||
|
$("#span_info_required").show();
|
||||||
|
} else {
|
||||||
|
$("#note_info").hide();
|
||||||
|
$("#span_info_required").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#id_fatigue').on('change', function(){
|
||||||
|
if($(this).val() >= 5) {
|
||||||
|
$("#note_info").show();
|
||||||
|
$("#span_info_required").show();
|
||||||
|
} else {
|
||||||
|
$("#note_info").hide();
|
||||||
|
$("#span_info_required").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#id_muscle_soreness').on('change', function(){
|
||||||
|
if($(this).val() >= 5) {
|
||||||
|
$("#note_info").show();
|
||||||
|
$("#span_info_required").show();
|
||||||
|
} else {
|
||||||
|
$("#note_info").hide();
|
||||||
|
$("#span_info_required").hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const csrf_token = "{{ csrf_token|escapejs }}";
|
const csrf_token = "{{ csrf_token|escapejs }}";
|
||||||
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
|
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
|
||||||
const event_lookup = "{% url 'event_lookup' %}";
|
const event_lookup = "{% url 'event_lookup' %}";
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<script src="{% static "js/template_users/datepicker_maxdate_today.js" %}"></script>
|
|
||||||
{% if request.session.template == 0 %}
|
{% if request.session.template == 0 %}
|
||||||
<script src="{% static "js/template_users/gymnast_autocomplete_black.js" %}"></script>
|
<script src="{% static "js/template_users/gymnast_autocomplete_black.js" %}"></script>
|
||||||
<script src="{% static "js/template_users/event_autocomplete_black.js" %}"></script>
|
<script src="{% static "js/template_users/event_autocomplete_black.js" %}"></script>
|
||||||
|
|
|
@ -1059,9 +1059,10 @@ def heightweight_create_or_update(request, heightweight_id=None, gymnast_id=None
|
||||||
|
|
||||||
# notification
|
# notification
|
||||||
receiver = []
|
receiver = []
|
||||||
height = form.cleaned_data["height"]
|
height = form.cleaned_data["height"] / 100
|
||||||
weight = form.cleaned_data["weight"]
|
weight = form.cleaned_data["weight"]
|
||||||
bmi = weight / (height * height)
|
bmi = weight / (height * height)
|
||||||
|
bmi = format(bmi, ".1f")
|
||||||
gymnast = Gymnast.objects.get(pk=form.cleaned_data["gymnast"].id)
|
gymnast = Gymnast.objects.get(pk=form.cleaned_data["gymnast"].id)
|
||||||
functionality = ContentType.objects.get(model="heightweight")
|
functionality = ContentType.objects.get(model="heightweight")
|
||||||
for notification in gymnast.notifications.filter(
|
for notification in gymnast.notifications.filter(
|
||||||
|
@ -1071,12 +1072,12 @@ def heightweight_create_or_update(request, heightweight_id=None, gymnast_id=None
|
||||||
|
|
||||||
send_mail(
|
send_mail(
|
||||||
f"{gymnast} : Nouveau poids/taille enregistré",
|
f"{gymnast} : Nouveau poids/taille enregistré",
|
||||||
f"Un nouveau poids/taille enregistré pour {gymnast} : {height} / {weight} ({bmi}).",
|
f"Un nouveau poids/taille enregistré pour {gymnast} : {height}cm / {weight}kg ({bmi}).",
|
||||||
settings.EMAIL_HOST_USER,
|
settings.EMAIL_HOST_USER,
|
||||||
receiver,
|
receiver,
|
||||||
fail_silently=False,
|
fail_silently=False,
|
||||||
html_message=f"""<p>Bonjour,</p>
|
html_message=f"""<p>Bonjour,</p>
|
||||||
<p>Un nouveau poids/taille enregistré pour {gymnast} : {height} / {weight} ({bmi}).</p><br />
|
<p>Un nouveau poids/taille enregistré pour {gymnast} : {height}cm / {weight}kg ({bmi}).</p><br />
|
||||||
<p>Excellente journée</p><p>Jarvis</p>""",
|
<p>Excellente journée</p><p>Jarvis</p>""",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue