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", {}) disabled_items = descr.get("disabled_items", {})
if vertical: if vertical:
lem.append("<table>") lem.append("<table>")
for i in range(len(labels)): for i in range(len(labels)): # pylint: disable=consider-using-enumerate
if input_type == "checkbox": 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 ( if (
values[field] values[field]
and descr["allowed_values"][i] in values[field] and descr["allowed_values"][i] in values[field]
@ -563,7 +560,7 @@ class TF(object):
else: else:
try: try:
v = int(values[field]) v = int(values[field])
except: except (ValueError, KeyError):
v = False v = False
if v: if v:
checked = 'checked="checked"' checked = 'checked="checked"'

View File

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