WIP: petitscours: UI improvements #843
8 changed files with 274 additions and 100 deletions
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 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><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>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -8,7 +8,20 @@
|
|||
<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>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>Remarques</strong></td><td> {{ demande.remarques }}</td></tr>
|
||||
</table>
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
{% 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 %}
|
||||
<h2>
|
||||
|
@ -9,12 +16,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 +32,12 @@
|
|||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if proposals %}
|
||||
<form method="post">
|
||||
|
||||
|
||||
<form method="post" id="traitement-form">
|
||||
{% csrf_token %}
|
||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||
{% if proposals %}
|
||||
Propositions:
|
||||
<ul>
|
||||
{% for proposeduser, matieres in proposed_for %}
|
||||
|
@ -46,13 +58,36 @@
|
|||
<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="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>
|
||||
|
||||
<p>
|
||||
<a href="{% url 'petits-cours-demandes-list' %}">Retour à la liste des demandes</a>
|
||||
</p>
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{% 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 %}
|
||||
<h2>
|
||||
Traitement de la demande de petits cours {{ demande.id }}
|
||||
|
@ -21,9 +27,11 @@
|
|||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if proposals %}
|
||||
<form method="post">
|
||||
|
||||
<form method="post" id="traitement-form">
|
||||
{% csrf_token %}
|
||||
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
|
||||
{% if proposals %}
|
||||
{% for matiere, users in proposals %}
|
||||
<h4>{{ matiere }}</h4>
|
||||
{% for i in "012"|make_list %}{% if i|add:"0" < users|length %}
|
||||
|
@ -53,13 +61,36 @@
|
|||
{% endfor %}
|
||||
{% endfor %}
|
||||
<input type="hidden" name="preparing" value="1" />
|
||||
{% 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" />
|
||||
</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="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>
|
||||
|
||||
<p>
|
||||
<a href="{% url 'petits-cours-demandes-list' %}">Retour à la liste des demandes</a>
|
||||
</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.shortcuts import get_object_or_404, redirect, render
|
||||
from django.template import loader
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.generic import DetailView, ListView
|
||||
|
@ -16,6 +17,7 @@ from gestioncof.decorators import buro_required
|
|||
from gestioncof.models import CofProfile
|
||||
from petitscours.forms import DemandeForm, MatieresFormSet
|
||||
from petitscours.models import (
|
||||
LEVELS_CHOICES,
|
||||
PetitCoursAbility,
|
||||
PetitCoursAttribution,
|
||||
PetitCoursAttributionCounter,
|
||||
|
@ -168,6 +170,12 @@ def _traitement_other_preparing(request, demande):
|
|||
|
||||
def _traitement_other(request, demande, redo):
|
||||
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:
|
||||
return _traitement_other_preparing(request, demande)
|
||||
else:
|
||||
|
@ -180,16 +188,38 @@ def _traitement_other(request, demande, redo):
|
|||
"demande": demande,
|
||||
"unsatisfied": unsatisfied,
|
||||
"proposals": proposals.items(),
|
||||
"levels": LEVELS_CHOICES,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
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 = {}
|
||||
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 +283,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