diff --git a/app/comp/moy_ue.py b/app/comp/moy_ue.py index 7d7ea338..8bd9fa94 100644 --- a/app/comp/moy_ue.py +++ b/app/comp/moy_ue.py @@ -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] module_ids = [module.id for module in modules] module_coefs_df = pd.DataFrame(columns=module_ids, index=ue_ids, dtype=float) - for mod_coef in ( + query = ( db.session.query(ModuleUECoef) .filter(UniteEns.formation_id == formation_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.fillna(value=0, inplace=True) + return module_coefs_df, ues, modules diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 73336d39..e5e22f95 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -32,7 +32,7 @@ import flask from flask import url_for, render_template from flask import g, request 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.sco_utils as scu @@ -89,7 +89,7 @@ def module_list(*args, **kw): def do_module_create(args) -> int: - "create a module" + "Create a module. Returns id of new object." # create 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: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() else: - do_module_create(tf[2]) + module_id = do_module_create(tf[2]) + mod = Module.query.get(module_id) return flask.redirect( url_for( "notes.ue_table", scodoc_dept=g.scodoc_dept, formation_id=ue.formation_id, + semestre_idx=mod.semestre_id, ) ) diff --git a/app/views/pn_modules.py b/app/views/pn_modules.py index aa7374a9..0dc52d1b 100644 --- a/app/views/pn_modules.py +++ b/app/views/pn_modules.py @@ -175,7 +175,7 @@ def edit_modules_ue_coefs(): ], page_title=f"Coefs programme {formation.acronyme}", ), - f"""