From a5ed9b815faeae04ee4454c19a3ac4799b202d07 Mon Sep 17 00:00:00 2001 From: Place Jean-Marie Date: Sun, 19 Sep 2021 08:21:08 +0200 Subject: [PATCH 1/2] fix plantage si un seul groupe ; correction indentation for radio button in wtf_forms (css) --- app/scodoc/sco_placement.py | 34 +++++++++++++++++++++++----------- app/static/css/scodoc.css | 2 ++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index ab9777b4..b304558e 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -89,6 +89,9 @@ def _get_group_info(evaluation_id): if partition != TOUS: has_groups = True nb_groups = len(groups_tree) + else: + has_groups = False + nb_groups = 1 return groups_tree, has_groups, nb_groups @@ -121,9 +124,7 @@ class PlacementForm(FlaskForm): ) groups = SelectMultipleField( "Groupe(s)", - validators=[ - wtforms.validators.DataRequired("indiquez au moins un groupe"), - ], + validators=[], ) submit = SubmitField("OK") @@ -131,8 +132,8 @@ class PlacementForm(FlaskForm): super().__init__(formdata=formdata, data=data) self.groups_tree = {} self.has_groups = None - self.group_tree_length = None self.nb_groups = None + self.tous_id = None self.set_evaluation_infos(data["evaluation_id"]) def set_evaluation_infos(self, evaluation_id): @@ -143,13 +144,20 @@ class PlacementForm(FlaskForm): self.groups_tree, self.has_groups, self.nb_groups = _get_group_info( evaluation_id ) - if self.has_groups: - choices = [] - for partition in self.groups_tree: - for groupe in self.groups_tree[partition]: + choices = [] + for partition in self.groups_tree: + for groupe in self.groups_tree[partition]: + if ( + groupe == TOUS + ): # Affichage et valeur spécifique pour le groupe TOUS + self.tous_id = str(self.groups_tree[partition][groupe]) + choices.append((TOUS, TOUS)) + else: groupe_id = str(self.groups_tree[partition][groupe]) choices.append((groupe_id, "%s (%s)" % (str(groupe), partition))) - self.groups.choices = choices + self.groups.choices = choices + # self.groups.default = [TOUS] # Ne fonctionnne pas... (ni dans la déclaration de PlaceForm.groups) + # la réponse [] est de toute façon transposée en [ self.tous_id ] lors du traitement (cas du groupe unique) class _DistributeurContinu: @@ -201,7 +209,6 @@ def placement_eval_selectetuds(evaluation_id): % runner.__dict__ ) return runner.exec_placement() # calcul et generation du fichier - # return flask.redirect(url_for("scodoc.index")) htmls = [ html_sco_header.sco_header(init_jquery_ui=True), sco_evaluations.evaluation_describe(evaluation_id=evaluation_id), @@ -224,7 +231,12 @@ class PlacementRunner: self.salle = form["salle"].data self.nb_rangs = form["nb_rangs"].data self.file_format = form["file_format"].data - self.groups_ids = form["groups"].data + if len(form["groups"].data) == 0: + self.groups_ids = [form.tous_id] + else: # On remplace le mot-clé TOUS le l'identiant de ce groupe + self.groups_ids = [ + gid if gid != TOUS else form.tous_id for gid in form["groups"].data + ] self.eval_data = sco_evaluations.do_evaluation_list( {"evaluation_id": self.evaluation_id} )[0] diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index a537bb96..82ada0fe 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -1094,6 +1094,8 @@ h2.formsemestre, .gtrcontent h2 { } .wtf-field li { display: inline; +}.wtf-field ul { + padding-left: 0; } .wtf-field .errors { color: red ; font-weight: bold; From 179be1baa0a0708aff8d50c6bcf8e8c9d357acf7 Mon Sep 17 00:00:00 2001 From: Place Jean-Marie Date: Sun, 19 Sep 2021 09:21:37 +0200 Subject: [PATCH 2/2] fix rang 1 twice in excel map --- app/scodoc/sco_placement.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index b304558e..a950c215 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -516,6 +516,7 @@ class PlacementRunner: cells_b = [ws0.make_cell("", self.styles["2b"])] cells_c = [ws0.make_cell("", self.styles["2b"])] row = 13 # première ligne de signature + rang += 1 for linetud in self.plan: cells_a.append(ws0.make_cell(linetud[0][0], self.styles["1t"])) # nom cells_b.append(ws0.make_cell(linetud[0][1], self.styles["1m"])) # prenom