minor code cleaning

This commit is contained in:
Emmanuel Viennet 2022-10-02 20:44:24 +02:00
parent f69ce75b1f
commit ad46a190ab
2 changed files with 15 additions and 24 deletions

View File

@ -543,11 +543,8 @@ class TF(object):
disabled_items = descr.get("disabled_items", {})
if vertical:
lem.append("<table>")
for i in range(len(labels)):
for i in range(len(labels)): # pylint: disable=consider-using-enumerate
if input_type == "checkbox":
# from app.scodoc.sco_utils import log # debug only
# log('checkbox: values[%s] = "%s"' % (field,repr(values[field]) ))
# log("descr['allowed_values'][%s] = '%s'" % (i, repr(descr['allowed_values'][i])))
if (
values[field]
and descr["allowed_values"][i] in values[field]
@ -563,7 +560,7 @@ class TF(object):
else:
try:
v = int(values[field])
except:
except (ValueError, KeyError):
v = False
if v:
checked = 'checked="checked"'

View File

@ -2113,28 +2113,22 @@ class BasePreferences(object):
if "explanation" in descr:
del descr["explanation"]
if formsemestre_id:
descr["explanation"] = (
"""ou <span class="spanlink" onclick="set_global_pref(this, '%s');">utiliser paramètre global</span>"""
% pref_name
)
# if descr.get('only_global',False):
# # pas modifiable, donne juste la valeur courante
# descr['readonly'] = True
# descr['explanation'] = '(valeur globale, non modifiable)'
# elif
descr[
"explanation"
] = """ou <span class="spanlink"
onclick="set_global_pref(this, '{pref_name}');"
>utiliser paramètre global</span>"""
if formsemestre_id and self.is_global(formsemestre_id, pref_name):
# valeur actuelle globale (ou vient d'etre supprimee localement):
# montre la valeur et menus pour la rendre locale
descr["readonly"] = True
menu_global = (
"""<select class="tf-selglobal" onchange="sel_global(this, '%s');">
menu_global = f"""<select class="tf-selglobal"
onchange="sel_global(this, '{pref_name}');">
<option value="">Valeur définie globalement</option>
<option value="create">Spécifier valeur pour ce semestre seulement</option>
<option value="create">Spécifier valeur pour ce
semestre seulement</option>
</select>
"""
% pref_name
)
# <option value="changeglobal">Changer paramètres globaux</option>
descr["explanation"] = menu_global
cat_elems.append((pref_name, descr))
@ -2144,18 +2138,18 @@ class BasePreferences(object):
if title:
form.append(
(
"sep_%s" % cat,
{"input_type": "separator", "title": "<h3>%s</h3>" % title},
f"sep_{cat}",
{"input_type": "separator", "title": f"<h3>{title}</h3>"},
)
)
subtitle = cat_descr.get("subtitle", None)
if subtitle:
form.append(
(
"sepsub_%s" % cat,
f"sepsub_{cat}",
{
"input_type": "separator",
"title": '<p class="help">%s</p>' % subtitle,
"title": f'<p class="help">{subtitle}</p>',
},
)
)