forked from ScoDoc/ScoDoc
Merge branch 'main96' of https://scodoc.org/git/iziram/ScoDoc
This commit is contained in:
commit
6d61b2dd57
@ -1043,7 +1043,6 @@ def signal_evaluation_abs(etudid: int = None, evaluation_id: int = None):
|
|||||||
delta: datetime.timedelta = evaluation.date_fin - evaluation.date_debut
|
delta: datetime.timedelta = evaluation.date_fin - evaluation.date_debut
|
||||||
if delta > datetime.timedelta(days=1):
|
if delta > datetime.timedelta(days=1):
|
||||||
# rediriger vers page saisie
|
# rediriger vers page saisie
|
||||||
flash("Redirection pour saisie abs")
|
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for(
|
url_for(
|
||||||
"assiduites.signal_assiduites_etud",
|
"assiduites.signal_assiduites_etud",
|
||||||
@ -1059,13 +1058,31 @@ def signal_evaluation_abs(etudid: int = None, evaluation_id: int = None):
|
|||||||
|
|
||||||
# créer l'assiduité
|
# créer l'assiduité
|
||||||
|
|
||||||
assiduite_unique: Assiduite = Assiduite.create_assiduite(
|
try:
|
||||||
etud=etud,
|
assiduite_unique: Assiduite = Assiduite.create_assiduite(
|
||||||
date_debut=scu.localize_datetime(evaluation.date_debut),
|
etud=etud,
|
||||||
date_fin=scu.localize_datetime(evaluation.date_fin),
|
date_debut=scu.localize_datetime(evaluation.date_debut),
|
||||||
etat=scu.EtatAssiduite.ABSENT,
|
date_fin=scu.localize_datetime(evaluation.date_fin),
|
||||||
moduleimpl=evaluation.moduleimpl,
|
etat=scu.EtatAssiduite.ABSENT,
|
||||||
)
|
moduleimpl=evaluation.moduleimpl,
|
||||||
|
)
|
||||||
|
except ScoValueError as see:
|
||||||
|
msg: str = see.args[0]
|
||||||
|
|
||||||
|
if "Duplication" in msg:
|
||||||
|
msg = "Une autre assiduité concerne déjà cette période. En cliquant sur continuer vous serez redirigé vers la page de saisie des assiduités de l'étudiant."
|
||||||
|
dest: str = url_for(
|
||||||
|
"assiduites.signal_assiduites_etud",
|
||||||
|
etudid=etudid,
|
||||||
|
evaluation_id=evaluation.id,
|
||||||
|
date_deb=evaluation.date_debut.strftime("%Y-%m-%dT%H:%M:%S"),
|
||||||
|
date_fin=evaluation.date_fin.strftime("%Y-%m-%dT%H:%M:%S"),
|
||||||
|
moduleimpl_id=evaluation.moduleimpl.id,
|
||||||
|
saisie_eval="true",
|
||||||
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
duplication="oui",
|
||||||
|
)
|
||||||
|
raise ScoValueError(msg, dest)
|
||||||
|
|
||||||
db.session.add(assiduite_unique)
|
db.session.add(assiduite_unique)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -11,14 +11,23 @@ import pytest
|
|||||||
|
|
||||||
import app.scodoc.sco_assiduites as scass
|
import app.scodoc.sco_assiduites as scass
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
from app import db
|
from app import db, log
|
||||||
from app.models import Assiduite, FormSemestre, Identite, Justificatif, ModuleImpl
|
from app.models import (
|
||||||
|
Assiduite,
|
||||||
|
FormSemestre,
|
||||||
|
Identite,
|
||||||
|
Justificatif,
|
||||||
|
ModuleImpl,
|
||||||
|
Absence,
|
||||||
|
)
|
||||||
from app.models.assiduites import compute_assiduites_justified
|
from app.models.assiduites import compute_assiduites_justified
|
||||||
|
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
from tests.unit import sco_fake_gen
|
from tests.unit import sco_fake_gen
|
||||||
from tools import downgrade_module, migrate_abs_to_assiduites
|
from tools import downgrade_module, migrate_abs_to_assiduites
|
||||||
|
|
||||||
|
import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
class BiInt(int, scu.BiDirectionalEnum):
|
class BiInt(int, scu.BiDirectionalEnum):
|
||||||
"""Classe pour tester la classe BiDirectionalEnum"""
|
"""Classe pour tester la classe BiDirectionalEnum"""
|
||||||
@ -133,7 +142,7 @@ def test_general(test_client):
|
|||||||
etud_faux_dict = g_fake.create_etud(code_nip=None, prenom="etudfaux")
|
etud_faux_dict = g_fake.create_etud(code_nip=None, prenom="etudfaux")
|
||||||
etud_faux = Identite.query.filter_by(id=etud_faux_dict["id"]).first()
|
etud_faux = Identite.query.filter_by(id=etud_faux_dict["id"]).first()
|
||||||
|
|
||||||
# verif_migration_abs_assiduites() // Test à revoir TODO-ASSIDUITE (issue #696)
|
verif_migration_abs_assiduites()
|
||||||
|
|
||||||
ajouter_assiduites(etuds, moduleimpls, etud_faux)
|
ajouter_assiduites(etuds, moduleimpls, etud_faux)
|
||||||
justificatifs: list[Justificatif] = ajouter_justificatifs(etuds[0])
|
justificatifs: list[Justificatif] = ajouter_justificatifs(etuds[0])
|
||||||
@ -307,14 +316,13 @@ def verif_migration_abs_assiduites():
|
|||||||
False,
|
False,
|
||||||
), # 3 assi 22-23-24/02/2023 08h > 13h (3dj) JUSTI(ext)
|
), # 3 assi 22-23-24/02/2023 08h > 13h (3dj) JUSTI(ext)
|
||||||
]:
|
]:
|
||||||
continue
|
_create_abs(
|
||||||
# sco_abs_views.doSignaleAbsence( # TODO-ASSIDUITE
|
date_debut=debut,
|
||||||
# datedebut=debut,
|
date_fin=fin,
|
||||||
# datefin=fin,
|
demijournee=demijournee,
|
||||||
# demijournee=demijournee,
|
etudid=etudid,
|
||||||
# etudid=etudid,
|
estjust=justifiee,
|
||||||
# estjust=justifiee,
|
)
|
||||||
# )
|
|
||||||
|
|
||||||
# --- Justification de certaines absences
|
# --- Justification de certaines absences
|
||||||
|
|
||||||
@ -330,13 +338,14 @@ def verif_migration_abs_assiduites():
|
|||||||
2,
|
2,
|
||||||
),
|
),
|
||||||
]:
|
]:
|
||||||
continue
|
_create_abs(
|
||||||
# sco_abs_views.doJustifAbsence(
|
date_debut=debut,
|
||||||
# datedebut=debut,
|
date_fin=fin,
|
||||||
# datefin=fin,
|
demijournee=demijournee,
|
||||||
# demijournee=demijournee,
|
etudid=etudid,
|
||||||
# etudid=etudid,
|
estjust=True,
|
||||||
# )
|
estabs=False,
|
||||||
|
)
|
||||||
|
|
||||||
migrate_abs_to_assiduites()
|
migrate_abs_to_assiduites()
|
||||||
|
|
||||||
@ -442,8 +451,6 @@ def verif_migration_abs_assiduites():
|
|||||||
_get_assi("2023-02-24T08:00", "2023-02-24T13:00", True) is not None
|
_get_assi("2023-02-24T08:00", "2023-02-24T13:00", True) is not None
|
||||||
), "Migration : Abs n°27 mal migrée"
|
), "Migration : Abs n°27 mal migrée"
|
||||||
|
|
||||||
essais_cache(etudid)
|
|
||||||
|
|
||||||
downgrade_module(assiduites=True, justificatifs=True)
|
downgrade_module(assiduites=True, justificatifs=True)
|
||||||
|
|
||||||
|
|
||||||
@ -1025,3 +1032,86 @@ def verifier_comptage_et_filtrage_assiduites(
|
|||||||
assert (
|
assert (
|
||||||
scass.filter_by_date(etu2.assiduites, Assiduite, date_fin=date).count() == 7
|
scass.filter_by_date(etu2.assiduites, Assiduite, date_fin=date).count() == 7
|
||||||
), "Filtrage 'Date fin' mauvais 5"
|
), "Filtrage 'Date fin' mauvais 5"
|
||||||
|
|
||||||
|
|
||||||
|
def _create_abs(
|
||||||
|
date_debut, date_fin, demijournee, estjust=False, etudid=False, estabs=True
|
||||||
|
):
|
||||||
|
etud = Identite.from_request(etudid)
|
||||||
|
deb: dt.date = dt.datetime.strptime(date_debut, "%d/%m/%Y").date()
|
||||||
|
fin: dt.date = dt.datetime.strptime(date_fin, "%d/%m/%Y").date()
|
||||||
|
abs_list: list[Absence] = []
|
||||||
|
while deb < fin:
|
||||||
|
if deb.weekday() in [5, 6]:
|
||||||
|
deb += dt.timedelta(days=1)
|
||||||
|
continue
|
||||||
|
if demijournee == 2:
|
||||||
|
abs_list.append(
|
||||||
|
Absence(
|
||||||
|
etudid=etud.id,
|
||||||
|
jour=deb.isoformat(),
|
||||||
|
estabs=estabs,
|
||||||
|
estjust=estjust,
|
||||||
|
matin=True,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
abs_list.append(
|
||||||
|
Absence(
|
||||||
|
etudid=etud.id,
|
||||||
|
jour=deb.isoformat(),
|
||||||
|
estabs=estabs,
|
||||||
|
estjust=estjust,
|
||||||
|
matin=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
abs_list.append(
|
||||||
|
Absence(
|
||||||
|
etudid=etud.id,
|
||||||
|
jour=deb.isoformat(),
|
||||||
|
estabs=estabs,
|
||||||
|
estjust=estjust,
|
||||||
|
matin=demijournee,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
log(
|
||||||
|
f"create_abs [{etudid}, {deb.isoformat()}, {estabs}, {estjust}, {['aprem', 'matin', 'journee'][demijournee]}]"
|
||||||
|
)
|
||||||
|
deb += dt.timedelta(days=1)
|
||||||
|
|
||||||
|
if deb == fin and deb.weekday() not in [5, 6]:
|
||||||
|
if demijournee == 2:
|
||||||
|
abs_list.append(
|
||||||
|
Absence(
|
||||||
|
etudid=etud.id,
|
||||||
|
jour=deb.isoformat(),
|
||||||
|
estabs=estabs,
|
||||||
|
estjust=estjust,
|
||||||
|
matin=True,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
abs_list.append(
|
||||||
|
Absence(
|
||||||
|
etudid=etud.id,
|
||||||
|
jour=deb.isoformat(),
|
||||||
|
estabs=estabs,
|
||||||
|
estjust=estjust,
|
||||||
|
matin=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
abs_list.append(
|
||||||
|
Absence(
|
||||||
|
etudid=etud.id,
|
||||||
|
jour=deb.isoformat(),
|
||||||
|
estabs=estabs,
|
||||||
|
estjust=estjust,
|
||||||
|
matin=demijournee,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
log(
|
||||||
|
f"create_abs [{etudid}, {deb.isoformat()}, {estabs}, {estjust}, {['aprem', 'matin', 'journee'][demijournee]}]"
|
||||||
|
)
|
||||||
|
|
||||||
|
db.session.add_all(abs_list)
|
||||||
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user