From c11fccab02409c4398571d62495c10100278444f Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 2 May 2022 10:54:52 +0200 Subject: [PATCH] Edition tag sur modules --- app/scodoc/sco_edit_module.py | 7 +++++-- app/scodoc/sco_tag_module.py | 4 ++-- app/static/css/scodoc.css | 11 +++++++++++ app/views/notes.py | 17 +++++++++++------ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 3aa00452e9..57b4f81050 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -866,6 +866,7 @@ def module_edit( { "input_type": "checkbox", "vertical": True, + "dom_id": "tf_module_parcours", "labels": [parcour.libelle for parcour in ref_comp.parcours], "allowed_values": [ str(parcour.id) for parcour in ref_comp.parcours @@ -904,9 +905,11 @@ def module_edit( request.base_url, scu.get_request_args(), descr, - html_foot_markup="""
""".format( + html_foot_markup="""
""".format( module_id, ",".join(sco_tag_module.module_tag_list(module_id)) - ), + ) + if not create + else "", initvalues=module_dict if module else {}, submitlabel="Modifier ce module" if module else "Créer ce module", cancelbutton="Annuler", diff --git a/app/scodoc/sco_tag_module.py b/app/scodoc/sco_tag_module.py index 1b41cd876e..20c340f1ff 100644 --- a/app/scodoc/sco_tag_module.py +++ b/app/scodoc/sco_tag_module.py @@ -235,7 +235,7 @@ def module_tag_list(module_id=""): def module_tag_set(module_id="", taglist=None): """taglist may either be: - a string with tag names separated by commas ("un;deux") + a string with tag names separated by commas ("un,deux") or a list of strings (["un", "deux"]) """ if not taglist: @@ -243,7 +243,7 @@ def module_tag_set(module_id="", taglist=None): elif isinstance(taglist, str): taglist = taglist.split(",") taglist = [t.strip() for t in taglist] - # log("module_tag_set: module_id=%s taglist=%s" % (module_id, taglist)) + log("module_tag_set: module_id=%s taglist=%s" % (module_id, taglist)) # Sanity check: Mod = sco_edit_module.module_list(args={"module_id": module_id}) if not Mod: diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index 2c7d4652fb..170d191744 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -2267,6 +2267,10 @@ span.missing_value { color: red; } +tr#tf_module_parcours>td { + background-color: rgb(229, 229, 229); +} + /* tableau recap notes */ table.notes_recapcomplet { border: 2px solid blue; @@ -3635,6 +3639,13 @@ span.sco_tag_edit .tag-editor { margin-top: 2px; } +div.sco_tag_module_edit span.sco_tag_edit .tag-editor { + background-color: rgb(210, 210, 210); + border: 0px; + margin-left: 0px; + margin-top: 2px; +} + span.sco_tag_edit .tag-editor-delete { height: 20px; } diff --git a/app/views/notes.py b/app/views/notes.py index e288a9bc4a..c8b6cc20af 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -543,12 +543,17 @@ sco_publish( ) sco_publish("/module_list", sco_edit_module.module_table, Permission.ScoView) sco_publish("/module_tag_search", sco_tag_module.module_tag_search, Permission.ScoView) -sco_publish( - "/module_tag_set", - sco_tag_module.module_tag_set, - Permission.ScoEditFormationTags, - methods=["GET", "POST"], -) + + +@bp.route("/module_tag_set", methods=["POST"]) +@scodoc +@permission_required(Permission.ScoEditFormationTags) +def module_tag_set(): + """Set tags on module""" + module_id = int(request.form.get("module_id")) + taglist = request.form.get("taglist") + return sco_tag_module.module_tag_set(module_id, taglist) + # @bp.route("/")