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
|
||||
if delta > datetime.timedelta(days=1):
|
||||
# rediriger vers page saisie
|
||||
flash("Redirection pour saisie abs")
|
||||
return redirect(
|
||||
url_for(
|
||||
"assiduites.signal_assiduites_etud",
|
||||
@ -1059,6 +1058,7 @@ def signal_evaluation_abs(etudid: int = None, evaluation_id: int = None):
|
||||
|
||||
# créer l'assiduité
|
||||
|
||||
try:
|
||||
assiduite_unique: Assiduite = Assiduite.create_assiduite(
|
||||
etud=etud,
|
||||
date_debut=scu.localize_datetime(evaluation.date_debut),
|
||||
@ -1066,6 +1066,23 @@ def signal_evaluation_abs(etudid: int = None, evaluation_id: int = None):
|
||||
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.commit()
|
||||
|
@ -11,14 +11,23 @@ import pytest
|
||||
|
||||
import app.scodoc.sco_assiduites as scass
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app import db
|
||||
from app.models import Assiduite, FormSemestre, Identite, Justificatif, ModuleImpl
|
||||
from app import db, log
|
||||
from app.models import (
|
||||
Assiduite,
|
||||
FormSemestre,
|
||||
Identite,
|
||||
Justificatif,
|
||||
ModuleImpl,
|
||||
Absence,
|
||||
)
|
||||
from app.models.assiduites import compute_assiduites_justified
|
||||
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from tests.unit import sco_fake_gen
|
||||
from tools import downgrade_module, migrate_abs_to_assiduites
|
||||
|
||||
import datetime as dt
|
||||
|
||||
|
||||
class BiInt(int, scu.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 = 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)
|
||||
justificatifs: list[Justificatif] = ajouter_justificatifs(etuds[0])
|
||||
@ -307,14 +316,13 @@ def verif_migration_abs_assiduites():
|
||||
False,
|
||||
), # 3 assi 22-23-24/02/2023 08h > 13h (3dj) JUSTI(ext)
|
||||
]:
|
||||
continue
|
||||
# sco_abs_views.doSignaleAbsence( # TODO-ASSIDUITE
|
||||
# datedebut=debut,
|
||||
# datefin=fin,
|
||||
# demijournee=demijournee,
|
||||
# etudid=etudid,
|
||||
# estjust=justifiee,
|
||||
# )
|
||||
_create_abs(
|
||||
date_debut=debut,
|
||||
date_fin=fin,
|
||||
demijournee=demijournee,
|
||||
etudid=etudid,
|
||||
estjust=justifiee,
|
||||
)
|
||||
|
||||
# --- Justification de certaines absences
|
||||
|
||||
@ -330,13 +338,14 @@ def verif_migration_abs_assiduites():
|
||||
2,
|
||||
),
|
||||
]:
|
||||
continue
|
||||
# sco_abs_views.doJustifAbsence(
|
||||
# datedebut=debut,
|
||||
# datefin=fin,
|
||||
# demijournee=demijournee,
|
||||
# etudid=etudid,
|
||||
# )
|
||||
_create_abs(
|
||||
date_debut=debut,
|
||||
date_fin=fin,
|
||||
demijournee=demijournee,
|
||||
etudid=etudid,
|
||||
estjust=True,
|
||||
estabs=False,
|
||||
)
|
||||
|
||||
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
|
||||
), "Migration : Abs n°27 mal migrée"
|
||||
|
||||
essais_cache(etudid)
|
||||
|
||||
downgrade_module(assiduites=True, justificatifs=True)
|
||||
|
||||
|
||||
@ -1025,3 +1032,86 @@ def verifier_comptage_et_filtrage_assiduites(
|
||||
assert (
|
||||
scass.filter_by_date(etu2.assiduites, Assiduite, date_fin=date).count() == 7
|
||||
), "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