Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
Showing only changes of commit 7fad9e0a71 - Show all commits

View File

@ -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()