forked from ScoDoc/ScoDoc
Assiduites : edit assi fix est_just #717
This commit is contained in:
parent
6a5c594e68
commit
d0159df665
@ -27,7 +27,7 @@ from app.models import (
|
|||||||
Justificatif,
|
Justificatif,
|
||||||
)
|
)
|
||||||
from flask_sqlalchemy.query import Query
|
from flask_sqlalchemy.query import Query
|
||||||
from app.models.assiduites import get_assiduites_justif
|
from app.models.assiduites import get_assiduites_justif, get_justifs_from_date
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
from app.scodoc.sco_utils import json_error
|
from app.scodoc.sco_utils import json_error
|
||||||
@ -851,12 +851,20 @@ def _edit_singular(assiduite_unique, data):
|
|||||||
assiduite_unique.desc = desc
|
assiduite_unique.desc = desc
|
||||||
|
|
||||||
# Cas 4 : est_just
|
# Cas 4 : est_just
|
||||||
est_just = data.get("est_just")
|
if assiduite_unique.etat == scu.EtatAssiduite.PRESENT:
|
||||||
if est_just is not None:
|
assiduite_unique.est_just = False
|
||||||
if not isinstance(est_just, bool):
|
else:
|
||||||
errors.append("param 'est_just' : booléen non reconnu")
|
assiduite_unique.est_just = (
|
||||||
else:
|
len(
|
||||||
assiduite_unique.est_just = est_just
|
get_justifs_from_date(
|
||||||
|
assiduite_unique.etudiant.id,
|
||||||
|
assiduite_unique.date_debut,
|
||||||
|
assiduite_unique.date_fin,
|
||||||
|
valid=True,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
> 0
|
||||||
|
)
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
err: str = ", ".join(errors)
|
err: str = ", ".join(errors)
|
||||||
|
@ -134,7 +134,10 @@ class Assiduite(db.Model):
|
|||||||
|
|
||||||
if not est_just:
|
if not est_just:
|
||||||
est_just = (
|
est_just = (
|
||||||
len(_get_assiduites_justif(etud.etudid, date_debut, date_fin)) > 0
|
len(
|
||||||
|
get_justifs_from_date(etud.etudid, date_debut, date_fin, valid=True)
|
||||||
|
)
|
||||||
|
> 0
|
||||||
)
|
)
|
||||||
|
|
||||||
if moduleimpl is not None:
|
if moduleimpl is not None:
|
||||||
@ -375,16 +378,23 @@ def compute_assiduites_justified(
|
|||||||
|
|
||||||
def get_assiduites_justif(assiduite_id: int, long: bool):
|
def get_assiduites_justif(assiduite_id: int, long: bool):
|
||||||
assi: Assiduite = Assiduite.query.get_or_404(assiduite_id)
|
assi: Assiduite = Assiduite.query.get_or_404(assiduite_id)
|
||||||
return _get_assiduites_justif(assi.etudid, assi.date_debut, assi.date_fin, long)
|
return get_justifs_from_date(assi.etudid, assi.date_debut, assi.date_fin, long)
|
||||||
|
|
||||||
|
|
||||||
def _get_assiduites_justif(
|
def get_justifs_from_date(
|
||||||
etudid: int, date_debut: datetime, date_fin: datetime, long: bool = False
|
etudid: int,
|
||||||
|
date_debut: datetime,
|
||||||
|
date_fin: datetime,
|
||||||
|
long: bool = False,
|
||||||
|
valid: bool = False,
|
||||||
):
|
):
|
||||||
justifs: Justificatif = Justificatif.query.filter(
|
justifs: Query = Justificatif.query.filter(
|
||||||
Justificatif.etudid == etudid,
|
Justificatif.etudid == etudid,
|
||||||
Justificatif.date_debut <= date_debut,
|
Justificatif.date_debut <= date_debut,
|
||||||
Justificatif.date_fin >= date_fin,
|
Justificatif.date_fin >= date_fin,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if valid:
|
||||||
|
justifs = justifs.filter(Justificatif.etat == EtatJustificatif.VALIDE)
|
||||||
|
|
||||||
return [j.justif_id if not long else j.to_dict(True) for j in justifs]
|
return [j.justif_id if not long else j.to_dict(True) for j in justifs]
|
||||||
|
@ -239,7 +239,7 @@
|
|||||||
edit = setModuleImplId(edit, module);
|
edit = setModuleImplId(edit, module);
|
||||||
|
|
||||||
fullEditAssiduites(data.assiduite_id, edit, () => {
|
fullEditAssiduites(data.assiduite_id, edit, () => {
|
||||||
try { getAllAssiduitesFromEtud(etudid, assiduiteCallBack) } catch (_) { }
|
loadAll();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user