WIP: petitscours: UI improvements #843
2 changed files with 63 additions and 48 deletions
|
@ -9,50 +9,58 @@
|
|||
</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>
|
||||
<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:
|
||||
<ul>
|
||||
{% for matiere in unsatisfied %}<li>{{ matiere }}</li>{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="error">
|
||||
Attention: Impossible de trouver des propositions pour les matières suivantes:
|
||||
<ul>
|
||||
{% for matiere in unsatisfied %}<li>{{ matiere }}</li>{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if proposals %}
|
||||
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
Propositions:
|
||||
<ul>
|
||||
{% for proposeduser, matieres in proposed_for %}
|
||||
<li>{{ proposeduser }} pour {% for matiere in matieres %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h4>Mails pour les membres proposés :</h4>
|
||||
{% for proposeduser, mail in proposed_mails %}
|
||||
<h5>Pour {{ proposeduser }}:</h5>
|
||||
{% with object=mail.0 content=mail.1 %}
|
||||
<pre>{{ object }}</pre>
|
||||
<pre>{{ content }}</pre>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
<h4>Mail pour l'auteur de la demande :</h4>
|
||||
{% with object=mainmail.0 content=mainmail.1 %}
|
||||
<pre style="margin-top: 15px;">{{ object }}</pre>
|
||||
<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" />
|
||||
{% csrf_token %}
|
||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||
{% if proposals %}
|
||||
Propositions:
|
||||
<ul>
|
||||
{% for proposeduser, matieres in proposed_for %}
|
||||
<li>{{ proposeduser }} pour {% for matiere in matieres %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h4>Mails pour les membres proposés :</h4>
|
||||
{% for proposeduser, mail in proposed_mails %}
|
||||
<h5>Pour {{ proposeduser }}:</h5>
|
||||
{% with object=mail.0 content=mail.1 %}
|
||||
<pre>{{ object }}</pre>
|
||||
<pre>{{ content }}</pre>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
<h4>Mail pour l'auteur de la demande :</h4>
|
||||
{% with object=mainmail.0 content=mainmail.1 %}
|
||||
<pre style="margin-top: 15px;">{{ object }}</pre>
|
||||
<pre style="margin-top: 15px;">{{ content|safe }}</pre>
|
||||
{% endwith %}
|
||||
<input type="hidden" name="attribdata" value="{{ attribdata }}" />
|
||||
<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>
|
||||
{% 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>
|
||||
{% endif %}
|
||||
|
||||
<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