WIP: petitscours: UI improvements #843
8 changed files with 274 additions and 100 deletions
|
@ -122,4 +122,4 @@ td {
|
||||||
|
|
||||||
color:#FFF;
|
color:#FFF;
|
||||||
background-color:rgb(222, 130, 107);
|
background-color:rgb(222, 130, 107);
|
||||||
}
|
}
|
||||||
|
|
77
petitscours/static/petitscours/css/confirmation.css
Normal file
77
petitscours/static/petitscours/css/confirmation.css
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/** Honteusement copié-collé de bda.css **/
|
||||||
|
/** JQuery-Confirm box **/
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-bg {
|
||||||
|
background-color: rgb(0,0,0,0.6) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box {
|
||||||
|
padding:0;
|
||||||
|
border-radius:0 !important;
|
||||||
|
font-family:Roboto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .content-pane {
|
||||||
|
border-bottom:1px solid #ddd;
|
||||||
|
margin: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .content {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .content-pane {
|
||||||
|
border-bottom:1px solid #ddd;
|
||||||
|
margin: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .content {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .content a,
|
||||||
|
.jconfirm .jconfirm-box .content a:hover {
|
||||||
|
color: #D81138;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .buttons {
|
||||||
|
margin-top:-6px; /* j'arrive pas à voir pk y'a un espace au dessus sinon... */
|
||||||
|
padding:0;
|
||||||
|
height:40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .buttons button {
|
||||||
|
min-width:40px;
|
||||||
|
height:100%;
|
||||||
|
margin:0;
|
||||||
|
margin:0 !important;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .buttons button:first-child:focus,
|
||||||
|
.jconfirm .jconfirm-box .buttons button:first-child:hover {
|
||||||
|
color:#FFF !important;
|
||||||
|
background:forestgreen !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box .buttons button:nth-child(2):focus,
|
||||||
|
.jconfirm .jconfirm-box .buttons button:nth-child(2):hover {
|
||||||
|
color:#FFF !important;
|
||||||
|
background:#D93A32 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jconfirm .jconfirm-box div.title-c .title {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
padding:0 15px;
|
||||||
|
height:40px;
|
||||||
|
line-height:40px;
|
||||||
|
|
||||||
|
font-family:Dosis;
|
||||||
|
font-size:20px;
|
||||||
|
font-weight:bold;
|
||||||
|
|
||||||
|
color:#FFF;
|
||||||
|
background-color:rgb(222, 130, 107);
|
||||||
|
}
|
|
@ -21,7 +21,11 @@
|
||||||
<td>{{ demande.created|date:"d E Y" }}</td>
|
<td>{{ demande.created|date:"d E Y" }}</td>
|
||||||
<td style="text-align: center;"><img src="{% if demande.traitee %}{% static "vendor/font-awesome/images/yes.png" %}{% else %}{% static "vendor/font-awesome/images/no.png" %}{% endif %}" /></td>
|
<td style="text-align: center;"><img src="{% if demande.traitee %}{% static "vendor/font-awesome/images/yes.png" %}{% else %}{% static "vendor/font-awesome/images/no.png" %}{% endif %}" /></td>
|
||||||
<td>{% if demande.traitee_par %}{{ demande.traitee_par.username }}{% else %}<span class="glyphicon glyphicon-ban-circle"></span>{% endif %}</td>
|
<td>{% if demande.traitee_par %}{{ demande.traitee_par.username }}{% else %}<span class="glyphicon glyphicon-ban-circle"></span>{% endif %}</td>
|
||||||
<td><a href="{% url "petits-cours-demande-details" demande.id %}" class="see_detail">Détails</a></td>
|
<td>{% if demande.traitee %}
|
||||||
|
<a href="{% url "petits-cours-demande-details" demande.id %}" class="see_detail">Détails</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url "petits-cours-demande-traitement" demande.id %}" class="see_detail">Traiter</a>
|
||||||
|
{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
{% extends "petitscours/base_title.html" %}
|
{% extends "petitscours/base_title.html" %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block extra_head %}
|
||||||
|
<script type="text/javascript" src="{% static 'kfet/vendor/jquery/jquery-confirm.min.js' %}"></script>
|
||||||
|
<link type="text/css" rel="stylesheet" href="{% static 'vendor/jquery/jquery-confirm.css' %}" />
|
||||||
|
<link type="text/css" rel="stylesheet" href="{% static 'petitscours/css/confirmation.css' %}" />
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block realcontent %}
|
{% block realcontent %}
|
||||||
<h2>
|
<h2>
|
||||||
|
@ -9,50 +16,78 @@
|
||||||
</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">
|
|
||||||
{% csrf_token %}
|
<form method="post" id="traitement-form">
|
||||||
Propositions:
|
{% csrf_token %}
|
||||||
<ul>
|
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||||
{% for proposeduser, matieres in proposed_for %}
|
{% if proposals %}
|
||||||
<li>{{ proposeduser }} pour {% for matiere in matieres %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}</li>
|
Propositions:
|
||||||
{% endfor %}
|
<ul>
|
||||||
</ul>
|
{% for proposeduser, matieres in proposed_for %}
|
||||||
<h4>Mails pour les membres proposés :</h4>
|
<li>{{ proposeduser }} pour {% for matiere in matieres %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}</li>
|
||||||
{% for proposeduser, mail in proposed_mails %}
|
{% endfor %}
|
||||||
<h5>Pour {{ proposeduser }}:</h5>
|
</ul>
|
||||||
{% with object=mail.0 content=mail.1 %}
|
<h4>Mails pour les membres proposés :</h4>
|
||||||
<pre>{{ object }}</pre>
|
{% for proposeduser, mail in proposed_mails %}
|
||||||
<pre>{{ content }}</pre>
|
<h5>Pour {{ proposeduser }}:</h5>
|
||||||
{% endwith %}
|
{% with object=mail.0 content=mail.1 %}
|
||||||
{% endfor %}
|
<pre>{{ object }}</pre>
|
||||||
<h4>Mail pour l'auteur de la demande :</h4>
|
<pre>{{ content }}</pre>
|
||||||
{% with object=mainmail.0 content=mainmail.1 %}
|
{% endwith %}
|
||||||
<pre style="margin-top: 15px;">{{ object }}</pre>
|
{% endfor %}
|
||||||
<pre style="margin-top: 15px;">{{ content|safe }}</pre>
|
<h4>Mail pour l'auteur de la demande :</h4>
|
||||||
{% endwith %}
|
{% with object=mainmail.0 content=mainmail.1 %}
|
||||||
<input type="hidden" name="attribdata" value="{{ attribdata }}" />
|
<pre style="margin-top: 15px;">{{ object }}</pre>
|
||||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
<pre style="margin-top: 15px;">{{ content|safe }}</pre>
|
||||||
<input class="btn btn-primary pull-right" type="submit" value="Valider le {% if redo %}re{% endif %}traitement de la demande" />
|
{% 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" />
|
||||||
|
{% 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="button" onclick="confirmation()" value="Marquer comme traitée" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
function confirmation() {
|
||||||
|
$.confirm({
|
||||||
|
title: 'Marquer comme traitée',
|
||||||
|
columnClass: 'col-md-6 col-md-offset-3',
|
||||||
|
content: "Voulez-vous vraiment marquer la demande comme traitée ? \
|
||||||
|
Aucun traitement automatique n'aura lieu.",
|
||||||
|
backgroundDismiss: true,
|
||||||
|
opacity: 1,
|
||||||
|
animation:'top',
|
||||||
|
closeAnimation:'bottom',
|
||||||
|
keyboardEnabled: true,
|
||||||
|
confirmButton: '<span class="glyphicon glyphicon-ok"></span>',
|
||||||
|
cancelButton: '<span class="glyphicon glyphicon-remove"></span>',
|
||||||
|
confirm: function() {
|
||||||
|
charte_ok = true ;
|
||||||
|
$("#traitement-form").submit();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% 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>
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
{% extends "petitscours/base_title.html" %}
|
{% extends "petitscours/base_title.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
|
{% block extra_head %}
|
||||||
|
<script type="text/javascript" src="{% static 'kfet/vendor/jquery/jquery-confirm.min.js' %}"></script>
|
||||||
|
<link type="text/css" rel="stylesheet" href="{% static 'vendor/jquery/jquery-confirm.css' %}" />
|
||||||
|
<link type="text/css" rel="stylesheet" href="{% static 'petitscours/css/confirmation.css' %}" />
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block realcontent %}
|
{% block realcontent %}
|
||||||
<h2>
|
<h2>
|
||||||
Traitement de la demande de petits cours {{ demande.id }}
|
Traitement de la demande de petits cours {{ demande.id }}
|
||||||
|
@ -14,52 +20,77 @@
|
||||||
Attention: demande de petits cours spécifiant le niveau "Autre niveau": choisissez les candidats correspondant aux remarques de la demande. S'il y a moins de 3 candidats adaptés, ne mettre que ceux qui conviennent, pas besoin de faire du bourrage :)
|
Attention: demande de petits cours spécifiant le niveau "Autre niveau": choisissez les candidats correspondant aux remarques de la demande. S'il y a moins de 3 candidats adaptés, ne mettre que ceux qui conviennent, pas besoin de faire du bourrage :)
|
||||||
</div>
|
</div>
|
||||||
{% 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">
|
|
||||||
{% csrf_token %}
|
|
||||||
{% for matiere, users in proposals %}
|
|
||||||
<h4>{{ matiere }}</h4>
|
|
||||||
{% for i in "012"|make_list %}{% if i|add:"0" < users|length %}
|
|
||||||
<div style="float: left; width: 340px;">
|
|
||||||
Proposition {{ i|add:"1" }}:
|
|
||||||
<select id="proposal-{{ matiere.id }}-{{ i }}" name="proposal-{{ matiere.id }}-{{ i }}">
|
|
||||||
<option value="-1" data-description="">-------</option>
|
|
||||||
{% for user in users %}
|
|
||||||
<option value="{{ user.id }}" data-description="{{ user.profile.petits_cours_remarques }}">{{ user }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div style="float: right; width: 580px;"><p id="proposal-description-{{ matiere.id }}-{{ i }}"></p></div>
|
|
||||||
<div class="spacer"></div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$('#proposal-{{ matiere.id }}-{{ i }}').change(function(){
|
|
||||||
var selected = $(this).find(':selected');
|
|
||||||
var content = "";
|
|
||||||
if (selected.val() != "-1")
|
|
||||||
content = (selected.data('description')) ? selected.data('description'): "Pas de remarques";
|
|
||||||
|
|
||||||
$('#proposal-description-{{ matiere.id }}-{{ i }}').html(content);
|
<form method="post" id="traitement-form">
|
||||||
}).trigger('change');
|
{% csrf_token %}
|
||||||
</script>
|
|
||||||
<hr />
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
<input type="hidden" name="preparing" value="1" />
|
|
||||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||||
<input type="submit" value="Préparer le {% if redo %}re{% endif %}traitement de la demande" />
|
{% if proposals %}
|
||||||
</form>
|
{% for matiere, users in proposals %}
|
||||||
|
<h4>{{ matiere }}</h4>
|
||||||
|
{% for i in "012"|make_list %}{% if i|add:"0" < users|length %}
|
||||||
|
<div style="float: left; width: 340px;">
|
||||||
|
Proposition {{ i|add:"1" }}:
|
||||||
|
<select id="proposal-{{ matiere.id }}-{{ i }}" name="proposal-{{ matiere.id }}-{{ i }}">
|
||||||
|
<option value="-1" data-description="">-------</option>
|
||||||
|
{% for user in users %}
|
||||||
|
<option value="{{ user.id }}" data-description="{{ user.profile.petits_cours_remarques }}">{{ user }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div style="float: right; width: 580px;"><p id="proposal-description-{{ matiere.id }}-{{ i }}"></p></div>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('#proposal-{{ matiere.id }}-{{ i }}').change(function(){
|
||||||
|
var selected = $(this).find(':selected');
|
||||||
|
var content = "";
|
||||||
|
if (selected.val() != "-1")
|
||||||
|
content = (selected.data('description')) ? selected.data('description'): "Pas de remarques";
|
||||||
|
|
||||||
|
$('#proposal-description-{{ matiere.id }}-{{ i }}').html(content);
|
||||||
|
}).trigger('change');
|
||||||
|
</script>
|
||||||
|
<hr />
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
<input type="hidden" name="preparing" value="1" />
|
||||||
|
<input type="submit" value="Préparer le {% if redo %}re{% endif %}traitement de la demande" />
|
||||||
{% else %}
|
{% else %}
|
||||||
<h3>Impossible de trouver des propositions pour cette demande</h3>
|
<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>
|
<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="button" onclick="confirmation()" value="Marquer comme traitée" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
function confirmation() {
|
||||||
|
$.confirm({
|
||||||
|
title: 'Marquer comme traitée',
|
||||||
|
columnClass: 'col-md-6 col-md-offset-3',
|
||||||
|
content: "Voulez-vous vraiment marquer la demande comme traitée ? \
|
||||||
|
Aucun traitement automatique n'aura lieu.",
|
||||||
|
backgroundDismiss: true,
|
||||||
|
opacity: 1,
|
||||||
|
animation:'top',
|
||||||
|
closeAnimation:'bottom',
|
||||||
|
keyboardEnabled: true,
|
||||||
|
confirmButton: '<span class="glyphicon glyphicon-ok"></span>',
|
||||||
|
cancelButton: '<span class="glyphicon glyphicon-remove"></span>',
|
||||||
|
confirm: function() {
|
||||||
|
charte_ok = true ;
|
||||||
|
$("#traitement-form").submit();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
{% extends "petitscours/base_title.html" %}
|
|
||||||
|
|
||||||
{% block realcontent %}
|
|
||||||
<h2>Traitement de la demande de petits cours {{ demande.id }}</h2>
|
|
||||||
<div class="success" style="margin: 15px 0px; font-size: 1.4em;">Demande {{ demande.id }} de {{ demande.name }} {% if redo %}re{% endif %}traitée avec succès !</div>
|
|
||||||
<a href="{% url "petits-cours-demandes-list" %}">Retour à la liste des demandes</a>
|
|
||||||
{% endblock %}
|
|
|
@ -8,6 +8,7 @@ from django.core import mail
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.views.generic import DetailView, ListView
|
from django.views.generic import DetailView, ListView
|
||||||
|
@ -16,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,
|
||||||
|
@ -168,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:
|
||||||
|
@ -180,16 +188,38 @@ def _traitement_other(request, demande, redo):
|
||||||
"demande": demande,
|
"demande": demande,
|
||||||
"unsatisfied": unsatisfied,
|
"unsatisfied": unsatisfied,
|
||||||
"proposals": proposals.items(),
|
"proposals": proposals.items(),
|
||||||
|
"levels": LEVELS_CHOICES,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
messages.success(
|
||||||
|
request,
|
||||||
|
f"Demande de {demande.name} {'re' if redo else ''}traitée avec succès !",
|
||||||
|
)
|
||||||
|
if redo:
|
||||||
|
return redirect(demande.get_absolute_url())
|
||||||
|
else:
|
||||||
|
return redirect(reverse("petits-cours-demandes-list"))
|
||||||
|
|
||||||
|
|
||||||
|
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 +283,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