Fix: édition coefs semestres, retour au semestre sélectionné.

This commit is contained in:
Emmanuel Viennet 2021-12-10 15:51:43 +01:00
parent 2f9b2a5a2d
commit 272de740e1
3 changed files with 14 additions and 6 deletions

View File

@ -67,13 +67,19 @@ def df_load_module_coefs(formation_id: int, semestre_idx: int = None) -> pd.Data
ue_ids = [ue.id for ue in ues] ue_ids = [ue.id for ue in ues]
module_ids = [module.id for module in modules] module_ids = [module.id for module in modules]
module_coefs_df = pd.DataFrame(columns=module_ids, index=ue_ids, dtype=float) module_coefs_df = pd.DataFrame(columns=module_ids, index=ue_ids, dtype=float)
for mod_coef in ( query = (
db.session.query(ModuleUECoef) db.session.query(ModuleUECoef)
.filter(UniteEns.formation_id == formation_id) .filter(UniteEns.formation_id == formation_id)
.filter(ModuleUECoef.ue_id == UniteEns.id) .filter(ModuleUECoef.ue_id == UniteEns.id)
): )
if semestre_idx is not None:
query = query.filter(UniteEns.semestre_idx == semestre_idx)
for mod_coef in query:
module_coefs_df[mod_coef.module_id][mod_coef.ue_id] = mod_coef.coef module_coefs_df[mod_coef.module_id][mod_coef.ue_id] = mod_coef.coef
module_coefs_df.fillna(value=0, inplace=True) module_coefs_df.fillna(value=0, inplace=True)
return module_coefs_df, ues, modules return module_coefs_df, ues, modules

View File

@ -32,7 +32,7 @@ import flask
from flask import url_for, render_template from flask import url_for, render_template
from flask import g, request from flask import g, request
from flask_login import current_user from flask_login import current_user
from app.models import Matiere, UniteEns from app.models import Matiere, Module
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
@ -89,7 +89,7 @@ def module_list(*args, **kw):
def do_module_create(args) -> int: def do_module_create(args) -> int:
"create a module" "Create a module. Returns id of new object."
# create # create
from app.scodoc import sco_formations from app.scodoc import sco_formations
@ -288,12 +288,14 @@ def module_create(matiere_id=None, module_type=None, semestre_id=None):
if tf[0] == 0: if tf[0] == 0:
return "\n".join(H) + tf[1] + html_sco_header.sco_footer() return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
else: else:
do_module_create(tf[2]) module_id = do_module_create(tf[2])
mod = Module.query.get(module_id)
return flask.redirect( return flask.redirect(
url_for( url_for(
"notes.ue_table", "notes.ue_table",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
formation_id=ue.formation_id, formation_id=ue.formation_id,
semestre_idx=mod.semestre_id,
) )
) )

View File

@ -175,7 +175,7 @@ def edit_modules_ue_coefs():
], ],
page_title=f"Coefs programme {formation.acronyme}", page_title=f"Coefs programme {formation.acronyme}",
), ),
f"""<h2>Formation {formation.titre} ({formation.acronyme}) f"""<h2>Formation {formation.titre} ({formation.acronyme})
[version {formation.version}] code {formation.formation_code} [version {formation.version}] code {formation.formation_code}
{lockicon} {lockicon}
</h2> </h2>