petitscours: dropdown pour facilement modifier le niveau d'une demande 'autre'

This commit is contained in:
LeSeulArtichaut 2024-12-12 02:09:14 +01:00
parent b59b745644
commit 49066a71d9
2 changed files with 22 additions and 1 deletions

View file

@ -8,7 +8,20 @@
<tr><td><strong>Quand</strong></td><td> {{ demande.quand }}</td></tr>
<tr><td><strong>Fréquence</strong></td><td> {{ demande.freq }}</td></tr>
<tr><td><strong>Matières</strong></td><td> {% for matiere in demande.matieres.all %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}</td></tr>
<tr><td><strong>Niveau souhaité</strong></td><td> {{ demande.get_niveau_display }}</td></tr>
<tr><td><strong>Niveau souhaité</strong></td><td>
{% if levels %}
<form method="post">
{% csrf_token %}
<select name="niveau" onchange="this.form.submit()">
{% for level_id, level_name in levels %}
<option value="{{ level_id }}" {% if level_id == 'other' %}selected{% endif %}>{{ level_name }}</option>
{% endfor %}
</select>
</form>
{% else %}
{{ demande.get_niveau_display }}
{% endif %}
</td></tr>
<tr><td><strong>Agrégé requis</strong></td><td> <img src="{% if demande.agrege_requis %}{% static "vendor/font-awesome/images/yes.png" %}{% else %}{% static "vendor/font-awesome/images/no.png" %}{% endif %}" /></td></tr>
<tr><td><strong>Remarques</strong></td><td> {{ demande.remarques }}</td></tr>
</table>

View file

@ -17,6 +17,7 @@ from gestioncof.decorators import buro_required
from gestioncof.models import CofProfile
from petitscours.forms import DemandeForm, MatieresFormSet
from petitscours.models import (
LEVELS_CHOICES,
PetitCoursAbility,
PetitCoursAttribution,
PetitCoursAttributionCounter,
@ -169,6 +170,12 @@ def _traitement_other_preparing(request, demande):
def _traitement_other(request, demande, redo):
if request.method == "POST":
if "niveau" in request.POST:
demande.niveau = request.POST["niveau"]
demande.save()
return redirect(
reverse("petits-cours-demande-traitement", args=(demande.id,))
)
if "preparing" in request.POST:
return _traitement_other_preparing(request, demande)
else:
@ -181,6 +188,7 @@ def _traitement_other(request, demande, redo):
"demande": demande,
"unsatisfied": unsatisfied,
"proposals": proposals.items(),
"levels": LEVELS_CHOICES,
},
)