forked from ScoDoc/ScoDoc
Assiduites : fix trace justificatifs
This commit is contained in:
parent
b8f7037804
commit
0fa1fa36e2
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user