Merge branch 'main96' of https://scodoc.org/git/iziram/ScoDoc
This commit is contained in:
commit
f25afd6e23
@ -12,11 +12,14 @@ from app.scodoc.sco_archives import BaseArchiver
|
|||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
from app.scodoc.sco_utils import is_iso_formated
|
from app.scodoc.sco_utils import is_iso_formated
|
||||||
|
|
||||||
|
from app import log
|
||||||
|
|
||||||
|
|
||||||
class Trace:
|
class Trace:
|
||||||
"""gestionnaire de la trace des fichiers justificatifs"""
|
"""gestionnaire de la trace des fichiers justificatifs"""
|
||||||
|
|
||||||
def __init__(self, path: str) -> None:
|
def __init__(self, path: str) -> None:
|
||||||
|
log(f"init Trace {path}")
|
||||||
self.path: str = path + "/_trace.csv"
|
self.path: str = path + "/_trace.csv"
|
||||||
self.content: dict[str, list[datetime, datetime, str]] = {}
|
self.content: dict[str, list[datetime, datetime, str]] = {}
|
||||||
self.import_from_file()
|
self.import_from_file()
|
||||||
@ -45,7 +48,7 @@ class Trace:
|
|||||||
if fname in modes:
|
if fname in modes:
|
||||||
continue
|
continue
|
||||||
traced: list[datetime, datetime, str] = self.content.get(fname, False)
|
traced: list[datetime, datetime, str] = self.content.get(fname, False)
|
||||||
if not traced:
|
if not traced or mode == "entry":
|
||||||
self.content[fname] = [None, None, None]
|
self.content[fname] = [None, None, None]
|
||||||
traced = self.content[fname]
|
traced = self.content[fname]
|
||||||
|
|
||||||
@ -123,8 +126,8 @@ class JustificatifArchiver(BaseArchiver):
|
|||||||
)
|
)
|
||||||
|
|
||||||
fname: str = self.store(archive_id, filename, data, dept_id=etud.dept_id)
|
fname: str = self.store(archive_id, filename, data, dept_id=etud.dept_id)
|
||||||
|
log(f"obj_dir {self.get_obj_dir(etud.id, dept_id=etud.dept_id)} | {archive_id}")
|
||||||
trace = Trace(self.get_obj_dir(etud.id, dept_id=etud.dept_id))
|
trace = Trace(archive_id)
|
||||||
trace.set_trace(fname, mode="entry")
|
trace.set_trace(fname, mode="entry")
|
||||||
if user_id is not None:
|
if user_id is not None:
|
||||||
trace.set_trace(fname, mode="user_id", current_user=user_id)
|
trace.set_trace(fname, mode="user_id", current_user=user_id)
|
||||||
@ -162,13 +165,13 @@ class JustificatifArchiver(BaseArchiver):
|
|||||||
|
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
if has_trace:
|
if has_trace:
|
||||||
trace = Trace(self.get_obj_dir(etud.id, dept_id=etud.dept_id))
|
trace = Trace(archive_id)
|
||||||
trace.set_trace(filename, mode="delete")
|
trace.set_trace(filename, mode="delete")
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if has_trace:
|
if has_trace:
|
||||||
trace = Trace(self.get_obj_dir(etud.id, dept_id=etud.dept_id))
|
trace = Trace(archive_id)
|
||||||
trace.set_trace(
|
trace.set_trace(
|
||||||
*self.list_archive(archive_id, dept_id=etud.dept_id), mode="delete"
|
*self.list_archive(archive_id, dept_id=etud.dept_id), mode="delete"
|
||||||
)
|
)
|
||||||
@ -190,7 +193,7 @@ class JustificatifArchiver(BaseArchiver):
|
|||||||
archive_id = self.get_id_from_name(etud.id, archive_name, dept_id=etud.dept_id)
|
archive_id = self.get_id_from_name(etud.id, archive_name, dept_id=etud.dept_id)
|
||||||
|
|
||||||
filenames = self.list_archive(archive_id, dept_id=etud.dept_id)
|
filenames = self.list_archive(archive_id, dept_id=etud.dept_id)
|
||||||
trace: Trace = Trace(self.get_obj_dir(etud.id, dept_id=etud.dept_id))
|
trace: Trace = Trace(archive_id)
|
||||||
traced = trace.get_trace(filenames)
|
traced = trace.get_trace(filenames)
|
||||||
retour = [(key, value[2]) for key, value in traced.items()]
|
retour = [(key, value[2]) for key, value in traced.items()]
|
||||||
|
|
||||||
@ -222,10 +225,3 @@ class JustificatifArchiver(BaseArchiver):
|
|||||||
rmtree(self.root, ignore_errors=True)
|
rmtree(self.root, ignore_errors=True)
|
||||||
else:
|
else:
|
||||||
rmtree(os.path.join(self.root, str(dept_id)), ignore_errors=True)
|
rmtree(os.path.join(self.root, str(dept_id)), ignore_errors=True)
|
||||||
|
|
||||||
def get_trace( # XXX inutilisée ?
|
|
||||||
self, etud: Identite, *fnames: str
|
|
||||||
) -> dict[str, list[datetime, datetime]]:
|
|
||||||
"""Récupère la trace des justificatifs de l'étudiant"""
|
|
||||||
trace = Trace(self.get_obj_dir(etud.id, etud.dept_id))
|
|
||||||
return trace.get_trace(fnames)
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{% include "assiduites/widgets/tableau_justi.j2" %}
|
{% include "assiduites/widgets/tableau_justi.j2" %}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="justi-form">
|
<section class="justi-form page">
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="justi-row">
|
<div class="justi-row">
|
||||||
@ -130,7 +130,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fieldsToJustificatif() {
|
function fieldsToJustificatif() {
|
||||||
const field = document.querySelector('.justi-form')
|
const field = document.querySelector('.justi-form.page')
|
||||||
|
|
||||||
const { deb, fin } = getDates()
|
const { deb, fin } = getDates()
|
||||||
|
|
||||||
@ -230,9 +230,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDates() {
|
function getDates() {
|
||||||
if (document.getElementById('justi_journee').checked) {
|
if (document.querySelector('.page #justi_journee').checked) {
|
||||||
const date_str_deb = document.getElementById("justi_date_debut").value
|
const date_str_deb = document.querySelector(".page #justi_date_debut").value
|
||||||
const date_str_fin = document.getElementById("justi_date_debut").value
|
const date_str_fin = document.querySelector(".page #justi_date_debut").value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -243,8 +243,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"deb": document.getElementById("justi_date_debut").value,
|
"deb": document.querySelector(".page #justi_date_debut").value,
|
||||||
"fin": document.getElementById("justi_date_fin").value,
|
"fin": document.querySelector(".page #justi_date_fin").value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,14 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.td[assiduite_id='insc'] * {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.td[assiduite_id='insc']::after {
|
||||||
|
content: "Etudiant non inscrit";
|
||||||
|
}
|
||||||
|
|
||||||
.sticky {
|
.sticky {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
left: 0;
|
left: 0;
|
||||||
@ -278,6 +286,8 @@
|
|||||||
currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm");
|
currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const inscriptionsModule = {};
|
||||||
|
|
||||||
function createColumn(dateStart = "", dateEnd = "", moduleimpl_id = "") {
|
function createColumn(dateStart = "", dateEnd = "", moduleimpl_id = "") {
|
||||||
let table = document.getElementById("studentTable");
|
let table = document.getElementById("studentTable");
|
||||||
let th = document.createElement("div");
|
let th = document.createElement("div");
|
||||||
@ -561,6 +571,8 @@
|
|||||||
const d_debut = moment(inputDeb).tz(TIMEZONE);
|
const d_debut = moment(inputDeb).tz(TIMEZONE);
|
||||||
const d_fin = moment(inputFin).tz(TIMEZONE);
|
const d_fin = moment(inputFin).tz(TIMEZONE);
|
||||||
|
|
||||||
|
const moduleimpl_id = col.querySelector("#moduleimpl_select").value;
|
||||||
|
|
||||||
const periode = {
|
const periode = {
|
||||||
deb: d_debut,
|
deb: d_debut,
|
||||||
fin: d_fin,
|
fin: d_fin,
|
||||||
@ -573,9 +585,12 @@
|
|||||||
});
|
});
|
||||||
setEtatLine(td, "")
|
setEtatLine(td, "")
|
||||||
const etu = td.parentElement.getAttribute('etudid');
|
const etu = td.parentElement.getAttribute('etudid');
|
||||||
|
const inscriptionModule = ["", "autre"].indexOf(moduleimpl_id) !== -1 ? true : checkInscriptionModule(moduleimpl_id, etu);
|
||||||
const conflits = getAssiduitesConflict(etu, periode);
|
const conflits = getAssiduitesConflict(etu, periode);
|
||||||
|
if (!inscriptionModule) {
|
||||||
if (conflits.length == 0) {
|
td.setAttribute('assiduite_id', "insc");
|
||||||
|
}
|
||||||
|
else if (conflits.length == 0) {
|
||||||
td.setAttribute('assiduite_id', "-1");
|
td.setAttribute('assiduite_id', "-1");
|
||||||
} else if (conflits.length == 1 && isConflictSameAsPeriod(conflits[0], periode)) {
|
} else if (conflits.length == 1 && isConflictSameAsPeriod(conflits[0], periode)) {
|
||||||
const assi = conflits[0];
|
const assi = conflits[0];
|
||||||
@ -587,7 +602,6 @@
|
|||||||
const inputs = [...td.querySelectorAll('input')];
|
const inputs = [...td.querySelectorAll('input')];
|
||||||
inputs.forEach((i) => {
|
inputs.forEach((i) => {
|
||||||
i.disabled = true;
|
i.disabled = true;
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -871,7 +885,7 @@
|
|||||||
const { moduleimpl, deb, fin } = getAssiduitesCol(colid, false);
|
const { moduleimpl, deb, fin } = getAssiduitesCol(colid, false);
|
||||||
|
|
||||||
const lines = [...document.querySelectorAll(`[assiduite_id][colid='${colid}']`)].filter((el) => {
|
const lines = [...document.querySelectorAll(`[assiduite_id][colid='${colid}']`)].filter((el) => {
|
||||||
return el.getAttribute('assiduite_id') != "conflit";
|
return ["conflit", "insc"].indexOf(el.getAttribute('assiduite_id')) == -1;
|
||||||
})
|
})
|
||||||
|
|
||||||
const toCreate = lines.filter((el) => { return el.getAttribute('assiduite_id') == '-1' })
|
const toCreate = lines.filter((el) => { return el.getAttribute('assiduite_id') == '-1' })
|
||||||
@ -1019,6 +1033,25 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkInscriptionModule(moduleimpl_id, etudid) {
|
||||||
|
if (!inscriptionsModule.hasOwnProperty(moduleimpl_id)) {
|
||||||
|
const path = getUrl() + `/api/moduleimpl/${moduleimpl_id}/inscriptions`;
|
||||||
|
sync_get(
|
||||||
|
path,
|
||||||
|
(data, status) => {
|
||||||
|
inscriptionsModule[moduleimpl_id] = data;
|
||||||
|
},
|
||||||
|
(data, status) => {
|
||||||
|
//error
|
||||||
|
console.error(data, status);
|
||||||
|
errorAlert();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const etudsInscrits = inscriptionsModule[moduleimpl_id].map((i) => i.etudid);
|
||||||
|
return etudsInscrits.indexOf(Number(etudid)) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
document.getElementById("addColumn").addEventListener("click", () => {
|
document.getElementById("addColumn").addEventListener("click", () => {
|
||||||
createColumn();
|
createColumn();
|
||||||
|
Loading…
Reference in New Issue
Block a user