WIP: petitscours: UI improvements #843

Draft
llanteri wants to merge 6 commits from petitscours into master
2 changed files with 22 additions and 1 deletions
Showing only changes of commit 49066a71d9 - Show all commits

View file

@ -8,7 +8,20 @@
<tr><td><strong>Quand</strong></td><td> {{ demande.quand }}</td></tr> <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>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>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>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> <tr><td><strong>Remarques</strong></td><td> {{ demande.remarques }}</td></tr>
</table> </table>

View file

@ -17,6 +17,7 @@ from gestioncof.decorators import buro_required
from gestioncof.models import CofProfile from gestioncof.models import CofProfile
from petitscours.forms import DemandeForm, MatieresFormSet from petitscours.forms import DemandeForm, MatieresFormSet
from petitscours.models import ( from petitscours.models import (
LEVELS_CHOICES,
PetitCoursAbility, PetitCoursAbility,
PetitCoursAttribution, PetitCoursAttribution,
PetitCoursAttributionCounter, PetitCoursAttributionCounter,
@ -169,6 +170,12 @@ def _traitement_other_preparing(request, demande):
def _traitement_other(request, demande, redo): def _traitement_other(request, demande, redo):
if request.method == "POST": 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: if "preparing" in request.POST:
return _traitement_other_preparing(request, demande) return _traitement_other_preparing(request, demande)
else: else:
@ -181,6 +188,7 @@ def _traitement_other(request, demande, redo):
"demande": demande, "demande": demande,
"unsatisfied": unsatisfied, "unsatisfied": unsatisfied,
"proposals": proposals.items(), "proposals": proposals.items(),
"levels": LEVELS_CHOICES,
}, },
) )