petitscours: ajout d'un bouton 'marquer comme traitée' pour les demandes sans propositions
This commit is contained in:
parent
2126224e15
commit
e357f57d61
2 changed files with 63 additions and 48 deletions
|
@ -9,50 +9,58 @@
|
||||||
</h2>
|
</h2>
|
||||||
{% include "petitscours/details_demande_infos.html" %}
|
{% include "petitscours/details_demande_infos.html" %}
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
{% if errors %}
|
{% if errors %}
|
||||||
<div class="error">
|
<div class="error">
|
||||||
Attention:
|
Attention:
|
||||||
<ul>{% for error in errors %}<li>{{ error }}</li>{% endfor %}</ul>
|
<ul>{% for error in errors %}<li>{{ error }}</li>{% endfor %}</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if unsatisfied %}
|
{% if unsatisfied %}
|
||||||
<div class="error">
|
<div class="error">
|
||||||
Attention: Impossible de trouver des propositions pour les matières suivantes:
|
Attention: Impossible de trouver des propositions pour les matières suivantes:
|
||||||
<ul>
|
<ul>
|
||||||
{% for matiere in unsatisfied %}<li>{{ matiere }}</li>{% endfor %}
|
{% for matiere in unsatisfied %}<li>{{ matiere }}</li>{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if proposals %}
|
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
Propositions:
|
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||||
<ul>
|
{% if proposals %}
|
||||||
{% for proposeduser, matieres in proposed_for %}
|
Propositions:
|
||||||
<li>{{ proposeduser }} pour {% for matiere in matieres %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}</li>
|
<ul>
|
||||||
{% endfor %}
|
{% for proposeduser, matieres in proposed_for %}
|
||||||
</ul>
|
<li>{{ proposeduser }} pour {% for matiere in matieres %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}</li>
|
||||||
<h4>Mails pour les membres proposés :</h4>
|
{% endfor %}
|
||||||
{% for proposeduser, mail in proposed_mails %}
|
</ul>
|
||||||
<h5>Pour {{ proposeduser }}:</h5>
|
<h4>Mails pour les membres proposés :</h4>
|
||||||
{% with object=mail.0 content=mail.1 %}
|
{% for proposeduser, mail in proposed_mails %}
|
||||||
<pre>{{ object }}</pre>
|
<h5>Pour {{ proposeduser }}:</h5>
|
||||||
<pre>{{ content }}</pre>
|
{% with object=mail.0 content=mail.1 %}
|
||||||
{% endwith %}
|
<pre>{{ object }}</pre>
|
||||||
{% endfor %}
|
<pre>{{ content }}</pre>
|
||||||
<h4>Mail pour l'auteur de la demande :</h4>
|
{% endwith %}
|
||||||
{% with object=mainmail.0 content=mainmail.1 %}
|
{% endfor %}
|
||||||
<pre style="margin-top: 15px;">{{ object }}</pre>
|
<h4>Mail pour l'auteur de la demande :</h4>
|
||||||
<pre style="margin-top: 15px;">{{ content|safe }}</pre>
|
{% with object=mainmail.0 content=mainmail.1 %}
|
||||||
{% endwith %}
|
<pre style="margin-top: 15px;">{{ object }}</pre>
|
||||||
<input type="hidden" name="attribdata" value="{{ attribdata }}" />
|
<pre style="margin-top: 15px;">{{ content|safe }}</pre>
|
||||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
{% endwith %}
|
||||||
<input class="btn btn-primary pull-right" type="submit" value="Valider le {% if redo %}re{% endif %}traitement de la demande" />
|
<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>
|
</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>
|
<p>
|
||||||
<a href="{% url 'petits-cours-demandes-list' %}">Retour à la liste des demandes</a>
|
<a href="{% url 'petits-cours-demandes-list' %}">Retour à la liste des demandes</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -185,11 +185,27 @@ def _traitement_other(request, demande, redo):
|
||||||
|
|
||||||
|
|
||||||
def _traitement_post(request, demande):
|
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 = {}
|
proposals = {}
|
||||||
proposed_for = {}
|
proposed_for = {}
|
||||||
unsatisfied = []
|
unsatisfied = []
|
||||||
extra = request.POST["extra"].strip()
|
extra = request.POST["extra"].strip()
|
||||||
redo = "redo" in request.POST
|
|
||||||
attribdata = request.POST["attribdata"]
|
attribdata = request.POST["attribdata"]
|
||||||
attribdata = dict(json.loads(attribdata))
|
attribdata = dict(json.loads(attribdata))
|
||||||
for matiere in demande.matieres.all():
|
for matiere in demande.matieres.all():
|
||||||
|
@ -253,15 +269,6 @@ def _traitement_post(request, demande):
|
||||||
user=user, matiere=matiere, demande=demande, rank=rank + 1
|
user=user, matiere=matiere, demande=demande, rank=rank + 1
|
||||||
)
|
)
|
||||||
attrib.save()
|
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
|
@login_required
|
||||||
|
|
Loading…
Reference in a new issue