Bug fix and improvement
This commit is contained in:
parent
766747dc03
commit
8c63cd801f
|
@ -7,10 +7,10 @@
|
|||
<div class="col-12 col-sm-12 col-md-8 col-lg-8 col-xl-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4 class="">{% if strength_id %}Edit{% else %}Add{% endif %} Strength</h4>
|
||||
<h4 class="">{% if mobility_flexibility_id %}Edit{% else %}Add{% endif %} Mobility/Flexibility</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{% if strength_id %}{% url 'strength_update' strength_id %}{% else %}{% url 'strength_create' %}{% endif %}" method="post" class="form-horizontal" id="formulaire" name="formulaire">
|
||||
<form action="{% if mobility_flexibility_id %}{% url 'mobility_flexibility_update' mobility_flexibility_id %}{% else %}{% url 'mobility_flexibility_create' %}{% endif %}" method="post" class="form-horizontal" id="formulaire" name="formulaire">
|
||||
{% csrf_token %}
|
||||
<div class="form-group row ">
|
||||
<label for="id_date" class="col-5 col-sm-5 col-form-label">Gymnast <span class="text-danger"><b>*</b></span></label>
|
||||
|
|
|
@ -39,6 +39,22 @@
|
|||
{% if form.anterior_chain.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.anterior_chain.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row ">
|
||||
<label for="id_lateral_chain_left" class="col-4 col-sm-3 col-form-label">{{ form.lateral_chain_left.label }}<span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-5 col-sm-3 col-md-2 col-lg-2 col-xl-2 {% if form.lateral_chain_left.errors %}has-danger{% endif %}">
|
||||
{{ form.lateral_chain_left }}
|
||||
{% if form.lateral_chain_left.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.lateral_chain_left.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_lateral_chain_right" class="col-4 col-sm-3 col-form-label">{{ form.lateral_chain_right.label }}<span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-5 col-sm-3 col-md-2 col-lg-2 col-xl-2 {% if form.lateral_chain_right.errors %}has-danger{% endif %}">
|
||||
{{ form.lateral_chain_right }}
|
||||
{% if form.lateral_chain_right.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.lateral_chain_right.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row ">
|
||||
<label for="id_posterior_chain_left" class="col-4 col-sm-3 col-form-label">{{ form.posterior_chain_left.label }} <span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-5 col-sm-3 col-md-2 col-lg-2 col-xl-2 {% if form.posterior_chain_left.errors %}has-danger{% endif %}">
|
||||
|
@ -53,6 +69,7 @@
|
|||
{% if form.posterior_chain_right.errors %} <span class="btn btn-sm btn-danger-outline">{% for error in form.posterior_chain_right.errors %}{{ error }}{% endfor %}</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row ">
|
||||
<label for="id_leg_lowering" class="col-4 col-sm-3 col-form-label">{{ form.leg_lowering.label }}<span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-5 col-sm-3 col-md-4 col-lg-4 col-xl-4 {% if form.leg_lowering.errors %}has-danger{% endif %}">
|
||||
|
|
|
@ -15,6 +15,14 @@
|
|||
<td>Anterior chain</td>
|
||||
<td>{{ stability.anterior_chain }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lateral chain left</td>
|
||||
<td>{{ stability.lateral_chain_left }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lateral chain right</td>
|
||||
<td>{{ stability.lateral_chain_right }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Posterior chain left</td>
|
||||
<td>{{ stability.posterior_chain_left }}</td>
|
||||
|
|
|
@ -261,6 +261,8 @@ class StabilityForm(forms.ModelForm):
|
|||
"anterior_chain",
|
||||
"posterior_chain_left",
|
||||
"posterior_chain_right",
|
||||
"lateral_chain_left",
|
||||
"lateral_chain_right",
|
||||
"leg_lowering",
|
||||
"sl_bridge",
|
||||
"side_plank_leg_raise",
|
||||
|
@ -298,6 +300,22 @@ class StabilityForm(forms.ModelForm):
|
|||
"max": "3",
|
||||
}
|
||||
),
|
||||
"lateral_chain_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "3",
|
||||
}
|
||||
),
|
||||
"lateral_chain_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "3",
|
||||
}
|
||||
),
|
||||
"leg_lowering": forms.Select(attrs={"class": "selectpicker"}),
|
||||
"sl_bridge": forms.SelectMultiple(attrs={"class": "selectpicker"}),
|
||||
"side_plank_leg_raise": forms.SelectMultiple(attrs={"class": "selectpicker"}),
|
||||
|
@ -389,6 +407,7 @@ class StrengthForm(forms.ModelForm):
|
|||
"heel_raise_test_right",
|
||||
)
|
||||
widgets = {
|
||||
"gymnast": forms.HiddenInput(),
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
"class": "form-control datepicker",
|
||||
|
@ -396,7 +415,6 @@ class StrengthForm(forms.ModelForm):
|
|||
"value": date.today().strftime("%Y-%m-%d"),
|
||||
}
|
||||
),
|
||||
"gymnast": forms.HiddenInput(),
|
||||
"harmstring_left_prone": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
|
@ -917,3 +935,231 @@ class SeasonInformationForm(forms.ModelForm):
|
|||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class MobilityFlexibilityForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = MobilityFlexibility
|
||||
fields = (
|
||||
"gymnast",
|
||||
"date",
|
||||
"hip_internal_rotation_right",
|
||||
"hip_internal_rotation_left",
|
||||
"harmstring_aket_right",
|
||||
"harmstring_aket_left",
|
||||
"elys_test_right",
|
||||
"elys_test_left",
|
||||
"bent_knee_fall_out_test_right",
|
||||
"bent_knee_fall_out_test_left",
|
||||
"knee_to_wall_test_right",
|
||||
"knee_to_wall_test_left",
|
||||
"shoulder_anteversion_supine_right",
|
||||
"shoulder_anteversion_supine_left",
|
||||
"shoulder_external_rotation_right",
|
||||
"shoulder_external_rotation_left",
|
||||
"shoulder_internal_rotation_right",
|
||||
"shoulder_internal_rotation_left",
|
||||
"functional_external_rotation_right",
|
||||
"functional_external_rotation_left",
|
||||
"mod_thomas_test_right",
|
||||
"mod_thomas_test_left",
|
||||
"lombo_pelvic_control",
|
||||
"cervical_control",
|
||||
)
|
||||
widgets = {
|
||||
"gymnast": forms.HiddenInput(),
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
"class": "form-control datepicker",
|
||||
"placeholder": date.today().strftime("%Y-%m-%d"),
|
||||
"value": date.today().strftime("%Y-%m-%d"),
|
||||
}
|
||||
),
|
||||
"hip_internal_rotation_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"hip_internal_rotation_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"harmstring_aket_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"harmstring_aket_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"elys_test_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"elys_test_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"bent_knee_fall_out_test_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"bent_knee_fall_out_test_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"knee_to_wall_test_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"knee_to_wall_test_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"shoulder_anteversion_supine_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"shoulder_anteversion_supine_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"shoulder_external_rotation_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"shoulder_external_rotation_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"shoulder_internal_rotation_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"shoulder_internal_rotation_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"functional_external_rotation_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"functional_external_rotation_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"mod_thomas_test_right": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"mod_thomas_test_left": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"lombo_pelvic_control": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
"cervical_control": forms.NumberInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "x",
|
||||
"min": "0",
|
||||
"max": "10000",
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
gymnast_related = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"class": "form-control",
|
||||
"placeholder": "Searching gymnast…",
|
||||
"data-ref": "#id_gymnast",
|
||||
}
|
||||
),
|
||||
)
|
|
@ -634,6 +634,12 @@ class Stability(Seasonisable):
|
|||
posterior_chain_right = models.PositiveSmallIntegerField(
|
||||
verbose_name="Posterior Chain Right"
|
||||
)
|
||||
lateral_chain_left = models.PositiveSmallIntegerField(
|
||||
verbose_name="Lateral Chain Left"
|
||||
)
|
||||
lateral_chain_right = models.PositiveSmallIntegerField(
|
||||
verbose_name="Lateral Chain Right"
|
||||
)
|
||||
leg_lowering = models.PositiveSmallIntegerField(
|
||||
choices=LUMBAR_STABILITY_CHOICE,
|
||||
verbose_name="Leg Lowering: lumbar stability",
|
||||
|
@ -691,7 +697,7 @@ class QualityOfMovement(Seasonisable):
|
|||
verbose_name="Single leg stability right"
|
||||
)
|
||||
single_leg_stability_left = models.PositiveSmallIntegerField(
|
||||
verbose_name="Single leg stability right"
|
||||
verbose_name="Single leg stability left"
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -38,7 +38,7 @@ from .forms import (
|
|||
WellBeingForm,
|
||||
HeightWeightForm,
|
||||
LearnedSkillForm,
|
||||
MobilityFlexibility,
|
||||
MobilityFlexibilityForm,
|
||||
QualityOfMovementForm,
|
||||
SeasonInformationForm,
|
||||
NumberOfRoutineDoneForm,
|
||||
|
@ -921,9 +921,7 @@ def strength_detail(request, strength_id):
|
|||
@login_required
|
||||
@require_http_methods(["GET", "POST"])
|
||||
def strength_create_or_update(request, strength_id=None, gymnast_id=None):
|
||||
"""
|
||||
Récupère toutes les informations d'une stability.
|
||||
"""
|
||||
"""Crée ou met à jours un test de force."""
|
||||
if strength_id:
|
||||
strength = get_object_or_404(Strength, pk=strength_id)
|
||||
data = {
|
||||
|
@ -984,34 +982,33 @@ def mobility_flexibility_detail(request, mobility_flexibility_id):
|
|||
|
||||
@login_required
|
||||
@require_http_methods(["GET", "POST"])
|
||||
def mobility_flexibility_create_or_update(request, strength_id=None, gymnast_id=None):
|
||||
pass
|
||||
# """
|
||||
# Récupère toutes les informations d'une stability.
|
||||
# """
|
||||
# if strength_id:
|
||||
# strength = get_object_or_404(Strength, pk=strength_id)
|
||||
# data = {
|
||||
# "gymnast_related": strength.gymnast,
|
||||
# }
|
||||
# else:
|
||||
# strength = None
|
||||
# data = None
|
||||
# if gymnast_id is not None:
|
||||
# gymnast = get_object_or_404(Gymnast, pk=gymnast_id)
|
||||
# data = {"gymnast": gymnast_id, "gymnast_related": str(gymnast)}
|
||||
def mobility_flexibility_create_or_update(request, mobility_flexibility_id=None, gymnast_id=None):
|
||||
"""Crée ou met à jours un test de mobilite/flexibilite."""
|
||||
if mobility_flexibility_id:
|
||||
mobility_flexibility = get_object_or_404(MobilityFlexibility, pk=strength_id)
|
||||
data = {
|
||||
"gymnast_related": mobility_flexibility.gymnast,
|
||||
}
|
||||
else:
|
||||
mobility_flexibility = None
|
||||
data = None
|
||||
if gymnast_id is not None:
|
||||
gymnast = get_object_or_404(Gymnast, pk=gymnast_id)
|
||||
data = {"gymnast": gymnast_id, "gymnast_related": str(gymnast)}
|
||||
|
||||
# if request.method == "POST":
|
||||
# form = StrengthForm(request.POST, instance=strength)
|
||||
if request.method == "POST":
|
||||
form = MobilityFlexibilityForm(request.POST, instance=mobility_flexibility)
|
||||
|
||||
# if form.is_valid():
|
||||
# strength = form.save()
|
||||
# return HttpResponseRedirect(
|
||||
# reverse("strength_details", args=(strength.pk,))
|
||||
# )
|
||||
# else:
|
||||
# return render(request, "followup/strength/create.html", {"form": form})
|
||||
if form.is_valid():
|
||||
mobility_flexibility = form.save()
|
||||
return HttpResponseRedirect(
|
||||
reverse("strength_details", args=(mobility_flexibility.pk,))
|
||||
)
|
||||
else:
|
||||
for error in form.errors:
|
||||
print(error)
|
||||
return render(request, "followup/mobility_flexibility/create.html", {"form": form})
|
||||
|
||||
# form = StrengthForm(instance=strength, initial=data)
|
||||
# context = {"form": form, "strength_id": strength_id}
|
||||
# return render(request, "followup/strength/create.html", context)
|
||||
form = StrengthForm(instance=mobility_flexibility, initial=data)
|
||||
context = {"form": form, "mobility_flexibility_id": mobility_flexibility_id}
|
||||
return render(request, "followup/mobility_flexibility/create.html", context)
|
||||
|
|
Loading…
Reference in New Issue