From e993599b39d15567d07db8cc8de87d9b0011cc89 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 28 Feb 2022 17:57:12 +0100 Subject: [PATCH] =?UTF-8?q?Restreint=20edition=20modules=20semestres=20BUT?= =?UTF-8?q?=20aux=20module=20du=20m=C3=AAme=20sem.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_formsemestre_edit.py | 30 ++++++++++++++++++++--------- app/static/js/formsemestre_edit.js | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 app/static/js/formsemestre_edit.js diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 3e1c92fb..f056a3e6 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -78,7 +78,7 @@ def formsemestre_createwithmodules(): H = [ html_sco_header.sco_header( page_title="Création d'un semestre", - javascripts=["libjs/AutoSuggest.js"], + javascripts=["libjs/AutoSuggest.js", "js/formsemestre_edit.js"], cssstyles=["css/autosuggest_inquisitor.css"], bodyOnLoad="init_tf_form('')", ), @@ -99,7 +99,7 @@ def formsemestre_editwithmodules(formsemestre_id): H = [ html_sco_header.html_sem_header( "Modification du semestre", - javascripts=["libjs/AutoSuggest.js"], + javascripts=["libjs/AutoSuggest.js", "js/formsemestre_edit.js"], cssstyles=["css/autosuggest_inquisitor.css"], bodyOnLoad="init_tf_form('')", ) @@ -344,6 +344,9 @@ def do_formsemestre_createwithmodules(edit=False): "explanation": "en BUT, on ne peut pas modifier le semestre après création" if formation.is_apc() else "", + "attributes": ['onchange="change_semestre_id();"'] + if formation.is_apc() + else "", }, ), ) @@ -496,7 +499,8 @@ def do_formsemestre_createwithmodules(edit=False): { "input_type": "boolcheckbox", "title": "", - "explanation": "Autoriser tous les enseignants associés à un module à y créer des évaluations", + "explanation": """Autoriser tous les enseignants associés + à un module à y créer des évaluations""", }, ), ( @@ -537,11 +541,19 @@ def do_formsemestre_createwithmodules(edit=False): ] nbmod = 0 - if edit: - templ_sep = "%(label)sResponsableInscrire" - else: - templ_sep = "%(label)sResponsable" + for semestre_id in semestre_ids: + if formation.is_apc(): + # pour restreindre l'édition aux module du semestre sélectionné + tr_class = 'class="sem{semestre_id}"' + else: + tr_class = "" + if edit: + templ_sep = f"""%(label)sResponsableInscrire""" + else: + templ_sep = ( + f"""%(label)sResponsable""" + ) modform.append( ( "sep", @@ -591,12 +603,12 @@ def do_formsemestre_createwithmodules(edit=False): ) fcg += "" itemtemplate = ( - """%(label)s%(elem)s""" + f"""%(label)s%(elem)s""" + fcg + "" ) else: - itemtemplate = """%(label)s%(elem)s""" + itemtemplate = f"""%(label)s%(elem)s""" modform.append( ( "MI" + str(mod["module_id"]), diff --git a/app/static/js/formsemestre_edit.js b/app/static/js/formsemestre_edit.js new file mode 100644 index 00000000..3394d659 --- /dev/null +++ b/app/static/js/formsemestre_edit.js @@ -0,0 +1,14 @@ +// Formulaire formsemestre_createwithmodules + +function change_semestre_id() { + var semestre_id = $("#tf_semestre_id")[0].value; + for (var i = -1; i < 12; i++) { + $(".sem" + i).hide(); + } + $(".sem" + semestre_id).show(); +} + + +$(window).on('load', function () { + change_semestre_id(); +}); \ No newline at end of file