WIP: petitscours: UI improvements #843
2 changed files with 63 additions and 48 deletions
|
@ -9,12 +9,14 @@
|
|||
</h2>
|
||||
{% include "petitscours/details_demande_infos.html" %}
|
||||
<hr />
|
||||
|
||||
{% if errors %}
|
||||
<div class="error">
|
||||
Attention:
|
||||
<ul>{% for error in errors %}<li>{{ error }}</li>{% endfor %}</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if unsatisfied %}
|
||||
<div class="error">
|
||||
Attention: Impossible de trouver des propositions pour les matières suivantes:
|
||||
|
@ -23,9 +25,12 @@
|
|||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if proposals %}
|
||||
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||
{% if proposals %}
|
||||
Propositions:
|
||||
<ul>
|
||||
{% for proposeduser, matieres in proposed_for %}
|
||||
|
@ -46,13 +51,16 @@
|
|||
<pre style="margin-top: 15px;">{{ content|safe }}</pre>
|
||||
{% endwith %}
|
||||
<input type="hidden" name="attribdata" value="{{ attribdata }}" />
|
||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||
<input class="btn btn-primary pull-right" type="submit" value="Valider le {% if redo %}re{% endif %}traitement de la demande" />
|
||||
</form>
|
||||
{% else %}
|
||||
<h3>Impossible de trouver des propositions pour cette demande</h3>
|
||||
<div class="error" style="font-size: 1.6em; margin-top: 10px;">Traitement manuel obligatoire !</div>
|
||||
<input type="hidden" name="manual" value="1" />
|
||||
<input class="btn btn-primary pull-right" type="submit" value="Marquer comme traitée" />
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
<p>
|
||||
<a href="{% url 'petits-cours-demandes-list' %}">Retour à la liste des demandes</a>
|
||||
</p>
|
||||
|
|
|
@ -185,11 +185,27 @@ def _traitement_other(request, demande, redo):
|
|||
|
||||
|
||||
def _traitement_post(request, demande):
|
||||
redo = "redo" in request.POST
|
||||
manual = "manual" in request.POST
|
||||
|
||||
if not manual:
|
||||
_traitement_attributions(request, demande)
|
||||
|
||||
demande.traitee = True
|
||||
demande.traitee_par = request.user
|
||||
demande.processed = timezone.now()
|
||||
demande.save()
|
||||
return render(
|
||||
request,
|
||||
"petitscours/traitement_demande_success.html",
|
||||
{"demande": demande, "redo": redo},
|
||||
)
|
||||
|
||||
def _traitement_attributions(request, demande):
|
||||
proposals = {}
|
||||
proposed_for = {}
|
||||
unsatisfied = []
|
||||
extra = request.POST["extra"].strip()
|
||||
redo = "redo" in request.POST
|
||||
attribdata = request.POST["attribdata"]
|
||||
attribdata = dict(json.loads(attribdata))
|
||||
for matiere in demande.matieres.all():
|
||||
|
@ -253,15 +269,6 @@ def _traitement_post(request, demande):
|
|||
user=user, matiere=matiere, demande=demande, rank=rank + 1
|
||||
)
|
||||
attrib.save()
|
||||
demande.traitee = True
|
||||
demande.traitee_par = request.user
|
||||
demande.processed = timezone.now()
|
||||
demande.save()
|
||||
return render(
|
||||
request,
|
||||
"petitscours/traitement_demande_success.html",
|
||||
{"demande": demande, "redo": redo},
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue