forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -72,7 +72,8 @@ class Assiduite(db.Model):
|
||||
if format_api:
|
||||
etat = EtatAssiduite.inverse().get(self.etat).name
|
||||
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:
|
||||
username = "Non renseigné"
|
||||
else:
|
||||
@ -224,7 +225,7 @@ class Justificatif(db.Model):
|
||||
if format_api:
|
||||
etat = EtatJustificatif.inverse().get(self.etat).name
|
||||
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:
|
||||
username = "Non renseigné"
|
||||
else:
|
||||
|
@ -65,12 +65,12 @@ class Trace:
|
||||
file.write("\n".join(lines))
|
||||
|
||||
def get_trace(
|
||||
self, fnames: list[str] = ()
|
||||
self, fnames: list[str] = None
|
||||
) -> dict[str, list[datetime, datetime, str]]:
|
||||
"""Récupère la trace pour les noms de 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
|
||||
|
||||
traced: dict = {}
|
||||
@ -187,8 +187,9 @@ class JustificatifArchiver(BaseArchiver):
|
||||
filenames = self.list_archive(archive_id)
|
||||
trace: Trace = Trace(self.get_obj_dir(etudid))
|
||||
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):
|
||||
"""
|
||||
|
@ -376,13 +376,15 @@ def test_list_justificatifs(api_admin_headers):
|
||||
|
||||
res: list = GET("/justificatif/1/list", api_admin_headers)
|
||||
|
||||
assert isinstance(res, list)
|
||||
assert len(res) == 2
|
||||
assert isinstance(res, dict)
|
||||
assert len(res["filenames"]) == 2
|
||||
assert res["total"] == 2
|
||||
|
||||
res: list = GET("/justificatif/2/list", api_admin_headers)
|
||||
|
||||
assert isinstance(res, list)
|
||||
assert len(res) == 0
|
||||
assert isinstance(res, dict)
|
||||
assert len(res["filenames"]) == 0
|
||||
assert res["total"] == 0
|
||||
|
||||
# Mauvais fonctionnement
|
||||
|
||||
@ -439,7 +441,9 @@ def test_remove_justificatif(api_admin_headers):
|
||||
"/justificatif/1/remove", {"remove": "all"}, api_admin_headers
|
||||
)
|
||||
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(
|
||||
"/justificatif/2/remove",
|
||||
@ -447,7 +451,9 @@ def test_remove_justificatif(api_admin_headers):
|
||||
api_admin_headers,
|
||||
)
|
||||
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(
|
||||
"/justificatif/2/remove",
|
||||
@ -455,7 +461,9 @@ def test_remove_justificatif(api_admin_headers):
|
||||
api_admin_headers,
|
||||
)
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user