forked from ScoDoc/ScoDoc
Compare commits
No commits in common. "2f05e081ee6c77e6d51a8da78ce9be88182344e7" and "f2574c2d495782b5917a6bc024deeea4636945e8" have entirely different histories.
2f05e081ee
...
f2574c2d49
@ -269,7 +269,13 @@ def validation_rcue_record(etudid: int):
|
||||
validation.parcours_id = parcours_id
|
||||
validation.ue1_id = ue1_id
|
||||
validation.ue2_id = ue2_id
|
||||
operation = "update"
|
||||
log(f"updating {validation}")
|
||||
Scolog.logdb(
|
||||
method="validation_rcue_record",
|
||||
etudid=etudid,
|
||||
msg=f"Mise à jour {validation}",
|
||||
commit=False,
|
||||
)
|
||||
else:
|
||||
validation = ApcValidationRCUE(
|
||||
code=code,
|
||||
@ -280,16 +286,15 @@ def validation_rcue_record(etudid: int):
|
||||
ue1_id=ue1_id,
|
||||
ue2_id=ue2_id,
|
||||
)
|
||||
operation = "record"
|
||||
log(f"recording {validation}")
|
||||
Scolog.logdb(
|
||||
method="validation_rcue_record",
|
||||
etudid=etudid,
|
||||
msg=f"Enregistrement {validation}",
|
||||
commit=False,
|
||||
)
|
||||
db.session.add(validation)
|
||||
db.session.commit()
|
||||
Scolog.logdb(
|
||||
method="validation_rcue_record",
|
||||
etudid=etudid,
|
||||
msg=f"Enregistrement {validation}",
|
||||
commit=True,
|
||||
)
|
||||
log(f"{operation} {validation}")
|
||||
return validation.to_dict()
|
||||
|
||||
|
||||
|
@ -212,34 +212,6 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
||||
else:
|
||||
self.ue_std_rows(rows, ue, title_bg)
|
||||
|
||||
@staticmethod
|
||||
def affichage_bonus_malus(ue: dict) -> list:
|
||||
fields_bmr = []
|
||||
# lecture des bonus sport culture et malus (ou bonus autre) (0 si valeur non numérique)
|
||||
try:
|
||||
bonus_sc = float(ue.get("bonus", 0.0)) or 0
|
||||
except ValueError:
|
||||
bonus_sc = 0
|
||||
try:
|
||||
malus = float(ue.get("malus", 0.0)) or 0
|
||||
except ValueError:
|
||||
malus = 0
|
||||
# Calcul de l affichage
|
||||
if malus < 0:
|
||||
if bonus_sc > 0:
|
||||
fields_bmr.append(f"Bonus sport/culture: {bonus_sc}")
|
||||
fields_bmr.append(f"Bonus autres: {-malus}")
|
||||
else:
|
||||
fields_bmr.append(f"Bonus: {-malus}")
|
||||
elif malus > 0:
|
||||
if bonus_sc > 0:
|
||||
fields_bmr.append(f"Bonus: {bonus_sc}")
|
||||
fields_bmr.append(f"Malus: {malus}")
|
||||
else:
|
||||
if bonus_sc > 0:
|
||||
fields_bmr.append(f"Bonus: {bonus_sc}")
|
||||
return fields_bmr
|
||||
|
||||
def ue_std_rows(self, rows: list, ue: dict, title_bg: tuple):
|
||||
"Lignes décrivant une UE standard dans la table de synthèse"
|
||||
# 2eme ligne titre UE (bonus/malus/ects)
|
||||
@ -248,7 +220,20 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
||||
else:
|
||||
ects_txt = ""
|
||||
# case Bonus/Malus/Rang "bmr"
|
||||
fields_bmr = BulletinGeneratorStandardBUT.affichage_bonus_malus(ue)
|
||||
fields_bmr = []
|
||||
try:
|
||||
value = float(ue.get("bonus", 0.0))
|
||||
if value != 0:
|
||||
fields_bmr.append(f"Bonus: {ue['bonus']}")
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
value = float(ue.get("malus", 0.0))
|
||||
if value != 0:
|
||||
fields_bmr.append(f"Malus: {ue['malus']}")
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
moy_ue = ue.get("moyenne", "-")
|
||||
if isinstance(moy_ue, dict): # UE non capitalisées
|
||||
if self.preferences["bul_show_ue_rangs"]:
|
||||
|
@ -82,10 +82,6 @@ class ApcValidationRCUE(db.Model):
|
||||
"as a dict"
|
||||
d = dict(self.__dict__)
|
||||
d.pop("_sa_instance_state", None)
|
||||
d["etud"] = self.etud.to_dict_short()
|
||||
d["ue1"] = self.ue1.to_dict()
|
||||
d["ue2"] = self.ue2.to_dict()
|
||||
|
||||
return d
|
||||
|
||||
def to_dict_bul(self) -> dict:
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import operator
|
||||
import urllib
|
||||
from urllib.parse import parse_qs
|
||||
import time
|
||||
@ -41,8 +42,6 @@ import time
|
||||
from flask import url_for, g, request
|
||||
from flask_login import current_user
|
||||
|
||||
from app import db
|
||||
from app.models import FormSemestre
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.scodoc import html_sco_header
|
||||
from app.scodoc import sco_abs
|
||||
@ -66,7 +65,6 @@ JAVASCRIPTS = html_sco_header.BOOTSTRAP_MULTISELECT_JS + [
|
||||
|
||||
CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS
|
||||
|
||||
|
||||
# view:
|
||||
def groups_view(
|
||||
group_ids=(),
|
||||
@ -424,13 +422,6 @@ class DisplayedGroupsInfos(object):
|
||||
H.append(f'<input type="hidden" name="group_ids" value="{group_id}"/>')
|
||||
return "\n".join(H)
|
||||
|
||||
def get_formsemestre(self) -> FormSemestre:
|
||||
return (
|
||||
db.session.get(FormSemestre, self.formsemestre_id)
|
||||
if self.formsemestre_id
|
||||
else None
|
||||
)
|
||||
|
||||
|
||||
# Ancien ZScolar.group_list renommé ici en group_table
|
||||
def groups_table(
|
||||
|
@ -517,7 +517,7 @@ def ficheEtud(etudid=None):
|
||||
cursus=but_cursus,
|
||||
scu=scu,
|
||||
)}
|
||||
<div class="link_validation_rcues">
|
||||
<div>
|
||||
<a href="{url_for("notes.validation_rcues",
|
||||
scodoc_dept=g.scodoc_dept, etudid=etudid,
|
||||
formsemestre_id=last_formsemestre.id)}"
|
||||
|
@ -8,7 +8,7 @@
|
||||
"""
|
||||
|
||||
from flask import g, url_for
|
||||
from app.models import Identite, Justificatif
|
||||
from app.models import Identite, Assiduite, Justificatif
|
||||
from app.tables import table_builder as tb
|
||||
import app.scodoc.sco_assiduites as scass
|
||||
from app.scodoc import sco_preferences
|
||||
@ -65,35 +65,31 @@ class RowAssi(tb.Row):
|
||||
}
|
||||
)
|
||||
|
||||
bilan_etud = url_for(
|
||||
"assiduites.bilan_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id
|
||||
)
|
||||
bilan_etud = f"{url_for('assiduites.bilan_etud', scodoc_dept=g.scodoc_dept)}?etudid={etud.id}"
|
||||
self.add_cell(
|
||||
"nom_disp",
|
||||
"Nom",
|
||||
etud.nom_disp(),
|
||||
"etudinfo",
|
||||
attrs={"id": str(etud.id)},
|
||||
"identite_detail",
|
||||
data={"order": etud.sort_key},
|
||||
target=bilan_etud,
|
||||
target_attrs={"class": "discretelink"},
|
||||
target_attrs={"class": "discretelink", "id": str(etud.id)},
|
||||
)
|
||||
self.add_cell(
|
||||
"prenom",
|
||||
"Prénom",
|
||||
etud.prenom_str,
|
||||
"etudinfo",
|
||||
attrs={"id": str(etud.id)},
|
||||
etud.prenom,
|
||||
"identite_detail",
|
||||
data={"order": etud.sort_key},
|
||||
target=bilan_etud,
|
||||
target_attrs={"class": "discretelink"},
|
||||
target_attrs={"class": "discretelink", "id": str(etud.id)},
|
||||
)
|
||||
stats = self._get_etud_stats(etud)
|
||||
for key, value in stats.items():
|
||||
self.add_cell(key, value[0], f"{value[1] - value[2]}", "assi_stats")
|
||||
self.add_cell(
|
||||
key + "_justi",
|
||||
value[0] + " Justifiées",
|
||||
value[0] + " Justifiée(s)",
|
||||
f"{value[2]}",
|
||||
"assi_stats",
|
||||
)
|
||||
@ -106,9 +102,9 @@ class RowAssi(tb.Row):
|
||||
|
||||
def _get_etud_stats(self, etud: Identite) -> dict[str, list[str, float, float]]:
|
||||
retour: dict[str, tuple[str, float, float]] = {
|
||||
"present": ["Présences", 0.0, 0.0],
|
||||
"retard": ["Retards", 0.0, 0.0],
|
||||
"absent": ["Absences", 0.0, 0.0],
|
||||
"present": ["Présence(s)", 0.0, 0.0],
|
||||
"retard": ["Retard(s)", 0.0, 0.0],
|
||||
"absent": ["Absence(s)", 0.0, 0.0],
|
||||
}
|
||||
|
||||
assi_metric = {
|
||||
|
@ -1,22 +1,11 @@
|
||||
{% extends "sco_page.j2" %}
|
||||
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script src="{{scu.STATIC_DIR}}/js/etud_info.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
|
||||
<h2>Visualisation de l'assiduité {{gr_tit|safe}}</h2>
|
||||
|
||||
<div class="stats-inputs">
|
||||
<label class="stats-label"> Date de début <input type="date" name="stats_date_debut" id="stats_date_debut"
|
||||
<label class="stats-label"> Date de début<input type="date" name="stats_date_debut" id="stats_date_debut"
|
||||
value="{{date_debut}}"></label>
|
||||
<label class="stats-label"> Date de fin <input type="date" name="stats_date_fin" id="stats_date_fin"
|
||||
<label class="stats-label"> Date de fin<input type="date" name="stats_date_fin" id="stats_date_fin"
|
||||
value="{{date_fin}}"></label>
|
||||
<button onclick="stats()">Changer</button>
|
||||
|
||||
<a style="margin-left:32px;" href="{{request.url}}&format=xlsx">{{scu.ICON_XLS|safe}}</a>
|
||||
<button onclick="stats()">Changer la période</button>
|
||||
</div>
|
||||
|
||||
{{tableau | safe}}
|
||||
@ -37,6 +26,4 @@
|
||||
document.querySelector('#stats_date_fin').value = date_fin;
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
</script>
|
@ -100,7 +100,6 @@
|
||||
data-ue2_id="{{niv['ue_pair'].id}}"
|
||||
data-code="{{validation.code if validation else ''}}"
|
||||
>
|
||||
<option value="" disabled {{"selected" if not validation else ""}}>-</option>
|
||||
{% for code in rcue_codes %}
|
||||
<option value="{{code}}"
|
||||
{% if validation and validation.code == code -%}
|
||||
|
@ -649,7 +649,6 @@ def visu_assi_group():
|
||||
"debut": request.args.get("date_debut"),
|
||||
"fin": request.args.get("date_fin"),
|
||||
}
|
||||
fmt = request.args.get("format", "html")
|
||||
|
||||
group_ids: list[int] = request.args.get("group_ids", None)
|
||||
etudiants: list[dict] = []
|
||||
@ -663,15 +662,13 @@ def visu_assi_group():
|
||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
|
||||
|
||||
etuds = etuds_sorted_from_ids([m["etudid"] for m in groups_infos.members])
|
||||
table: TableAssi = TableAssi(etuds=etuds, dates=list(dates.values()))
|
||||
|
||||
if fmt.startswith("xls"):
|
||||
return scu.send_file(
|
||||
table.excel(),
|
||||
filename=f"assiduite-{groups_infos.groups_filename}",
|
||||
mime=scu.XLSX_MIMETYPE,
|
||||
suffix=scu.XLSX_SUFFIX,
|
||||
)
|
||||
header: str = html_sco_header.sco_header(
|
||||
page_title="Visualisation des assiduités",
|
||||
init_qtip=True,
|
||||
)
|
||||
|
||||
table: TableAssi = TableAssi(etuds=etuds, dates=list(dates.values()))
|
||||
|
||||
if groups_infos.tous_les_etuds_du_sem:
|
||||
gr_tit = "en"
|
||||
@ -684,16 +681,18 @@ def visu_assi_group():
|
||||
grp + ' <span class="fontred">' + groups_infos.groups_titles + "</span>"
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"assiduites/pages/visu_assi.j2",
|
||||
tableau=table.html(),
|
||||
gr_tit=gr_tit,
|
||||
date_debut=dates["debut"],
|
||||
date_fin=dates["fin"],
|
||||
group_ids=request.args.get("group_ids", None),
|
||||
sco=ScoData(formsemestre=groups_infos.get_formsemestre()),
|
||||
title=f"Assiduité {grp} {groups_infos.groups_titles}",
|
||||
)
|
||||
return HTMLBuilder(
|
||||
header,
|
||||
render_template(
|
||||
"assiduites/pages/visu_assi.j2",
|
||||
tableau=table.html(),
|
||||
gr_tit=gr_tit,
|
||||
date_debut=dates["debut"],
|
||||
date_fin=dates["fin"],
|
||||
group_ids=request.args.get("group_ids", None),
|
||||
),
|
||||
html_sco_header.sco_footer(),
|
||||
).build()
|
||||
|
||||
|
||||
@bp.route("/SignalAssiduiteDifferee")
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.6.3"
|
||||
SCOVERSION = "9.6.0"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
@ -1,82 +0,0 @@
|
||||
"""Tests unitaires : bulletins de notes
|
||||
|
||||
Utiliser comme:
|
||||
pytest tests/unit/test_bulletin_bonus.py
|
||||
|
||||
"""
|
||||
from app.but.bulletin_but_pdf import BulletinGeneratorStandardBUT
|
||||
|
||||
|
||||
def test_nobonus():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus({}) == []
|
||||
|
||||
|
||||
def test_bonus_sport_nul():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus({"bonus": 0}) == []
|
||||
|
||||
|
||||
def test_malus_nul():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus({"malus": 0}) == []
|
||||
|
||||
|
||||
def test_bonus_et_malus_nuls():
|
||||
assert (
|
||||
BulletinGeneratorStandardBUT.affichage_bonus_malus({"bonus": 0, "malus": 0})
|
||||
== []
|
||||
)
|
||||
|
||||
|
||||
def test_vrai_malus():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus({"malus": 0.1}) == [
|
||||
"Malus: 0.1"
|
||||
]
|
||||
|
||||
|
||||
def test_bonus_sport_et_vrai_malus():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus(
|
||||
{"malus": 0.12, "bonus": 0.23}
|
||||
) == [
|
||||
"Bonus: 0.23",
|
||||
"Malus: 0.12",
|
||||
]
|
||||
|
||||
|
||||
def test_bonus_sport_seul():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus({"bonus": 0.5}) == [
|
||||
"Bonus: 0.5"
|
||||
]
|
||||
|
||||
|
||||
def test_bonus_sport_nul_et_vrai_malus():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus(
|
||||
{"bonus": 0, "malus": 0.5}
|
||||
) == ["Malus: 0.5"]
|
||||
|
||||
|
||||
def test_bonus_sport_et_malus_nul():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus(
|
||||
{"bonus": 0.5, "malus": 0}
|
||||
) == [
|
||||
"Bonus: 0.5",
|
||||
]
|
||||
|
||||
|
||||
def test_faux_malus():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus({"malus": -0.6}) == [
|
||||
"Bonus: 0.6"
|
||||
]
|
||||
|
||||
|
||||
def test_sport_nul_faux_malus():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus(
|
||||
{"bonus": 0, "malus": -0.6}
|
||||
) == ["Bonus: 0.6"]
|
||||
|
||||
|
||||
def test_bonus_sport_et_faux_malus():
|
||||
assert BulletinGeneratorStandardBUT.affichage_bonus_malus(
|
||||
{"bonus": 0.3, "malus": -0.6}
|
||||
) == [
|
||||
"Bonus sport/culture: 0.3",
|
||||
"Bonus autres: 0.6",
|
||||
]
|
@ -75,9 +75,9 @@ fi
|
||||
#echo "Creating python3 virtualenv..."
|
||||
su -c "(cd $SCODOC_DIR && python3 -m venv venv)" "$SCODOC_USER" || die "Error creating Python 3 virtualenv"
|
||||
|
||||
# ------------ INSTALL DES PAQUETS PYTHON (3.11)
|
||||
# ------------ INSTALL DES PAQUETS PYTHON (3.9)
|
||||
# pip in our env, as user "scodoc"
|
||||
su -c "(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.11.txt)" "$SCODOC_USER" || die "Error installing python packages"
|
||||
su -c "(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.9.txt)" "$SCODOC_USER" || die "Error installing python packages"
|
||||
|
||||
# --- NGINX
|
||||
# Evite d'écraser: il faudrait ici présenter un dialogue "fichier local modifié, ..."
|
||||
|
@ -7,8 +7,6 @@ from datetime import date, datetime, time, timedelta
|
||||
from json import dump, dumps
|
||||
from sqlalchemy import not_
|
||||
|
||||
from flask import g
|
||||
|
||||
from app import db
|
||||
from app.models import (
|
||||
Absence,
|
||||
@ -32,7 +30,6 @@ from app.scodoc.sco_utils import (
|
||||
localize_datetime,
|
||||
print_progress_bar,
|
||||
)
|
||||
from app.scodoc import notesdb as ndb
|
||||
|
||||
|
||||
class _glob:
|
||||
@ -41,6 +38,7 @@ class _glob:
|
||||
DEBUG: bool = False
|
||||
PROBLEMS: dict[int, list[str]] = {}
|
||||
DEPT_ETUDIDS: dict[int, Identite] = {}
|
||||
MODULES: dict[tuple[int, int]] = {}
|
||||
COMPTE: list[int, int] = []
|
||||
ERR_ETU: list[int] = []
|
||||
MERGER_ASSI: "_Merger" = None
|
||||
@ -99,70 +97,42 @@ class _Merger:
|
||||
date_deb = _Merger._tuple_to_date(self.deb)
|
||||
date_fin = _Merger._tuple_to_date(self.fin, end=True)
|
||||
|
||||
_glob.cursor.execute(
|
||||
"""INSERT INTO justificatifs
|
||||
(etudid,date_debut,date_fin,etat,raison,entry_date)
|
||||
VALUES (%(etudid)s,%(date_debut)s,%(date_fin)s,%(etat)s,%(raison)s,%(entry_date)s)
|
||||
""",
|
||||
{
|
||||
"etudid": self.etudid,
|
||||
"date_debut": date_deb,
|
||||
"date_fin": date_fin,
|
||||
"etat": EtatJustificatif.VALIDE,
|
||||
"raison": self.raison,
|
||||
"entry_date": self.entry_date,
|
||||
},
|
||||
retour = Justificatif.fast_create_justificatif(
|
||||
etudid=self.etudid,
|
||||
date_debut=date_deb,
|
||||
date_fin=date_fin,
|
||||
etat=EtatJustificatif.VALIDE,
|
||||
raison=self.raison,
|
||||
entry_date=self.entry_date,
|
||||
)
|
||||
# retour = Justificatif.fast_create_justificatif(
|
||||
# etudid=self.etudid,
|
||||
# date_debut=date_deb,
|
||||
# date_fin=date_fin,
|
||||
# etat=EtatJustificatif.VALIDE,
|
||||
# raison=self.raison,
|
||||
# entry_date=self.entry_date,
|
||||
# )
|
||||
# return retour
|
||||
return retour
|
||||
|
||||
def _to_assi(self):
|
||||
date_deb = _Merger._tuple_to_date(self.deb)
|
||||
date_fin = _Merger._tuple_to_date(self.fin, end=True)
|
||||
|
||||
_glob.cursor.execute(
|
||||
"""INSERT INTO assiduites
|
||||
(etudid,date_debut,date_fin,etat,moduleimpl_id,"desc",entry_date)
|
||||
VALUES (%(etudid)s,%(date_debut)s,%(date_fin)s,%(etat)s,%(moduleimpl_id)s,%(desc)s,%(entry_date)s)
|
||||
""",
|
||||
{
|
||||
"etudid": self.etudid,
|
||||
"date_debut": date_deb,
|
||||
"date_fin": date_fin,
|
||||
"etat": EtatAssiduite.ABSENT,
|
||||
"moduleimpl_id": self.moduleimpl,
|
||||
"desc": self.raison,
|
||||
"entry_date": self.entry_date,
|
||||
},
|
||||
retour = Assiduite.fast_create_assiduite(
|
||||
etudid=self.etudid,
|
||||
date_debut=date_deb,
|
||||
date_fin=date_fin,
|
||||
etat=EtatAssiduite.ABSENT,
|
||||
moduleimpl_id=self.moduleimpl,
|
||||
description=self.raison,
|
||||
entry_date=self.entry_date,
|
||||
)
|
||||
|
||||
# retour = Assiduite.fast_create_assiduite(
|
||||
# etudid=self.etudid,
|
||||
# date_debut=date_deb,
|
||||
# date_fin=date_fin,
|
||||
# etat=EtatAssiduite.ABSENT,
|
||||
# moduleimpl_id=self.moduleimpl,
|
||||
# description=self.raison,
|
||||
# entry_date=self.entry_date,
|
||||
# )
|
||||
# return retour
|
||||
return retour
|
||||
|
||||
def export(self):
|
||||
"""Génère un nouvel objet Assiduité ou Justificatif"""
|
||||
obj: Assiduite or Justificatif = None
|
||||
if self.est_abs:
|
||||
_glob.COMPTE[0] += 1
|
||||
self._to_assi()
|
||||
obj = self._to_assi()
|
||||
else:
|
||||
_glob.COMPTE[1] += 1
|
||||
self._to_justif()
|
||||
obj = self._to_justif()
|
||||
|
||||
db.session.add(obj)
|
||||
|
||||
|
||||
class _Statistics:
|
||||
@ -273,10 +243,6 @@ def migrate_abs_to_assiduites(
|
||||
evening: list[str] = str(evening).split(":")
|
||||
_glob.EVENING = time(int(evening[0]), int(evening[1]))
|
||||
|
||||
ndb.open_db_connection()
|
||||
_glob.cnx = g.db_conn
|
||||
_glob.cursor = _glob.cnx.cursor()
|
||||
|
||||
if dept is None:
|
||||
prof_total = Profiler("MigrationTotal")
|
||||
prof_total.start()
|
||||
@ -321,6 +287,7 @@ def migrate_dept(dept_name: str, stats: _Statistics, time_elapsed: Profiler):
|
||||
return
|
||||
|
||||
_glob.DEPT_ETUDIDS = {e.id for e in Identite.query.filter_by(dept_id=dept.id)}
|
||||
_glob.MODULES = {}
|
||||
_glob.COMPTE = [0, 0]
|
||||
_glob.ERR_ETU = []
|
||||
_glob.MERGER_ASSI = None
|
||||
@ -332,17 +299,9 @@ def migrate_dept(dept_name: str, stats: _Statistics, time_elapsed: Profiler):
|
||||
|
||||
print_progress_bar(0, absences_len, "Progression", "effectué", autosize=True)
|
||||
|
||||
etuds_modimpl_ids = {}
|
||||
for i, abs_ in enumerate(absences):
|
||||
etud_modimpl_ids = etuds_modimpl_ids.get(abs_.etudid)
|
||||
if etud_modimpl_ids is None:
|
||||
etud_modimpl_ids = {
|
||||
ins.moduleimpl_id
|
||||
for ins in ModuleImplInscription.query.filter_by(etudid=abs_.etudid)
|
||||
}
|
||||
etuds_modimpl_ids[abs_.etudid] = etud_modimpl_ids
|
||||
try:
|
||||
_from_abs_to_assiduite_justificatif(abs_, etud_modimpl_ids)
|
||||
_from_abs_to_assiduite_justificatif(abs_)
|
||||
except ValueError as e:
|
||||
stats.add_problem(abs_, e.args[0])
|
||||
|
||||
@ -363,14 +322,14 @@ def migrate_dept(dept_name: str, stats: _Statistics, time_elapsed: Profiler):
|
||||
"effectué",
|
||||
autosize=True,
|
||||
)
|
||||
_glob.cnx.commit()
|
||||
db.session.commit()
|
||||
|
||||
if _glob.MERGER_ASSI is not None:
|
||||
_glob.MERGER_ASSI.export()
|
||||
if _glob.MERGER_JUST is not None:
|
||||
_glob.MERGER_JUST.export()
|
||||
|
||||
_glob.cnx.commit()
|
||||
db.session.commit()
|
||||
|
||||
print_progress_bar(
|
||||
absences_len,
|
||||
@ -420,15 +379,24 @@ def migrate_dept(dept_name: str, stats: _Statistics, time_elapsed: Profiler):
|
||||
print(dumps(statistiques, indent=2))
|
||||
|
||||
|
||||
def _from_abs_to_assiduite_justificatif(_abs: Absence, etud_modimpl_ids: set[int]):
|
||||
def _from_abs_to_assiduite_justificatif(_abs: Absence):
|
||||
if _abs.etudid not in _glob.DEPT_ETUDIDS:
|
||||
raise ValueError("Etudiant inexistant")
|
||||
|
||||
if _abs.estabs:
|
||||
if (_abs.moduleimpl_id is not None) and (
|
||||
_abs.moduleimpl_id not in etud_modimpl_ids
|
||||
moduleimpl_id: int = _abs.moduleimpl_id
|
||||
if (
|
||||
moduleimpl_id is not None
|
||||
and (_abs.etudid, _abs.moduleimpl_id) not in _glob.MODULES
|
||||
):
|
||||
raise ValueError("Moduleimpl_id incorrect ou étudiant non inscrit")
|
||||
moduleimpl_inscription: ModuleImplInscription = (
|
||||
ModuleImplInscription.query.filter_by(
|
||||
moduleimpl_id=_abs.moduleimpl_id, etudid=_abs.etudid
|
||||
).first()
|
||||
)
|
||||
if moduleimpl_inscription is None:
|
||||
raise ValueError("Moduleimpl_id incorrect ou étudiant non inscrit")
|
||||
_glob.MODULES[(_abs.etudid, _abs.moduleimpl_id)] = True
|
||||
|
||||
if _glob.MERGER_ASSI is None:
|
||||
_glob.MERGER_ASSI = _Merger(_abs, True)
|
||||
|
Loading…
Reference in New Issue
Block a user