forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -72,7 +72,8 @@ class Assiduite(db.Model):
|
|||||||
if format_api:
|
if format_api:
|
||||||
etat = EtatAssiduite.inverse().get(self.etat).name
|
etat = EtatAssiduite.inverse().get(self.etat).name
|
||||||
if self.user_id is not None:
|
if self.user_id is not None:
|
||||||
user: User = User.query.get(self.user_id)
|
user: User = db.session.get(User, self.user_id)
|
||||||
|
|
||||||
if user is None:
|
if user is None:
|
||||||
username = "Non renseigné"
|
username = "Non renseigné"
|
||||||
else:
|
else:
|
||||||
@ -224,7 +225,7 @@ class Justificatif(db.Model):
|
|||||||
if format_api:
|
if format_api:
|
||||||
etat = EtatJustificatif.inverse().get(self.etat).name
|
etat = EtatJustificatif.inverse().get(self.etat).name
|
||||||
if self.user_id is not None:
|
if self.user_id is not None:
|
||||||
user: User = User.query.get(self.user_id)
|
user: User = db.session.get(User, self.user_id)
|
||||||
if user is None:
|
if user is None:
|
||||||
username = "Non renseigné"
|
username = "Non renseigné"
|
||||||
else:
|
else:
|
||||||
|
@ -65,12 +65,12 @@ class Trace:
|
|||||||
file.write("\n".join(lines))
|
file.write("\n".join(lines))
|
||||||
|
|
||||||
def get_trace(
|
def get_trace(
|
||||||
self, fnames: list[str] = ()
|
self, fnames: list[str] = None
|
||||||
) -> dict[str, list[datetime, datetime, str]]:
|
) -> dict[str, list[datetime, datetime, str]]:
|
||||||
"""Récupère la trace pour les noms de fichiers.
|
"""Récupère la trace pour les noms de fichiers.
|
||||||
si aucun nom n'est donné, récupère tous les fichiers"""
|
si aucun nom n'est donné, récupère tous les fichiers"""
|
||||||
|
|
||||||
if fnames is None or len(fnames) == 0:
|
if fnames is None:
|
||||||
return self.content
|
return self.content
|
||||||
|
|
||||||
traced: dict = {}
|
traced: dict = {}
|
||||||
@ -187,8 +187,9 @@ class JustificatifArchiver(BaseArchiver):
|
|||||||
filenames = self.list_archive(archive_id)
|
filenames = self.list_archive(archive_id)
|
||||||
trace: Trace = Trace(self.get_obj_dir(etudid))
|
trace: Trace = Trace(self.get_obj_dir(etudid))
|
||||||
traced = trace.get_trace(filenames)
|
traced = trace.get_trace(filenames)
|
||||||
|
retour = [(key, value[2]) for key, value in traced.items()]
|
||||||
|
|
||||||
return [(key, value[2]) for key, value in traced.items()]
|
return retour
|
||||||
|
|
||||||
def get_justificatif_file(self, archive_name: str, etudid: int, filename: str):
|
def get_justificatif_file(self, archive_name: str, etudid: int, filename: str):
|
||||||
"""
|
"""
|
||||||
|
@ -376,13 +376,15 @@ def test_list_justificatifs(api_admin_headers):
|
|||||||
|
|
||||||
res: list = GET("/justificatif/1/list", api_admin_headers)
|
res: list = GET("/justificatif/1/list", api_admin_headers)
|
||||||
|
|
||||||
assert isinstance(res, list)
|
assert isinstance(res, dict)
|
||||||
assert len(res) == 2
|
assert len(res["filenames"]) == 2
|
||||||
|
assert res["total"] == 2
|
||||||
|
|
||||||
res: list = GET("/justificatif/2/list", api_admin_headers)
|
res: list = GET("/justificatif/2/list", api_admin_headers)
|
||||||
|
|
||||||
assert isinstance(res, list)
|
assert isinstance(res, dict)
|
||||||
assert len(res) == 0
|
assert len(res["filenames"]) == 0
|
||||||
|
assert res["total"] == 0
|
||||||
|
|
||||||
# Mauvais fonctionnement
|
# Mauvais fonctionnement
|
||||||
|
|
||||||
@ -439,7 +441,9 @@ def test_remove_justificatif(api_admin_headers):
|
|||||||
"/justificatif/1/remove", {"remove": "all"}, api_admin_headers
|
"/justificatif/1/remove", {"remove": "all"}, api_admin_headers
|
||||||
)
|
)
|
||||||
assert res == {"response": "removed"}
|
assert res == {"response": "removed"}
|
||||||
assert len(GET("/justificatif/1/list", api_admin_headers)) == 0
|
l = GET("/justificatif/1/list", api_admin_headers)
|
||||||
|
assert isinstance(l, dict)
|
||||||
|
assert l["total"] == 0
|
||||||
|
|
||||||
res: dict = POST_JSON(
|
res: dict = POST_JSON(
|
||||||
"/justificatif/2/remove",
|
"/justificatif/2/remove",
|
||||||
@ -447,7 +451,9 @@ def test_remove_justificatif(api_admin_headers):
|
|||||||
api_admin_headers,
|
api_admin_headers,
|
||||||
)
|
)
|
||||||
assert res == {"response": "removed"}
|
assert res == {"response": "removed"}
|
||||||
assert len(GET("/justificatif/2/list", api_admin_headers)) == 1
|
l = GET("/justificatif/2/list", api_admin_headers)
|
||||||
|
assert isinstance(l, dict)
|
||||||
|
assert l["total"] == 1
|
||||||
|
|
||||||
res: dict = POST_JSON(
|
res: dict = POST_JSON(
|
||||||
"/justificatif/2/remove",
|
"/justificatif/2/remove",
|
||||||
@ -455,7 +461,9 @@ def test_remove_justificatif(api_admin_headers):
|
|||||||
api_admin_headers,
|
api_admin_headers,
|
||||||
)
|
)
|
||||||
assert res == {"response": "removed"}
|
assert res == {"response": "removed"}
|
||||||
assert len(GET("/justificatif/2/list", api_admin_headers)) == 0
|
l = GET("/justificatif/2/list", api_admin_headers)
|
||||||
|
assert isinstance(l, dict)
|
||||||
|
assert l["total"] == 0
|
||||||
|
|
||||||
# Mauvais fonctionnement
|
# Mauvais fonctionnement
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user