Assiduite: relecture de code, cosmétique, formattage

This commit is contained in:
Emmanuel Viennet 2023-12-01 13:46:33 +01:00
parent a5e5ad6248
commit 419f1223dd
7 changed files with 457 additions and 456 deletions

View File

@ -896,14 +896,21 @@ def is_valid_filename(filename):
BOOL_STR = { BOOL_STR = {
0: False,
1: True,
"": False, "": False,
"0": False, "0": False,
"1": True, "1": True,
"f": False, "f": False,
"false": False, "false": False,
"o": True,
"on": True,
"n": False, "n": False,
"t": True, "t": True,
"true": True, "true": True,
True: True,
"v": True,
"vrai": True,
"y": True, "y": True,
} }

View File

@ -1,646 +1,651 @@
:root { :root {
--color-present: #6bdb83; --color-present: #6bdb83;
--color-absent: #e62a11; --color-absent: #e62a11;
--color-absent-clair: #F25D4A; --color-absent-clair: #f25d4a;
--color-retard: #f0c865; --color-retard: #f0c865;
--color-justi: #7059FF; --color-justi: #7059ff;
--color-justi-clair: #6885E3; --color-justi-clair: #6885e3;
--color-justi-invalide: #a84476; --color-justi-invalide: #a84476;
--color-nonwork: #badfff; --color-nonwork: #badfff;
--color-absent-justi: #e65ab7; --color-absent-justi: #e65ab7;
--color-retard-justi: #ffef7a; --color-retard-justi: #ffef7a;
--color-error: #e62a11; --color-error: #e62a11;
--color-warning: #eec660; --color-warning: #eec660;
--color-information: #658ef0; --color-information: #658ef0;
--color-def: #d61616; --color-def: #d61616;
--color-conflit: #ff00009c; --color-conflit: #ff00009c;
--color-bg-def: #c8c8c8; --color-bg-def: #c8c8c8;
--color-primary: #7059FF; --color-primary: #7059ff;
--color-secondary: #6f9fff; --color-secondary: #6f9fff;
--color-defaut: #FFF; --color-defaut: #fff;
--color-defaut-dark: #444; --color-defaut-dark: #444;
--color-default-text: #1F1F1F; --color-default-text: #1f1f1f;
--motif-justi: repeating-linear-gradient(
--motif-justi: repeating-linear-gradient(135deg, transparent, transparent 4px, var(--color-justi) 4px, var(--color-justi) 8px); 135deg,
--motif-justi-invalide: repeating-linear-gradient(-135deg, transparent, transparent 4px, var(--color-justi-invalide) 4px, var(--color-justi-invalide) 8px); transparent,
transparent 4px,
var(--color-justi) 4px,
var(--color-justi) 8px
);
--motif-justi-invalide: repeating-linear-gradient(
-135deg,
transparent,
transparent 4px,
var(--color-justi-invalide) 4px,
var(--color-justi-invalide) 8px
);
} }
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
.selectors>* { .selectors > * {
margin: 10px 0; margin: 10px 0;
} }
.selectors:disabled { .selectors:disabled {
opacity: 0.5; opacity: 0.5;
} }
#validate_selectors { #validate_selectors {
margin: 15px 0; margin: 15px 0;
} }
.no-display { .no-display {
display: none !important; display: none !important;
} }
/* === Gestion de la timeline === */ /* === Gestion de la timeline === */
#tl_date { #tl_date {
visibility: hidden; visibility: hidden;
width: 0px; width: 0px;
height: 0px; height: 0px;
position: absolute; position: absolute;
left: 15%; left: 15%;
} }
.infos-button { .infos-button {
position: relative; position: relative;
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
} }
.infos { .infos {
position: relative; position: relative;
display: flex; display: flex;
justify-content: start; justify-content: start;
align-content: center; align-content: center;
gap: 10px; gap: 10px;
} }
#datestr { #datestr {
cursor: pointer; cursor: pointer;
background-color: white; background-color: white;
border: 1px #444 solid; border: 1px #444 solid;
border-radius: 5px; border-radius: 5px;
padding: 5px; padding: 5px;
min-width: 250px; min-width: 250px;
display: inline-block; display: inline-block;
min-height: 20px; min-height: 20px;
} }
#tl_slider { #tl_slider {
width: 90%; width: 90%;
cursor: grab; cursor: grab;
/* visibility: hidden; */ /* visibility: hidden; */
} }
#datestr, #datestr,
#time { #time {
width: fit-content; width: fit-content;
} }
.ui-slider-handle.tl_handle { .ui-slider-handle.tl_handle {
background: none; background: none;
width: 25px; width: 25px;
height: 25px; height: 25px;
visibility: visible; visibility: visible;
background-position: top; background-position: top;
background-size: cover; background-size: cover;
border: none; border: none;
top: -180%; top: -180%;
cursor: grab; cursor: grab;
} }
#l_handle { #l_handle {
background-image: url(../icons/l_handle.svg); background-image: url(../icons/l_handle.svg);
} }
#r_handle { #r_handle {
background-image: url(../icons/r_handle.svg); background-image: url(../icons/r_handle.svg);
} }
.ui-slider-range.ui-widget-header.ui-corner-all { .ui-slider-range.ui-widget-header.ui-corner-all {
background-color: var(--color-warning); background-color: var(--color-warning);
background-image: none; background-image: none;
opacity: 0.50; opacity: 0.5;
visibility: visible; visibility: visible;
} }
/* === Gestion des etuds row === */ /* === Gestion des etuds row === */
.etud_row { .etud_row {
display: grid; display: grid;
grid-template-columns: 2% 20% 55% auto; grid-template-columns: 2% 20% 55% auto;
gap: 16px; gap: 16px;
background-color: white; background-color: white;
border-radius: 15px; border-radius: 15px;
padding: 4px 16px; padding: 4px 16px;
margin: 0.5% 0; margin: 0.5% 0;
box-shadow: -1px 12px 5px -8px rgba(68, 68, 68, 0.61); box-shadow: -1px 12px 5px -8px rgba(68, 68, 68, 0.61);
-webkit-box-shadow: -1px 12px 5px -8px rgba(68, 68, 68, 0.61); -webkit-box-shadow: -1px 12px 5px -8px rgba(68, 68, 68, 0.61);
-moz-box-shadow: -1px 12px 5px -8px rgba(68, 68, 68, 0.61); -moz-box-shadow: -1px 12px 5px -8px rgba(68, 68, 68, 0.61);
max-width: 800px; max-width: 800px;
} }
.etud_row * { .etud_row * {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 50px;
height: 50px;
} }
.etud_row.def, .etud_row.def,
.etud_row.dem { .etud_row.dem {
background-color: var(--color-bg-def); background-color: var(--color-bg-def);
} }
/* --- Index --- */ /* --- Index --- */
.etud_row .index_field { .etud_row .index_field {
grid-column: 1; grid-column: 1;
} }
/* --- Nom étud --- */ /* --- Nom étud --- */
.etud_row .name_field { .etud_row .name_field {
grid-column: 2; grid-column: 2;
height: 100%; height: 100%;
justify-content: start; justify-content: start;
} }
.etud_row .name_field .name_set { .etud_row .name_field .name_set {
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: flex-start;
margin: 0 5%; margin: 0 5%;
cursor: pointer; cursor: pointer;
} }
.etud_row.def .nom::after, .etud_row.def .nom::after,
.tr.def .td.sticky span::after { .tr.def .td.sticky span::after {
display: block; display: block;
content: " (Déf.)"; content: " (Déf.)";
color: var(--color-def); color: var(--color-def);
margin-left: 2px; margin-left: 2px;
} }
.etud_row.dem .nom::after, .etud_row.dem .nom::after,
.tr.dem .td.sticky span::after { .tr.dem .td.sticky span::after {
display: block; display: block;
content: " (Dém.)"; content: " (Dém.)";
color: var(--color-def); color: var(--color-def);
margin-left: 2px; margin-left: 2px;
} }
.etud_row .name_field .name_set * { .etud_row .name_field .name_set * {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
.etud_row .name_field .name_set h4 { .etud_row .name_field .name_set h4 {
font-size: small; font-size: small;
font-weight: 600; font-weight: 600;
} }
.etud_row .name_field .name_set h5 { .etud_row .name_field .name_set h5 {
font-size: x-small; font-size: x-small;
} }
.etud_row .pdp { .etud_row .pdp {
border-radius: 15px; border-radius: 15px;
} }
/* --- Barre assiduités --- */ /* --- Barre assiduités --- */
.etud_row .assiduites_bar { .etud_row .assiduites_bar {
display: grid; display: grid;
grid-template-columns: 7px 1fr; grid-template-columns: 7px 1fr;
gap: 13px; gap: 13px;
grid-column: 3; grid-column: 3;
position: relative; position: relative;
} }
.etud_row .assiduites_bar .filler { .etud_row .assiduites_bar .filler {
height: 5px; height: 5px;
width: 90%; width: 90%;
background-color: white; background-color: white;
border: 1px solid #444; border: 1px solid #444;
} }
.etud_row .assiduites_bar #prevDateAssi { .etud_row .assiduites_bar #prevDateAssi {
height: 7px; height: 7px;
width: 7px; width: 7px;
background-color: white; background-color: white;
border: 1px solid #444; border: 1px solid #444;
margin: 0px 8px; margin: 0px 8px;
} }
.etud_row .assiduites_bar #prevDateAssi.single { .etud_row .assiduites_bar #prevDateAssi.single {
height: 9px; height: 9px;
width: 9px; width: 9px;
} }
.etud_row.conflit { .etud_row.conflit {
background-color: var(--color-conflit); background-color: var(--color-conflit);
} }
.etud_row .assiduites_bar .absent, .etud_row .assiduites_bar .absent,
.demo.absent { .demo.absent {
background-color: var(--color-absent) !important; background-color: var(--color-absent) !important;
} }
.etud_row .assiduites_bar .present, .etud_row .assiduites_bar .present,
.demo.present { .demo.present {
background-color: var(--color-present) !important; background-color: var(--color-present) !important;
} }
.etud_row .assiduites_bar .retard, .etud_row .assiduites_bar .retard,
.demo.retard { .demo.retard {
background-color: var(--color-retard) !important; background-color: var(--color-retard) !important;
} }
.demo.nonwork { .demo.nonwork {
background-color: var(--color-nonwork) !important; background-color: var(--color-nonwork) !important;
} }
.etud_row .assiduites_bar .justified, .etud_row .assiduites_bar .justified,
.demo.justified { .demo.justified {
background-image: var(--motif-justi); background-image: var(--motif-justi);
} }
.etud_row .assiduites_bar .invalid_justified, .etud_row .assiduites_bar .invalid_justified,
.demo.invalid_justified { .demo.invalid_justified {
background-image: var(--motif-justi-invalide); background-image: var(--motif-justi-invalide);
} }
/* --- Boutons assiduités --- */ /* --- Boutons assiduités --- */
.etud_row .btns_field { .etud_row .btns_field {
grid-column: 4; grid-column: 4;
} }
.btns_field:disabled { .btns_field:disabled {
opacity: 0.7; opacity: 0.7;
} }
.etud_row .btns_field * { .etud_row .btns_field * {
margin: 0 5%; margin: 0 5%;
cursor: pointer; cursor: pointer;
width: 35px; width: 35px;
height: 35px; height: 35px;
} }
.rbtn { .rbtn {
-webkit-appearance: none; -webkit-appearance: none;
appearance: none; appearance: none;
cursor: pointer;
cursor: pointer;
} }
.rbtn::before { .rbtn::before {
content: ""; content: "";
display: inline-block; display: inline-block;
width: 35px; width: 35px;
height: 35px; height: 35px;
background-position: center; background-position: center;
background-size: cover; background-size: cover;
border-radius: 5px; border-radius: 5px;
border: 1px solid var(--color-defaut-dark); border: 1px solid var(--color-defaut-dark);
} }
.rbtn.present::before { .rbtn.present::before {
background-image: url(../icons/present.svg); background-image: url(../icons/present.svg);
background-color: var(--color-present); background-color: var(--color-present);
} }
.rbtn.absent::before { .rbtn.absent::before {
background-color: var(--color-absent); background-color: var(--color-absent);
background-image: url(../icons/absent.svg); background-image: url(../icons/absent.svg);
} }
.rbtn.aucun::before { .rbtn.aucun::before {
background-image: url(../icons/aucun.svg); background-image: url(../icons/aucun.svg);
background-color: var(--color-defaut-dark); background-color: var(--color-defaut-dark);
} }
.rbtn.retard::before { .rbtn.retard::before {
background-color: var(--color-retard); background-color: var(--color-retard);
background-image: url(../icons/retard.svg); background-image: url(../icons/retard.svg);
} }
.rbtn:checked:before { .rbtn:checked:before {
outline: 5px solid var(--color-primary); outline: 5px solid var(--color-primary);
border-radius: 50%; border-radius: 50%;
} }
.rbtn:focus { .rbtn:focus {
outline: none !important; outline: none !important;
} }
/*<== Modal conflit ==>*/ /*<== Modal conflit ==>*/
.modal { .modal {
display: block; display: block;
position: fixed; position: fixed;
z-index: 500; z-index: 500;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: auto; overflow: auto;
background-color: rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.4);
} }
.modal-content { .modal-content {
background-color: #fefefe; background-color: #fefefe;
margin: 5% auto; margin: 5% auto;
padding: 20px; padding: 20px;
border: 1px solid #888; border: 1px solid #888;
width: 80%; width: 80%;
height: 320px; height: 320px;
position: relative; position: relative;
border-radius: 10px; border-radius: 10px;
} }
.close { .close {
color: #111; color: #111;
position: absolute; position: absolute;
right: 5px; right: 5px;
top: 0px; top: 0px;
font-size: 28px; font-size: 28px;
font-weight: bold; font-weight: bold;
cursor: pointer; cursor: pointer;
} }
/* Ajout de styles pour la frise chronologique */ /* Ajout de styles pour la frise chronologique */
.modal-timeline { .modal-timeline {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: stretch; align-items: stretch;
margin-bottom: 20px; margin-bottom: 20px;
} }
.time-labels, .time-labels,
.assiduites-container { .assiduites-container {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
position: relative; position: relative;
} }
.time-label { .time-label {
font-size: 14px; font-size: 14px;
margin-bottom: 4px; margin-bottom: 4px;
} }
.assiduite { .assiduite {
position: absolute; position: absolute;
top: 20px; top: 20px;
cursor: pointer; cursor: pointer;
border-radius: 4px; border-radius: 4px;
z-index: 10; z-index: 10;
height: 100px; height: 100px;
padding: 4px; padding: 4px;
} }
.assiduite-info { .assiduite-info {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
justify-content: space-between; justify-content: space-between;
} }
.assiduite-id, .assiduite-id,
.assiduite-period, .assiduite-period,
.assiduite-state, .assiduite-state,
.assiduite-user_id { .assiduite-user_id {
font-size: 12px; font-size: 12px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
text-align: center; text-align: center;
} }
.assiduites-container { .assiduites-container {
min-height: 20px; min-height: 20px;
height: calc(50% - 60px); height: calc(50% - 60px);
/* Augmentation de la hauteur du conteneur des assiduités */ /* Augmentation de la hauteur du conteneur des assiduités */
position: relative; position: relative;
margin-bottom: 10px; margin-bottom: 10px;
} }
.action-buttons { .action-buttons {
position: absolute; position: absolute;
text-align: center; text-align: center;
display: flex; display: flex;
justify-content: space-evenly; justify-content: space-evenly;
align-items: center; align-items: center;
height: 60px; height: 60px;
width: 100%; width: 100%;
bottom: 5%; bottom: 5%;
} }
/* Ajout de la classe CSS pour la bordure en pointillés */ /* Ajout de la classe CSS pour la bordure en pointillés */
.assiduite.selected { .assiduite.selected {
border: 2px dashed black; border: 2px dashed black;
} }
.assiduite-special { .assiduite-special {
height: 120px; height: 120px;
position: absolute; position: absolute;
z-index: 5; z-index: 5;
border: 2px solid #000; border: 2px solid #000;
background-color: rgba(36, 36, 36, 0.25); background-color: rgba(36, 36, 36, 0.25);
background-image: repeating-linear-gradient(135deg, transparent, transparent 5px, rgba(81, 81, 81, 0.61) 5px, rgba(81, 81, 81, 0.61) 10px); background-image: repeating-linear-gradient(
border-radius: 5px; 135deg,
transparent,
transparent 5px,
rgba(81, 81, 81, 0.61) 5px,
rgba(81, 81, 81, 0.61) 10px
);
border-radius: 5px;
} }
/*<== Info sur l'assiduité sélectionnée ==>*/ /*<== Info sur l'assiduité sélectionnée ==>*/
.modal-assiduite-content { .modal-assiduite-content {
background-color: #fefefe; background-color: #fefefe;
margin: 5% auto; margin: 5% auto;
padding: 20px; padding: 20px;
border: 1px solid #888; border: 1px solid #888;
width: max-content; width: max-content;
position: relative; position: relative;
border-radius: 10px; border-radius: 10px;
display: none; display: none;
} }
.modal-assiduite-content.show { .modal-assiduite-content.show {
display: block; display: block;
} }
.modal-assiduite-content .infos { .modal-assiduite-content .infos {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-evenly; justify-content: space-evenly;
align-items: flex-start; align-items: flex-start;
} }
/*<=== Mass Action ==>*/ /*<=== Mass Action ==>*/
.mass-selection { .mass-selection {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
width: 100%; width: 100%;
margin: 2% 0; margin: 2% 0;
} }
.mass-selection span { .mass-selection span {
margin: 0 1%; margin: 0 1%;
} }
.mass-selection .rbtn { .mass-selection .rbtn {
background-color: transparent; background-color: transparent;
cursor: pointer; cursor: pointer;
} }
/*<== Loader ==> */ /*<== Loader ==> */
.loader-container { .loader-container {
display: none; display: none;
/* Cacher le loader par défaut */ /* Cacher le loader par défaut */
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
/* Fond semi-transparent pour bloquer les clics */ /* Fond semi-transparent pour bloquer les clics */
z-index: 9999; z-index: 9999;
/* Placer le loader au-dessus de tout le contenu */ /* Placer le loader au-dessus de tout le contenu */
} }
.loader { .loader {
border: 6px solid #f3f3f3; border: 6px solid #f3f3f3;
border-radius: 50%; border-radius: 50%;
border-top: 6px solid var(--color-primary); border-top: 6px solid var(--color-primary);
width: 60px; width: 60px;
height: 60px; height: 60px;
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
animation: spin 2s linear infinite; animation: spin 2s linear infinite;
} }
@keyframes spin { @keyframes spin {
0% { 0% {
transform: translate(-50%, -50%) rotate(0deg); transform: translate(-50%, -50%) rotate(0deg);
} }
100% { 100% {
transform: translate(-50%, -50%) rotate(360deg); transform: translate(-50%, -50%) rotate(360deg);
} }
} }
.fieldsplit { .fieldsplit {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
} }
.fieldsplit legend { .fieldsplit legend {
margin: 0; margin: 0;
} }
#page-assiduite-content { #page-assiduite-content {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 5%; gap: 5%;
flex-direction: column; flex-direction: column;
} }
#page-assiduite-content>* { #page-assiduite-content > * {
margin: 1.5% 0; margin: 1.5% 0;
} }
.rouge { .rouge {
color: var(--color-error); color: var(--color-error);
} }
.legende { .legende {
border: 1px dashed #333; border: 1px dashed #333;
width: 75%; width: 75%;
padding: 20px; padding: 20px;
} }
.order { .order {
background-image: url(../icons/sort.svg); background-image: url(../icons/sort.svg);
} }
.filter { .filter {
background-image: url(../icons/filter.svg); background-image: url(../icons/filter.svg);
} }
.download { .download {
background-image: url(../icons/download.svg); background-image: url(../icons/download.svg);
} }
.iconline { .iconline {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
gap: min(2%, 15px); gap: min(2%, 15px);
align-items: center; align-items: center;
} }
[name='destroyFile'] { [name="destroyFile"] {
-webkit-appearance: none; -webkit-appearance: none;
appearance: none; appearance: none;
cursor: pointer; cursor: pointer;
background-image: url(../icons/trash.svg); background-image: url(../icons/trash.svg);
} }
[name='destroyFile']:checked { [name="destroyFile"]:checked {
background-image: url(../icons/remove_circle.svg); background-image: url(../icons/remove_circle.svg);
} }
.icon { .icon {
display: block; display: block;
width: 24px; width: 24px;
height: 24px; height: 24px;
outline: none !important; outline: none !important;
border: none !important; border: none !important;
cursor: pointer; cursor: pointer;
margin: 0 2px !important; margin: 0 2px !important;
} }
.icon:focus { .icon:focus {
outline: none; outline: none;
border: none; border: none;
} }
#forcemodule { #forcemodule {
border-radius: 8px; border-radius: 8px;
background: var(--color-error); background: var(--color-error);
max-width: fit-content; max-width: fit-content;
padding: 5px; padding: 5px;
color: white; color: white;
} }
.demo { .demo {
width: 23px; width: 23px;
height: 13px; height: 13px;
display: inline-block; display: inline-block;
border: solid 1px #333; border: solid 1px #333;
} }
.assi-liste {
border: 1px solid gray;
border-radius: 12px;
padding: 12px;
}
#options-tableau label {
font-weight: normal;
margin-right: 12px;
}

View File

@ -1,13 +1,14 @@
from app.tables import table_builder as tb
from app.models import Identite, Assiduite, Justificatif
from app.auth.models import User
from datetime import datetime from datetime import datetime
from app.scodoc.sco_utils import EtatAssiduite, EtatJustificatif
from flask_sqlalchemy.query import Query, Pagination
from sqlalchemy import union, literal, select, desc
from app import db, g
from flask import url_for from flask import url_for
from app import log from flask_sqlalchemy.query import Pagination, Query
from sqlalchemy import desc, literal, union
from app import db, g
from app.auth.models import User
from app.models import Assiduite, Identite, Justificatif
from app.scodoc.sco_utils import EtatAssiduite, EtatJustificatif, to_bool
from app.tables import table_builder as tb
class ListeAssiJusti(tb.Table): class ListeAssiJusti(tb.Table):
@ -21,9 +22,9 @@ class ListeAssiJusti(tb.Table):
def __init__( def __init__(
self, self,
table_data: "Data", table_data: "AssiJustifData",
filtre: "Filtre" = None, filtre: "AssiFiltre" = None,
options: "Options" = None, options: "AssiDisplayOptions" = None,
**kwargs, **kwargs,
) -> None: ) -> None:
""" """
@ -33,12 +34,12 @@ class ListeAssiJusti(tb.Table):
filtre (Filtre, optional): Filtrage des objets à afficher. Defaults to None. filtre (Filtre, optional): Filtrage des objets à afficher. Defaults to None.
page (int, optional): numéro de page de la pagination. Defaults to 1. page (int, optional): numéro de page de la pagination. Defaults to 1.
""" """
self.table_data: "Data" = table_data self.table_data: "AssiJustifData" = table_data
# Gestion du filtre, par défaut un filtre vide # Gestion du filtre, par défaut un filtre vide
self.filtre = filtre if filtre is not None else Filtre() self.filtre = filtre if filtre is not None else AssiFiltre()
# Gestion des options, par défaut un objet Options vide # Gestion des options, par défaut un objet Options vide
self.options = options if options is not None else Options() self.options = options if options is not None else AssiDisplayOptions()
self.total_page: int = None self.total_page: int = None
@ -383,7 +384,7 @@ class RowAssiJusti(tb.Row):
self.add_cell("actions", "Actions", "&ensp;".join(html), no_excel=True) self.add_cell("actions", "Actions", "&ensp;".join(html), no_excel=True)
class Filtre: class AssiFiltre:
""" """
Classe représentant le filtrage qui sera appliqué aux objets Classe représentant le filtrage qui sera appliqué aux objets
du Tableau `ListeAssiJusti` du Tableau `ListeAssiJusti`
@ -475,8 +476,8 @@ class Filtre:
return self.filtres.get("type_obj", 0) return self.filtres.get("type_obj", 0)
class Options: class AssiDisplayOptions:
VRAI = ["on", "true", "t", "v", "vrai", True, 1] "Options pour affichage tableau"
def __init__( def __init__(
self, self,
@ -494,17 +495,18 @@ class Options:
if self.nb_ligne_page is not None: if self.nb_ligne_page is not None:
self.nb_ligne_page = min(nb_ligne_page, ListeAssiJusti.MAX_PAR_PAGE) self.nb_ligne_page = min(nb_ligne_page, ListeAssiJusti.MAX_PAR_PAGE)
self.show_pres: bool = show_pres in Options.VRAI self.show_pres = to_bool(show_pres)
self.show_reta: bool = show_reta in Options.VRAI self.show_reta = to_bool(show_reta)
self.show_desc: bool = show_desc in Options.VRAI self.show_desc = to_bool(show_desc)
self.show_etu: bool = show_etu in Options.VRAI self.show_etu = to_bool(show_etu)
self.show_actions: bool = show_actions in Options.VRAI self.show_actions = to_bool(show_actions)
self.show_module: bool = show_module in Options.VRAI self.show_module = to_bool(show_module)
def remplacer(self, **kwargs): def remplacer(self, **kwargs):
"Positionnne options booléennes selon arguments"
for k, v in kwargs.items(): for k, v in kwargs.items():
if k.startswith("show_"): if k.startswith("show_"):
setattr(self, k, v in Options.VRAI) setattr(self, k, to_bool(v))
elif k in ["page", "nb_ligne_page"]: elif k in ["page", "nb_ligne_page"]:
setattr(self, k, int(v)) setattr(self, k, int(v))
if k == "nb_ligne_page": if k == "nb_ligne_page":
@ -513,7 +515,9 @@ class Options:
) )
class Data: class AssiJustifData:
"Les assiduités et justificatifs"
def __init__( def __init__(
self, assiduites_query: Query = None, justificatifs_query: Query = None self, assiduites_query: Query = None, justificatifs_query: Query = None
): ):
@ -521,8 +525,8 @@ class Data:
self.justificatifs_query: Query = justificatifs_query self.justificatifs_query: Query = justificatifs_query
@staticmethod @staticmethod
def from_etudiants(*etudiants: Identite) -> "Data": def from_etudiants(*etudiants: Identite) -> "AssiJustifData":
data = Data() data = AssiJustifData()
data.assiduites_query = Assiduite.query.filter( data.assiduites_query = Assiduite.query.filter(
Assiduite.etudid.in_([e.etudid for e in etudiants]) Assiduite.etudid.in_([e.etudid for e in etudiants])
) )

View File

@ -63,7 +63,7 @@
</fieldset> </fieldset>
</section> </section>
<section class="liste"> <section class="assi-liste">
{{tableau | safe }} {{tableau | safe }}
</section> </section>

View File

@ -55,7 +55,7 @@
</fieldset> </fieldset>
</section> </section>
<section class="liste"> <section class="assi-liste">
{{tableau | safe }} {{tableau | safe }}
</section> </section>
@ -242,4 +242,4 @@
document.getElementById("justi_date_fin").valueAsObject = { time: assi_evening } document.getElementById("justi_date_fin").valueAsObject = { time: assi_evening }
} }
</script> </script>
{% endblock pageContent %} {% endblock pageContent %}

View File

@ -1,50 +1,41 @@
<hr>
<div> <div>
<h3>Options</h3> <div class="sco_box_title">Évènements enregistrés pour cet étudiant</div>
<div id="options-tableau"> <div id="options-tableau">
{% if afficher_options != false %} {% if afficher_options != false %}
<label for="show_pres">afficher les présences</label> <input type="checkbox" id="show_pres" name="show_pres"
{% if options.show_pres %} onclick="updateTableau()" {{'checked' if options.show_pres else ''}}>
<input type="checkbox" id="show_pres" name="show_pres" checked> <label for="show_pres">afficher les présences</label>
{% else %}
<input type="checkbox" id="show_pres" name="show_pres">
{% endif %}
<label for="show_reta">afficher les retards</label> <input type="checkbox" id="show_reta" name="show_reta"
{% if options.show_reta %} onclick="updateTableau()" {{'checked' if options.show_reta else ''}}>
<input type="checkbox" id="show_reta" name="show_reta" checked> <label for="show_reta">afficher les retards</label>
{% else %}
<input type="checkbox" id="show_reta" name="show_reta"> <input type="checkbox" id="show_desc" name="show_desc"
onclick="updateTableau()" {{'checked' if options.show_desc else ''}}>
<label for="with_desc">afficher les descriptions</label>
<a style="margin-left:32px;" href="{{request.url}}&fmt=xlsx">{{scu.ICON_XLS|safe}}</a>
<br>
{% endif %} {% endif %}
<label for="with_desc">afficher les descriptions</label> <label for="nb_ligne_page">Nombre de lignes par page : </label>
{% if options.show_desc %} <input type="number" name="nb_ligne_page" id="nb_ligne_page"
<input type="checkbox" id="show_desc" name="show_desc" checked> size="4" step="25" min="10" value="{{options.nb_ligne_page}}"
{% else %} onchange="updateTableau()"
<input type="checkbox" id="show_desc" name="show_desc"> >
{% endif %}
<br>
{% endif %}
<label for="nb_ligne_page">Nombre de ligne par page : </label>
<input type="number" name="nb_ligne_page" id="nb_ligne_page" value="{{options.nb_ligne_page}}">
<label for="n_page">Page n°</label> <label for="n_page">Page n°</label>
<select name="n_page" id="n_page"> <select name="n_page" id="n_page">
{% for n in range(1,total_pages+1) %} {% for n in range(1,total_pages+1) %}
{% if n == options.page %} <option value="{{n}}" {{'selected' if n == options.page else ''}}>{{n}}</option>
<option value="{{n}}" selected>{{n}}</option>
{% else %}
<option value="{{n}}">{{n}}</option>
{% endif %}
{% endfor %} {% endfor %}
</select> </select>
<br> <br>
<button onclick="updateTableau()">valider</button>
<a style="margin-left:32px;" href="{{request.url}}&fmt=xlsx">{{scu.ICON_XLS|safe}}</a>
</div> </div>
</div> </div>
{{tableau | safe}} {{table.html() | safe}}
<script> <script>
@ -60,8 +51,11 @@
url.searchParams.set(el.name, el.value) url.searchParams.set(el.name, el.value)
} }
}) })
if (!url.href.endsWith("#options-tableau")) {
location.href = url.href; location.href = url.href + "#options-tableau";
} else {
location.href = url.href;
}
} }
</script> </script>
@ -70,4 +64,4 @@
.small-font { .small-font {
font-size: 9pt; font-size: 9pt;
} }
</style> </style>

View File

@ -28,7 +28,7 @@ import datetime
import re import re
from flask import g, request, render_template, flash from flask import g, request, render_template, flash
from flask import abort, url_for, redirect from flask import abort, url_for, redirect, Response
from flask_login import current_user from flask_login import current_user
from app import db from app import db
@ -255,19 +255,17 @@ def signal_assiduites_etud():
Args: Args:
etudid (int): l'identifiant de l'étudiant etudid (int): l'identifiant de l'étudiant
date_deb, date_fin: heures début et fin (ISO sans timezone)
moduleimpl_id
evaluation_id
saisie_eval : si présent, mode "évaluation"
Returns: Returns:
str: l'html généré str: l'html généré
""" """
# Récupération de l'étudiant concerné
etudid = request.args.get("etudid", -1) etudid = request.args.get("etudid", -1)
etud: Identite = Identite.query.get_or_404(etudid) etud = Identite.get_etud(etudid)
if etud.dept_id != g.scodoc_dept_id:
abort(404, "étudiant inexistant dans ce département")
# gestion évaluations (Appel à la page depuis les évaluations)
# Gestion évaluations (appel à la page depuis les évaluations)
saisie_eval: bool = request.args.get("saisie_eval") is not None saisie_eval: bool = request.args.get("saisie_eval") is not None
date_deb: str = request.args.get("date_deb") date_deb: str = request.args.get("date_deb")
date_fin: str = request.args.get("date_fin") date_fin: str = request.args.get("date_fin")
@ -298,17 +296,17 @@ def signal_assiduites_etud():
], ],
) )
tableau = _preparer_tableau( is_html, tableau = _prepare_tableau(
liste_assi.Data.from_etudiants( liste_assi.AssiJustifData.from_etudiants(
etud, etud,
), ),
filename=f"assiduite-{etudid}", filename=f"assiduite-{etudid}",
afficher_etu=False, afficher_etu=False,
filtre=liste_assi.Filtre(type_obj=1), filtre=liste_assi.AssiFiltre(type_obj=1),
options=liste_assi.Options(show_module=True), options=liste_assi.AssiDisplayOptions(show_module=True),
) )
if not tableau[0]: if not is_html:
return tableau[1] return tableau
# Génération de la page # Génération de la page
return HTMLBuilder( return HTMLBuilder(
header, header,
@ -328,7 +326,7 @@ def signal_assiduites_etud():
etud=etud, etud=etud,
redirect_url=redirect_url, redirect_url=redirect_url,
moduleimpl_id=moduleimpl_id, moduleimpl_id=moduleimpl_id,
tableau=tableau[1], tableau=tableau,
), ),
# render_template( # render_template(
# "assiduites/pages/signal_assiduites_etud.j2", # "assiduites/pages/signal_assiduites_etud.j2",
@ -390,14 +388,14 @@ def liste_assiduites_etud():
"css/assiduites.css", "css/assiduites.css",
], ],
) )
tableau = _preparer_tableau( tableau = _prepare_tableau(
liste_assi.Data.from_etudiants( liste_assi.AssiJustifData.from_etudiants(
etud, etud,
), ),
filename=f"assiduites-justificatifs-{etudid}", filename=f"assiduites-justificatifs-{etudid}",
afficher_etu=False, afficher_etu=False,
filtre=liste_assi.Filtre(type_obj=0), filtre=liste_assi.AssiFiltre(type_obj=0),
options=liste_assi.Options(show_module=True), options=liste_assi.AssiDisplayOptions(show_module=True),
) )
if not tableau[0]: if not tableau[0]:
return tableau[1] return tableau[1]
@ -505,14 +503,14 @@ def ajout_justificatif_etud():
], ],
) )
tableau = _preparer_tableau( tableau = _prepare_tableau(
liste_assi.Data.from_etudiants( liste_assi.AssiJustifData.from_etudiants(
etud, etud,
), ),
filename=f"justificatifs-{etudid}", filename=f"justificatifs-{etudid}",
afficher_etu=False, afficher_etu=False,
filtre=liste_assi.Filtre(type_obj=2), filtre=liste_assi.AssiFiltre(type_obj=2),
options=liste_assi.Options(show_module=False, show_desc=True), options=liste_assi.AssiDisplayOptions(show_module=False, show_desc=True),
afficher_options=False, afficher_options=False,
) )
if not tableau[0]: if not tableau[0]:
@ -1062,30 +1060,25 @@ def visu_assi_group():
) )
def _preparer_tableau( def _prepare_tableau(
data: liste_assi.Data, data: liste_assi.AssiJustifData,
filename: str = "tableau-assiduites", filename: str = "tableau-assiduites",
afficher_etu: bool = True, afficher_etu: bool = True,
filtre: liste_assi.Filtre = None, filtre: liste_assi.AssiFiltre = None,
options: liste_assi.Options = None, options: liste_assi.AssiDisplayOptions = None,
afficher_options: bool = True, afficher_options: bool = True,
) -> tuple[bool, "Response"]: ) -> tuple[bool, Response | str]:
""" """
_preparer_tableau prépare un tableau d'assiduités / justificatifs Prépare un tableau d'assiduités / justificatifs
Cette fontion récupère dans la requête les arguments : Cette fonction récupère dans la requête les arguments :
valeurs possibles des booléens vrais ["on", "true", "t", "v", "vrai", True, 1]
toute autre valeur est considérée comme fausse.
show_pres : bool -> Affiche les présences, par défaut False show_pres : bool -> Affiche les présences, par défaut False
show_reta : bool -> Affiche les retard, par défaut False show_reta : bool -> Affiche les retard, par défaut False
show_desc : bool -> Affiche les descriptions, par défaut False show_desc : bool -> Affiche les descriptions, par défaut False
Returns: Returns:
tuple[bool | "Reponse" ]: tuple[bool | Reponse|str ]:
- bool : Vrai si la réponse est du Text/HTML - bool : Vrai si la réponse est du Text/HTML
- Reponse : du Text/HTML ou Une Reponse (téléchargement fichier) - Reponse : du Text/HTML ou Une Reponse (téléchargement fichier)
""" """
@ -1111,7 +1104,7 @@ def _preparer_tableau(
fmt = request.args.get("fmt", "html") fmt = request.args.get("fmt", "html")
if options is None: if options is None:
options: liste_assi.Options = liste_assi.Options() options: liste_assi.AssiDisplayOptions = liste_assi.AssiDisplayOptions()
options.remplacer( options.remplacer(
page=page_number, page=page_number,
@ -1138,7 +1131,7 @@ def _preparer_tableau(
return True, render_template( return True, render_template(
"assiduites/widgets/tableau.j2", "assiduites/widgets/tableau.j2",
tableau=table.html(), table=table,
total_pages=table.total_pages, total_pages=table.total_pages,
options=options, options=options,
afficher_options=afficher_options, afficher_options=afficher_options,
@ -1509,11 +1502,7 @@ def signal_evaluation_abs(etudid: int = None, evaluation_id: int = None):
Alors l'absence sera sur la période de l'évaluation Alors l'absence sera sur la période de l'évaluation
Sinon L'utilisateur sera redirigé vers la page de saisie des absences de l'étudiant Sinon L'utilisateur sera redirigé vers la page de saisie des absences de l'étudiant
""" """
etud = Identite.get_etud(etudid)
# Récupération de l'étudiant concerné
etud: Identite = Identite.query.get_or_404(etudid)
if etud.dept_id != g.scodoc_dept_id:
abort(404, "étudiant inexistant dans ce département")
# Récupération de l'évaluation concernée # Récupération de l'évaluation concernée
evaluation: Evaluation = Evaluation.query.get_or_404(evaluation_id) evaluation: Evaluation = Evaluation.query.get_or_404(evaluation_id)
@ -1549,7 +1538,9 @@ def signal_evaluation_abs(etudid: int = None, evaluation_id: int = None):
# En cas d'erreur # En cas d'erreur
msg: str = see.args[0] msg: str = see.args[0]
if "Duplication" in msg: if "Duplication" in msg:
msg = "Une autre assiduité concerne déjà cette période. En cliquant sur continuer vous serez redirigé vers la page de saisie des assiduités de l'étudiant." msg = """Une autre saisie concerne déjà cette période.
En cliquant sur continuer vous serez redirigé vers la page de
saisie des assiduités de l'étudiant."""
dest: str = url_for( dest: str = url_for(
"assiduites.signal_assiduites_etud", "assiduites.signal_assiduites_etud",
etudid=etudid, etudid=etudid,