fix plantage si un seul groupe ; correction indentation for radio button in wtf_forms (css)

This commit is contained in:
Jean-Marie Place 2021-09-19 08:21:08 +02:00
parent 13c027fc19
commit a5ed9b815f
2 changed files with 25 additions and 11 deletions

View File

@ -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]

View File

@ -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;