forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -338,6 +338,19 @@ class Assiduite(ScoDocModel):
|
||||
|
||||
return "Non spécifié" if traduire else None
|
||||
|
||||
def get_saisie(self) -> str:
|
||||
"""
|
||||
retourne le texte "saisie le <date> par <User>"
|
||||
"""
|
||||
|
||||
date: str = self.entry_date.strftime("%d/%m/%Y à %H:%M")
|
||||
utilisateur: str = ""
|
||||
if self.user != None:
|
||||
self.user: User
|
||||
utilisateur = f"par {self.user.get_prenomnom()}"
|
||||
|
||||
return f"saisie le {date} {utilisateur}"
|
||||
|
||||
|
||||
class Justificatif(ScoDocModel):
|
||||
"""
|
||||
|
596
app/templates/assiduites/pages/calendrier2.j2
Normal file
596
app/templates/assiduites/pages/calendrier2.j2
Normal file
@ -0,0 +1,596 @@
|
||||
{% block pageContent %}
|
||||
{% include "assiduites/widgets/alert.j2" %}
|
||||
|
||||
<div class="pageContent">
|
||||
<h2>Assiduité de {{sco.etud.html_link_fiche()|safe}}</h2>
|
||||
|
||||
<div class="options">
|
||||
<input type="checkbox" id="show_pres" name="show_pres" class="memo" {{'checked' if show_pres else ''}}><label for="show_pres">afficher les présences</label>
|
||||
<input type="checkbox" name="show_reta" id="show_reta" class="memo" {{'checked' if show_reta else ''}}><label for="show_reta">afficher les retards</label>
|
||||
<input type="checkbox" name="mode_demi" id="mode_demi" class="memo" {{'checked' if mode_demi else ''}}><label for="mode_demi">mode demi journée</label>
|
||||
</div>
|
||||
|
||||
<div class="calendrier">
|
||||
{% for mois,jours in calendrier.items() %}
|
||||
<div class="month">
|
||||
<h3>{{mois}}</h3>
|
||||
<div class="days {{'demi' if mode_demi else ''}}">
|
||||
{% for jour in jours %}
|
||||
{% if jour.is_non_work() %}
|
||||
<div class="day {{jour.get_class()}}">
|
||||
<span>{{jour.get_nom()}}</span>
|
||||
{% else %}
|
||||
<div class="day {{jour.get_class(show_pres, show_reta) if not mode_demi else ''}}">
|
||||
{% endif %}
|
||||
{% if mode_demi %}
|
||||
{% if not jour.is_non_work() %}
|
||||
<span>{{jour.get_nom()}}</span>
|
||||
<span class="{{jour.get_demi_class(True, show_pres,show_reta)}}"></span>
|
||||
<span class="{{jour.get_demi_class(False, show_pres,show_reta)}}"></span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if not jour.is_non_work() %}
|
||||
<span>{{jour.get_nom(False)}}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if not jour.is_non_work() and jour.has_assiduites()%}
|
||||
|
||||
<div class="dayline">
|
||||
<div class="dayline-title">
|
||||
<span>Assiduité du</span>
|
||||
<br>
|
||||
<span>{{jour.get_date()}}</span>
|
||||
{{jour.generate_minitimeline() | safe}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="annee">
|
||||
<span id="label-annee">Année scolaire 2022-2023</span><span id="label-changer" style="margin-left: 5px;">Changer
|
||||
année: </span>
|
||||
<select name="" id="annee">
|
||||
</select>
|
||||
|
||||
<span id="label-nom">Assiduité de {{sco.etud.nomprenom}}</span>
|
||||
</div>
|
||||
|
||||
<div class="help">
|
||||
<h3>Calendrier</h3>
|
||||
<p>Code couleur</p>
|
||||
<ul class="couleurs">
|
||||
<li><span title="Vert" class="present demo"></span> → présence de l'étudiant lors de la période
|
||||
</li>
|
||||
<li><span title="Bleu clair" class="nonwork demo"></span> → la période n'est pas travaillée
|
||||
</li>
|
||||
<li><span title="Rouge" class="absent demo"></span> → absence de l'étudiant lors de la période
|
||||
</li>
|
||||
<li><span title="Rose" class="demo color absent est_just"></span> → absence justifiée
|
||||
</li>
|
||||
<li><span title="Orange" class="retard demo"></span> → retard de l'étudiant lors de la période
|
||||
</li>
|
||||
<li><span title="Jaune clair" class="demo color retard est_just"></span> → retard justifié
|
||||
</li>
|
||||
|
||||
<li><span title="Quart Bleu" class="est_just demo"></span> → la période est couverte par un
|
||||
justificatif valide</li>
|
||||
<li><span title="Justif. non valide" class="invalide demo"></span> → la période est
|
||||
couverte par un justificatif non valide
|
||||
</li>
|
||||
<li><span title="Justif. en attente" class="attente demo"></span> → la période
|
||||
a un justificatif en attente de validation
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Vous pouvez passer le curseur sur les jours colorés afin de voir les informations supplémentaires</p>
|
||||
</div>
|
||||
<ul class="couleurs print">
|
||||
<li><span title="Vert" class="present demo"></span> présence
|
||||
</li>
|
||||
<li><span title="Bleu clair" class="nonwork demo"></span> non travaillé
|
||||
</li>
|
||||
<li><span title="Rouge" class="absent demo"></span> absence
|
||||
</li>
|
||||
<li><span title="Rose" class="demo color absent est_just"></span> absence justifiée
|
||||
</li>
|
||||
<li><span title="Orange" class="retard demo"></span> retard
|
||||
</li>
|
||||
<li><span title="Jaune clair" class="demo color retard est_just"></span>retard justifié
|
||||
</li>
|
||||
<li><span title="Quart Bleu" class="est_just demo"></span>
|
||||
justificatif valide</li>
|
||||
<li><span title="Quart Violet" class="invalide demo"></span> justificatif non valide
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.help .couleurs {
|
||||
grid-template-columns: 2;
|
||||
grid-template-rows: auto;
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.couleurs.print {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.help .couleurs li:nth-child(odd) {
|
||||
grid-column: 1;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.help .couleurs li:nth-child(even) {
|
||||
grid-column: 2;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.color.present {
|
||||
background-color: var(--color-present) !important;
|
||||
}
|
||||
|
||||
.color.absent {
|
||||
background-color: var(--color-absent) !important;
|
||||
}
|
||||
|
||||
.color.absent.est_just {
|
||||
background-color: var(--color-absent-justi) !important;
|
||||
}
|
||||
.color.retard {
|
||||
background-color: var(--color-retard) !important;
|
||||
}
|
||||
|
||||
.color.retard.est_just {
|
||||
background-color: var(--color-retard-justi) !important;
|
||||
}
|
||||
|
||||
.color.nonwork {
|
||||
background-color: var(--color-nonwork) !important;
|
||||
}
|
||||
|
||||
.color {
|
||||
background-color: var(--color-defaut) !important;
|
||||
}
|
||||
|
||||
.pageContent {
|
||||
margin-top: 1vh;
|
||||
max-width: var(--sco-content-max-width);
|
||||
}
|
||||
|
||||
.calendrier {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
flex-wrap: wrap;
|
||||
border: 1px solid #444;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.month h3 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.day,
|
||||
.demi .day.color.nonwork {
|
||||
text-align: left;
|
||||
margin: 2px;
|
||||
cursor: default;
|
||||
font-size: 13px;
|
||||
position: relative;
|
||||
font-weight: normal;
|
||||
min-width: 6em;
|
||||
display: flex;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.color.est_just.sans_etat::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 25%;
|
||||
height: 100%;
|
||||
background-color: var(--color-justi) !important;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.color.invalide::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 25%;
|
||||
height: 100%;
|
||||
right: 0;
|
||||
background-color: var(--color-justi-invalide) !important;
|
||||
}
|
||||
.color.attente::before, .color.modifie::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 25%;
|
||||
height: 100%;
|
||||
right: 0;
|
||||
background: repeating-linear-gradient(
|
||||
to bottom,
|
||||
var(--color-justi-attente-stripe) 0px,
|
||||
var(--color-justi-attente-stripe) 4px,
|
||||
var(--color-justi-attente) 4px,
|
||||
var(--color-justi-attente) 7px
|
||||
)!important;
|
||||
}
|
||||
.demo.invalide {
|
||||
background-color: var(--color-justi-invalide) !important;
|
||||
}
|
||||
.demo.attente {
|
||||
background: repeating-linear-gradient(
|
||||
to bottom,
|
||||
var(--color-justi-attente-stripe) 0px,
|
||||
var(--color-justi-attente-stripe) 4px,
|
||||
var(--color-justi-attente) 4px,
|
||||
var(--color-justi-attente) 7px
|
||||
)!important;
|
||||
}
|
||||
|
||||
.demo.est_just {
|
||||
background-color: var(--color-justi) !important;
|
||||
}
|
||||
|
||||
|
||||
.demi .day.nonwork>span {
|
||||
flex: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.demi .day {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.day .dayline {
|
||||
position: absolute;
|
||||
display: none;
|
||||
top: 100%;
|
||||
z-index: 50;
|
||||
width: max-content;
|
||||
height: 75px;
|
||||
background-color: #dedede;
|
||||
border-radius: 15px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.day:hover .dayline {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dayline .mini-timeline {
|
||||
margin-top: 10%;
|
||||
}
|
||||
|
||||
.dayline-title {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.dayline .mini_tick {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
top: 0;
|
||||
transform: translateY(-110%);
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.dayline .mini_tick::after {
|
||||
display: block;
|
||||
content: "|";
|
||||
position: absolute;
|
||||
bottom: -69%;
|
||||
z-index: 2;
|
||||
transform: translateX(200%);
|
||||
}
|
||||
|
||||
#label-nom,
|
||||
#label-justi {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.demi .day {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.demi .day>span {
|
||||
display: block;
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
border: 1px solid #d5d5d5;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.demi .day>span:first-of-type {
|
||||
width: 3em;
|
||||
min-width: 3em;
|
||||
}
|
||||
|
||||
.options>* {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.options input {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.options label {
|
||||
font-weight: normal;
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
|
||||
/*Gestion des bubbles*/
|
||||
.assiduite-bubble {
|
||||
position: relative;
|
||||
display: none;
|
||||
background-color: #f9f9f9;
|
||||
border-radius: 5px;
|
||||
padding: 8px;
|
||||
border: 3px solid #ccc;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
z-index: 500;
|
||||
min-width: max-content;
|
||||
top: 200%;
|
||||
}
|
||||
|
||||
.mini-timeline-block:hover .assiduite-bubble {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.assiduite-bubble::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
border-width: 6px;
|
||||
border-style: solid;
|
||||
border-color: transparent transparent #f9f9f9 transparent;
|
||||
}
|
||||
|
||||
.assiduite-bubble::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
border-color: transparent transparent #ccc transparent;
|
||||
}
|
||||
|
||||
.assiduite-id,
|
||||
.assiduite-period,
|
||||
.assiduite-state,
|
||||
.assiduite-user_id {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.assiduite-bubble.absent {
|
||||
border-color: var(--color-absent) !important;
|
||||
}
|
||||
|
||||
.assiduite-bubble.present {
|
||||
border-color: var(--color-present) !important;
|
||||
}
|
||||
|
||||
.assiduite-bubble.retard {
|
||||
border-color: var(--color-retard) !important;
|
||||
}
|
||||
|
||||
/*Gestion des minitimelines*/
|
||||
.mini-timeline {
|
||||
height: 7px;
|
||||
border: 1px solid black;
|
||||
position: relative;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.mini-timeline.single {
|
||||
height: 9px;
|
||||
}
|
||||
|
||||
.mini-timeline-block {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.mini-timeline-block {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.mini_tick {
|
||||
position: absolute;
|
||||
text-align: start;
|
||||
top: -40px;
|
||||
transform: translateX(-50%);
|
||||
z-index: 50;
|
||||
|
||||
}
|
||||
|
||||
.mini_tick::after {
|
||||
display: block;
|
||||
content: "|";
|
||||
position: absolute;
|
||||
bottom: -2px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.mini-timeline-block.creneau {
|
||||
outline: 3px solid var(--color-primary);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.mini-timeline-block.absent {
|
||||
background-color: var(--color-absent) !important;
|
||||
}
|
||||
|
||||
.mini-timeline-block.present {
|
||||
background-color: var(--color-present) !important;
|
||||
}
|
||||
|
||||
.mini-timeline-block.retard {
|
||||
background-color: var(--color-retard) !important;
|
||||
}
|
||||
|
||||
.mini-timeline-block.justified {
|
||||
background-image: var(--motif-justi);
|
||||
}
|
||||
|
||||
.mini-timeline-block.invalid_justified {
|
||||
background-image: var(--motif-justi-invalide);
|
||||
}
|
||||
|
||||
@media print {
|
||||
|
||||
.couleurs.print {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.couleurs.print li {
|
||||
list-style-type: none !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
|
||||
.day,
|
||||
.demi .day.color.color.nonwork {
|
||||
min-width: 5em;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.demi .day>span:first-of-type {
|
||||
width: 2.5em;
|
||||
min-width: 2.5em;
|
||||
}
|
||||
|
||||
.color {
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
|
||||
.day.est_just,
|
||||
.demi .day span.est_just {
|
||||
background-image: none;
|
||||
|
||||
}
|
||||
|
||||
.day.invalide,
|
||||
.demi .day span.invalide {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.demi .day span.est_just::before {
|
||||
content: "J";
|
||||
}
|
||||
|
||||
.demi .day span.invalide::before {
|
||||
content: "JI";
|
||||
}
|
||||
|
||||
#sidebar,
|
||||
.help,
|
||||
h2,
|
||||
#annee,
|
||||
#label-changer,
|
||||
.options {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#label-nom,
|
||||
#label-justi {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#gtrcontent {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.annee {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function getOptions() {
|
||||
return {
|
||||
"show_pres": document.getElementById("show_pres").checked,
|
||||
"show_reta": document.getElementById("show_reta").checked,
|
||||
"mode_demi": document.getElementById("mode_demi").checked,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updatePage(){
|
||||
const url = new URL(location.href);
|
||||
const options = getOptions();
|
||||
url.searchParams.set("annee", document.getElementById('annee').value);
|
||||
url.searchParams.set("mode_demi", options.mode_demi);
|
||||
url.searchParams.set("show_pres", options.show_pres);
|
||||
url.searchParams.set("show_reta", options.show_reta);
|
||||
|
||||
if (location.href != url.href){
|
||||
location.href = url.href
|
||||
}
|
||||
}
|
||||
|
||||
const defAnnee = {{ annee }}
|
||||
let annees = {{ annees | safe }}
|
||||
annees = annees.filter((x, i) => annees.indexOf(x) === i)
|
||||
const etudid = {{ sco.etud.id }};
|
||||
|
||||
const select = document.querySelector('#annee');
|
||||
annees.forEach((a) => {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = a + "",
|
||||
opt.textContent = `${a} - ${a + 1}`;
|
||||
if (a === defAnnee) {
|
||||
opt.selected = true;
|
||||
document.querySelector('.annee #label-annee').textContent = `Année scolaire ${a}-${a + 1}`
|
||||
|
||||
}
|
||||
select.appendChild(opt)
|
||||
})
|
||||
|
||||
document.querySelectorAll('input[type="checkbox"].memo, #annee').forEach(el => {
|
||||
el.addEventListener('change', function() {
|
||||
updatePage();
|
||||
})});
|
||||
|
||||
document.querySelectorAll('[assi_id]').forEach((el,i) => {
|
||||
el.addEventListener('click', ()=>{
|
||||
const assi_id = el.getAttribute('assi_id');
|
||||
window.open(`${SCO_URL}/Assiduites/tableau_assiduite_actions?type=assiduite&action=details&obj_id=${assi_id}`);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
{% endblock pageContent %}
|
7
app/templates/assiduites/widgets/assiduite_bubble.j2
Normal file
7
app/templates/assiduites/widgets/assiduite_bubble.j2
Normal file
@ -0,0 +1,7 @@
|
||||
<div class="assiduite-bubble {{etat}}">
|
||||
<div class="assiduite-id">{{moduleimpl}}</div>
|
||||
<div class="assiduite-period">{{date_debut}}</div>
|
||||
<div class="assiduite-period">{{date_fin}}</div>
|
||||
<div class="assiduite-state">État: {{etat}}</div>
|
||||
<div class="assiduite-user_id">{{saisie}}</div>
|
||||
</div>
|
7
app/templates/assiduites/widgets/minitimeline_simple.j2
Normal file
7
app/templates/assiduites/widgets/minitimeline_simple.j2
Normal file
@ -0,0 +1,7 @@
|
||||
<div class="mini-timeline">
|
||||
{% for assi in assi_blocks %}
|
||||
<div assi_id="{{assi.id}}" class="mini-timeline-block {{assi.etat}} {{assi.est_just}}" style="left: {{assi.emplacement}}%; width:{{assi.longueur}}%;" >
|
||||
{{assi.bubble | safe }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
@ -80,6 +80,7 @@ from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.tables.visu_assiduites import TableAssi, etuds_sorted_from_ids
|
||||
from app.scodoc.sco_archives_justificatifs import JustificatifArchiver
|
||||
|
||||
from flask_sqlalchemy.query import Query
|
||||
|
||||
CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS
|
||||
|
||||
@ -837,19 +838,11 @@ def calendrier_assi_etud():
|
||||
if etud.dept_id != g.scodoc_dept_id:
|
||||
abort(404, "étudiant inexistant dans ce département")
|
||||
|
||||
# Préparation de la page
|
||||
header: str = html_sco_header.sco_header(
|
||||
page_title="Calendrier de l'assiduité",
|
||||
init_qtip=True,
|
||||
javascripts=[
|
||||
"js/assiduites.js",
|
||||
"js/date_utils.js",
|
||||
],
|
||||
cssstyles=CSSSTYLES
|
||||
+ [
|
||||
"css/assiduites.css",
|
||||
],
|
||||
)
|
||||
# Options
|
||||
mode_demi: bool = scu.to_bool(request.args.get("mode_demi", "t"))
|
||||
show_pres: bool = scu.to_bool(request.args.get("show_pres", "f"))
|
||||
show_reta: bool = scu.to_bool(request.args.get("show_reta", "f"))
|
||||
annee: int = int(request.args.get("annee", scu.annee_scolaire()))
|
||||
|
||||
# Récupération des années d'étude de l'étudiant
|
||||
annees: list[int] = []
|
||||
@ -866,16 +859,34 @@ def calendrier_assi_etud():
|
||||
annees_str += f"{ann},"
|
||||
annees_str += "]"
|
||||
|
||||
# Préparation de la page
|
||||
header: str = html_sco_header.sco_header(
|
||||
page_title="Calendrier de l'assiduité",
|
||||
init_qtip=True,
|
||||
javascripts=[
|
||||
"js/assiduites.js",
|
||||
"js/date_utils.js",
|
||||
],
|
||||
cssstyles=CSSSTYLES
|
||||
+ [
|
||||
"css/assiduites.css",
|
||||
],
|
||||
)
|
||||
|
||||
calendrier = generate_calendar(etud, annee)
|
||||
# Peuplement du template jinja
|
||||
return HTMLBuilder(
|
||||
header,
|
||||
render_template(
|
||||
"assiduites/pages/calendrier.j2",
|
||||
"assiduites/pages/calendrier2.j2",
|
||||
sco=ScoData(etud),
|
||||
annee=scu.annee_scolaire(),
|
||||
annee=annee,
|
||||
nonworkdays=_non_work_days(),
|
||||
minitimeline=_mini_timeline(),
|
||||
annees=annees_str,
|
||||
calendrier=calendrier,
|
||||
mode_demi=mode_demi,
|
||||
show_pres=show_pres,
|
||||
show_reta=show_reta,
|
||||
),
|
||||
).build()
|
||||
|
||||
@ -2239,3 +2250,352 @@ def _get_etuds_dem_def(formsemestre) -> str:
|
||||
)
|
||||
+ "}"
|
||||
)
|
||||
|
||||
|
||||
# --- Gestion du calendrier ---
|
||||
|
||||
|
||||
def generate_calendar(
|
||||
etudiant: Identite,
|
||||
annee: int = None,
|
||||
):
|
||||
# Si pas d'année alors on prend l'année scolaire en cours
|
||||
if annee is None:
|
||||
annee = scu.annee_scolaire()
|
||||
|
||||
# On prend du 01/09 au 31/08
|
||||
date_debut: datetime.datetime = datetime.datetime(annee, 9, 1, 0, 0)
|
||||
date_fin: datetime.datetime = datetime.datetime(annee + 1, 8, 31, 23, 59)
|
||||
|
||||
# Filtrage des assiduités et des justificatifs en fonction de la periode / année
|
||||
etud_assiduites: Query = scass.filter_by_date(
|
||||
etudiant.assiduites,
|
||||
Assiduite,
|
||||
date_deb=date_debut,
|
||||
date_fin=date_fin,
|
||||
)
|
||||
etud_justificatifs: Query = scass.filter_by_date(
|
||||
etudiant.justificatifs,
|
||||
Justificatif,
|
||||
date_deb=date_debut,
|
||||
date_fin=date_fin,
|
||||
)
|
||||
|
||||
# Récupération des jours de l'année et de leurs assiduités/justificatifs
|
||||
annee_par_mois: dict[int, list[datetime.date]] = _organize_by_month(
|
||||
_get_dates_between(
|
||||
deb=date_debut.date(),
|
||||
fin=date_fin.date(),
|
||||
),
|
||||
etud_assiduites,
|
||||
etud_justificatifs,
|
||||
)
|
||||
|
||||
return annee_par_mois
|
||||
|
||||
|
||||
WEEKDAYS = {
|
||||
0: "Lun ",
|
||||
1: "Mar ",
|
||||
2: "Mer ",
|
||||
3: "Jeu ",
|
||||
4: "Ven ",
|
||||
5: "Sam ",
|
||||
6: "Dim ",
|
||||
}
|
||||
|
||||
MONTHS = {
|
||||
1: "Janv.",
|
||||
2: "Févr.",
|
||||
3: "Mars",
|
||||
4: "Avr.",
|
||||
5: "Mai",
|
||||
6: "Juin",
|
||||
7: "Juil.",
|
||||
8: "Août",
|
||||
9: "Sept.",
|
||||
10: "Oct.",
|
||||
11: "Nov.",
|
||||
12: "Déc.",
|
||||
}
|
||||
|
||||
|
||||
class Jour:
|
||||
"""Jour
|
||||
Jour du calendrier
|
||||
get_nom : retourne le numéro et le nom du Jour (ex: M19 / Mer 19)
|
||||
"""
|
||||
|
||||
def __init__(self, date: datetime.date, assiduites: Query, justificatifs: Query):
|
||||
self.date = date
|
||||
self.assiduites = assiduites
|
||||
self.justificatifs = justificatifs
|
||||
|
||||
def get_nom(self, mode_demi: bool = True) -> str:
|
||||
str_jour: str = WEEKDAYS.get(self.date.weekday())
|
||||
return f"{str_jour[0] if mode_demi or self.is_non_work() else str_jour}{self.date.day}"
|
||||
|
||||
def get_date(self) -> str:
|
||||
return self.date.strftime("%d/%m/%Y")
|
||||
|
||||
def get_class(self, show_pres: bool = False, show_reta: bool = False) -> str:
|
||||
etat = ""
|
||||
est_just = ""
|
||||
|
||||
if self.is_non_work():
|
||||
return "color nonwork"
|
||||
|
||||
etat = self._get_color_assiduites_cascade(
|
||||
self._get_etats_from_assiduites(self.assiduites),
|
||||
show_pres=show_pres,
|
||||
show_reta=show_reta,
|
||||
)
|
||||
|
||||
est_just = self._get_color_justificatifs_cascade(
|
||||
self._get_etats_from_justificatifs(self.justificatifs),
|
||||
)
|
||||
|
||||
return f"color {etat} {est_just}"
|
||||
|
||||
def get_demi_class(
|
||||
self, matin: bool, show_pres: bool = False, show_reta: bool = False
|
||||
) -> str:
|
||||
# Transformation d'une heure "HH:MM" en time(h,m)
|
||||
STR_TIME = lambda x: datetime.time(*list(map(int, x.split(":"))))
|
||||
|
||||
heure_midi = STR_TIME(ScoDocSiteConfig.get("assi_lunch_time", "13:00"))
|
||||
|
||||
if matin:
|
||||
heure_matin = STR_TIME(ScoDocSiteConfig.get("assi_morning_time", "08:00"))
|
||||
matin = (
|
||||
# date debut
|
||||
scu.localize_datetime(
|
||||
datetime.datetime.combine(self.date, heure_matin)
|
||||
),
|
||||
# date fin
|
||||
scu.localize_datetime(datetime.datetime.combine(self.date, heure_midi)),
|
||||
)
|
||||
assiduites_matin = [
|
||||
assi
|
||||
for assi in self.assiduites
|
||||
if scu.is_period_overlapping((assi.date_debut, assi.date_fin), matin)
|
||||
]
|
||||
justificatifs_matin = [
|
||||
justi
|
||||
for justi in self.justificatifs
|
||||
if scu.is_period_overlapping((justi.date_debut, justi.date_fin), matin)
|
||||
]
|
||||
|
||||
etat = self._get_color_assiduites_cascade(
|
||||
self._get_etats_from_assiduites(assiduites_matin),
|
||||
show_pres=show_pres,
|
||||
show_reta=show_reta,
|
||||
)
|
||||
|
||||
est_just = self._get_color_justificatifs_cascade(
|
||||
self._get_etats_from_justificatifs(justificatifs_matin),
|
||||
)
|
||||
|
||||
return f"color {etat} {est_just}"
|
||||
|
||||
heure_soir = STR_TIME(ScoDocSiteConfig.get("assi_afternoon_time", "17:00"))
|
||||
|
||||
# séparation en demi journées
|
||||
aprem = (
|
||||
# date debut
|
||||
scu.localize_datetime(datetime.datetime.combine(self.date, heure_midi)),
|
||||
# date fin
|
||||
scu.localize_datetime(datetime.datetime.combine(self.date, heure_soir)),
|
||||
)
|
||||
|
||||
assiduites_aprem = [
|
||||
assi
|
||||
for assi in self.assiduites
|
||||
if scu.is_period_overlapping((assi.date_debut, assi.date_fin), aprem)
|
||||
]
|
||||
|
||||
justificatifs_aprem = [
|
||||
justi
|
||||
for justi in self.justificatifs
|
||||
if scu.is_period_overlapping((justi.date_debut, justi.date_fin), aprem)
|
||||
]
|
||||
|
||||
etat = self._get_color_assiduites_cascade(
|
||||
self._get_etats_from_assiduites(assiduites_aprem),
|
||||
show_pres=show_pres,
|
||||
show_reta=show_reta,
|
||||
)
|
||||
|
||||
est_just = self._get_color_justificatifs_cascade(
|
||||
self._get_etats_from_justificatifs(justificatifs_aprem),
|
||||
)
|
||||
|
||||
return f"color {etat} {est_just}"
|
||||
|
||||
def has_assiduites(self) -> bool:
|
||||
return self.assiduites.count() > 0
|
||||
|
||||
def generate_minitimeline(self) -> str:
|
||||
# Récupérer le référenciel de la timeline
|
||||
STR_TIME = lambda x: _time_to_timedelta(
|
||||
datetime.time(*list(map(int, x.split(":"))))
|
||||
)
|
||||
|
||||
heure_matin: datetime.timedelta = STR_TIME(
|
||||
ScoDocSiteConfig.get("assi_morning_time", "08:00")
|
||||
)
|
||||
heure_midi: datetime.timedelta = STR_TIME(
|
||||
ScoDocSiteConfig.get("assi_lun_time", "13:00")
|
||||
)
|
||||
heure_soir: datetime.timedelta = STR_TIME(
|
||||
ScoDocSiteConfig.get("assi_afternoon_time", "17:00")
|
||||
)
|
||||
# longueur_timeline = heure_soir - heure_matin
|
||||
longueur_timeline: datetime.timedelta = heure_soir - heure_matin
|
||||
|
||||
# chaque block d'assiduité est défini par:
|
||||
# longueur = ( (fin-deb) / longueur_timeline ) * 100
|
||||
# emplacement = ( (deb - heure_matin) / longueur_timeline ) * 100
|
||||
|
||||
assiduite_blocks: list[dict[str, float | str]] = []
|
||||
|
||||
for assi in self.assiduites:
|
||||
deb: datetime.timedelta = _time_to_timedelta(
|
||||
assi.date_debut.time()
|
||||
if assi.date_debut.date() == self.date
|
||||
else heure_matin
|
||||
)
|
||||
fin: datetime.timedelta = _time_to_timedelta(
|
||||
assi.date_fin.time()
|
||||
if assi.date_fin.date() == self.date
|
||||
else heure_soir
|
||||
)
|
||||
|
||||
longueur: float = ((fin - deb) / longueur_timeline) * 100
|
||||
emplacement: float = ((deb - heure_matin) / longueur_timeline) * 100
|
||||
etat: str = scu.EtatAssiduite(assi.etat).name.lower()
|
||||
est_just: str = "est_just" if assi.est_just else ""
|
||||
|
||||
assiduite_blocks.append(
|
||||
{
|
||||
"longueur": longueur,
|
||||
"emplacement": emplacement,
|
||||
"etat": etat,
|
||||
"est_just": est_just,
|
||||
"bubble": _generate_assiduite_bubble(assi),
|
||||
"id": assi.assiduite_id,
|
||||
}
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"assiduites/widgets/minitimeline_simple.j2",
|
||||
assi_blocks=assiduite_blocks,
|
||||
)
|
||||
|
||||
def is_non_work(self):
|
||||
return self.date.weekday() in scu.NonWorkDays.get_all_non_work_days(
|
||||
dept_id=g.scodoc_dept_id
|
||||
)
|
||||
|
||||
def _get_etats_from_assiduites(self, assiduites: Query) -> list[scu.EtatAssiduite]:
|
||||
return list(set([scu.EtatAssiduite(assi.etat) for assi in assiduites]))
|
||||
|
||||
def _get_etats_from_justificatifs(
|
||||
self, justificatifs: Query
|
||||
) -> list[scu.EtatJustificatif]:
|
||||
return list(set([scu.EtatJustificatif(justi.etat) for justi in justificatifs]))
|
||||
|
||||
def _get_color_assiduites_cascade(
|
||||
self,
|
||||
etats: list[scu.EtatAssiduite],
|
||||
show_pres: bool = False,
|
||||
show_reta: bool = False,
|
||||
) -> str:
|
||||
if scu.EtatAssiduite.ABSENT in etats:
|
||||
return "absent"
|
||||
if scu.EtatAssiduite.RETARD in etats and show_reta:
|
||||
return "retard"
|
||||
if scu.EtatAssiduite.PRESENT in etats and show_pres:
|
||||
return "present"
|
||||
|
||||
return "sans_etat"
|
||||
|
||||
def _get_color_justificatifs_cascade(
|
||||
self,
|
||||
etats: list[scu.EtatJustificatif],
|
||||
) -> str:
|
||||
if scu.EtatJustificatif.VALIDE in etats:
|
||||
return "est_just"
|
||||
if scu.EtatJustificatif.ATTENTE in etats:
|
||||
return "attente"
|
||||
if scu.EtatJustificatif.MODIFIE in etats:
|
||||
return "modifie"
|
||||
if scu.EtatJustificatif.NON_VALIDE in etats:
|
||||
return "invalide"
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
def _get_dates_between(deb: datetime.date, fin: datetime.date) -> list[datetime.date]:
|
||||
resultat = []
|
||||
date_actuelle = deb
|
||||
while date_actuelle <= fin:
|
||||
resultat.append(date_actuelle)
|
||||
date_actuelle += datetime.timedelta(days=1)
|
||||
return resultat
|
||||
|
||||
|
||||
def _organize_by_month(days, assiduites, justificatifs):
|
||||
"""
|
||||
Organiser les dates par mois.
|
||||
"""
|
||||
organized = {}
|
||||
for date in days:
|
||||
# Utiliser le numéro du mois comme clé
|
||||
month = MONTHS.get(date.month)
|
||||
# Ajouter le jour à la liste correspondante au mois
|
||||
if month not in organized:
|
||||
organized[month] = []
|
||||
|
||||
date_assiduites: Query = scass.filter_by_date(
|
||||
assiduites,
|
||||
Assiduite,
|
||||
date_deb=datetime.datetime.combine(date, datetime.time(0, 0)),
|
||||
date_fin=datetime.datetime.combine(date, datetime.time(23, 59, 59)),
|
||||
)
|
||||
|
||||
date_justificatifs: Query = scass.filter_by_date(
|
||||
justificatifs,
|
||||
Justificatif,
|
||||
date_deb=datetime.datetime.combine(date, datetime.time(0, 0)),
|
||||
date_fin=datetime.datetime.combine(date, datetime.time(23, 59, 59)),
|
||||
)
|
||||
# On génère un `Jour` composé d'une date, et des assiduités/justificatifs du jour
|
||||
jour: Jour = Jour(date, date_assiduites, date_justificatifs)
|
||||
|
||||
organized[month].append(jour)
|
||||
|
||||
return organized
|
||||
|
||||
|
||||
def _time_to_timedelta(t: datetime.time) -> datetime.timedelta:
|
||||
if isinstance(t, datetime.timedelta):
|
||||
return t
|
||||
return datetime.timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)
|
||||
|
||||
|
||||
def _generate_assiduite_bubble(assiduite: Assiduite) -> str:
|
||||
# Récupérer informations modules impl
|
||||
moduleimpl_infos: str = assiduite.get_module(traduire=True)
|
||||
|
||||
# Récupérer informations saisie
|
||||
saisie: str = assiduite.get_saisie()
|
||||
|
||||
return render_template(
|
||||
"assiduites/widgets/assiduite_bubble.j2",
|
||||
moduleimpl=moduleimpl_infos,
|
||||
etat=scu.EtatAssiduite(assiduite.etat).name.lower(),
|
||||
date_debut=assiduite.date_debut.strftime("%d/%m/%Y %H:%M"),
|
||||
date_fin=assiduite.date_fin.strftime("%d/%m/%Y %H:%M"),
|
||||
saisie=saisie,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user