diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py
index df31c1d26..bb9bb7f20 100644
--- a/app/scodoc/TrivialFormulator.py
+++ b/app/scodoc/TrivialFormulator.py
@@ -701,8 +701,17 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
labels = descr.get(
"labels", descr.get("allowed_values", ["oui", "non"])
)
- R.append(labels[int(self.values[field])])
- if int(self.values[field]):
+ _val = self.values[field]
+ if isinstance(_val, bool):
+ bool_val = 1 if _val else 0
+ elif _val == "False":
+ bool_val = 0
+ elif _val:
+ bool_val = 1
+ else:
+ bool_val = 0
+ R.append(labels[bool_val])
+ if bool_val:
R.append('' % field)
else:
labels = descr.get("labels", descr["allowed_values"])
diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py
index 50d964151..08b1f9a7e 100644
--- a/app/scodoc/sco_formsemestre_edit.py
+++ b/app/scodoc/sco_formsemestre_edit.py
@@ -1600,9 +1600,9 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
cnx, args={"formsemestre_id": formsemestre_id, "ue_id": ue["ue_id"]}
)
if coefs:
- initvalues["ue_" + ue["ue_id"]] = coefs[0]["coefficient"]
+ initvalues["ue_" + str(ue["ue_id"])] = coefs[0]["coefficient"]
else:
- initvalues["ue_" + ue["ue_id"]] = "auto"
+ initvalues["ue_" + str(ue["ue_id"])] = "auto"
descr = {
"size": 10,
"title": ue["acronyme"],
@@ -1610,7 +1610,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
}
if ue["ue_id"] == err_ue_id:
descr["dom_id"] = "erroneous_ue"
- form.append(("ue_" + ue["ue_id"], descr))
+ form.append(("ue_" + str(ue["ue_id"]), descr))
tf = TrivialFormulator(
REQUEST.URL0,
@@ -1632,7 +1632,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
ue_modified = []
msg = []
for ue in ues:
- val = tf[2]["ue_" + ue["ue_id"]]
+ val = tf[2]["ue_" + str(ue["ue_id"])]
coefs = sco_formsemestre.formsemestre_uecoef_list(
cnx, args={"formsemestre_id": formsemestre_id, "ue_id": ue["ue_id"]}
)
diff --git a/app/scodoc/sco_formsemestre_exterieurs.py b/app/scodoc/sco_formsemestre_exterieurs.py
index a46ce8050..ca8b4370c 100644
--- a/app/scodoc/sco_formsemestre_exterieurs.py
+++ b/app/scodoc/sco_formsemestre_exterieurs.py
@@ -229,7 +229,8 @@ def formsemestre_ext_edit_ue_validations(
descr = _ue_form_description(context, ue_list, REQUEST.form)
if REQUEST and REQUEST.method == "GET":
initvalues = {
- "note_" + ue["ue_id"]: ue["validation"].get("moy_ue", "") for ue in ue_list
+ "note_" + str(ue["ue_id"]): ue["validation"].get("moy_ue", "")
+ for ue in ue_list
}
else:
initvalues = {}
@@ -326,11 +327,11 @@ def _ue_form_description(context, ue_list, values):
for ue in ue_list:
# Menu pour code validation UE:
# Ne propose que ADM, CMP et "Non inscrit"
- select_name = "valid_" + ue["ue_id"]
+ select_name = "valid_" + str(ue["ue_id"])
menu_code_UE = """"
- cur_value = values.get("coef_" + ue["ue_id"], False)
+ cur_value = values.get("coef_" + str(ue["ue_id"]), False)
if cur_value is False: # pas dans le form, cherche en base
cur_value = ue["uecoef"].get("coefficient", "")
itemtemplate = (
@@ -389,15 +390,15 @@ def _check_values(context, ue_list, values):
"""
for ue in ue_list:
pu = " pour UE %s" % ue["acronyme"]
- code = values.get("valid_" + ue["ue_id"], False)
+ code = values.get("valid_" + str(ue["ue_id"]), False)
if code == "None":
code = None
- note = values.get("note_" + ue["ue_id"], False)
+ note = values.get("note_" + str(ue["ue_id"]), False)
try:
note = _convert_field_to_float(note)
except ValueError:
return False, "note invalide" + pu
- coef = values.get("coef_" + ue["ue_id"], False)
+ coef = values.get("coef_" + str(ue["ue_id"]), False)
try:
coef = _convert_field_to_float(coef)
except ValueError:
@@ -472,12 +473,12 @@ def _record_ue_validations_and_coefs(
context, formsemestre_id, etudid, ue_list, values, REQUEST=None
):
for ue in ue_list:
- code = values.get("valid_" + ue["ue_id"], False)
+ code = values.get("valid_" + str(ue["ue_id"]), False)
if code == "None":
code = None
- note = values.get("note_" + ue["ue_id"], False)
+ note = values.get("note_" + str(ue["ue_id"]), False)
note = _convert_field_to_float(note)
- coef = values.get("coef_" + ue["ue_id"], False)
+ coef = values.get("coef_" + str(ue["ue_id"]), False)
coef = _convert_field_to_float(coef)
if coef == "" or coef == False:
coef = None
diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py
index e713e601d..bf87dac02 100644
--- a/app/scodoc/sco_preferences.py
+++ b/app/scodoc/sco_preferences.py
@@ -1424,7 +1424,7 @@ class BasePreferences(object):
{
"initvalue": None,
"title": "Bulletins PDF: largeur col. modules",
- "explanation": "en cm (vide si auto)",
+ "explanation": "en cm (vide ou 0 si auto)",
"type": "float",
"category": "bul",
},
@@ -1816,10 +1816,18 @@ class BasePreferences(object):
and self.prefs_dict[p["name"]].get("input_type", None)
== "boolcheckbox"
):
+ # boolcheckbox: la valeur stockée en base est une chaine "0" ou "1"
+ # que l'on ressort en True|False
if p["value"]:
- p["value"] = int(p["value"]) # boolcheckboxes are always 0/1
+ try:
+ p["value"] = bool(int(p["value"]))
+ except ValueError:
+ log(
+ f"""Warning: invalid value for boolean pref in db: '{p["value"]}'"""
+ )
+ p["value"] = False
else:
- p["value"] = 0 # NULL (backward compat)
+ p["value"] = False # NULL (backward compat)
self.prefs[p["formsemestre_id"]][p["name"]] = p["value"]
# add defaults for missing prefs
@@ -1885,6 +1893,9 @@ class BasePreferences(object):
names = [name]
for name in names:
value = self.get(formsemestre_id, name)
+ if self.prefs_dict[name].get("input_type", None) == "boolcheckbox":
+ # repasse les booleens en chaines "0":"1"
+ value = "1" if value else "0"
# existe deja ?
pdb = self._editor.list(
cnx, args={"formsemestre_id": formsemestre_id, "name": name}
@@ -2187,7 +2198,7 @@ function set_global_pref(el, pref_name) {
return flask.redirect(dest_url + "&head_message=Préférences modifiées")
elif destination == "again":
return flask.redirect(
- REQUEST.URL0 + "?formsemestre_id=" + self.formsemestre_id
+ REQUEST.URL0 + "?formsemestre_id=" + str(self.formsemestre_id)
)
elif destination == "global":
return flask.redirect(scu.ScoURL() + "/edit_preferences")
diff --git a/app/views/notes.py b/app/views/notes.py
index b83810922..a0d11493a 100644
--- a/app/views/notes.py
+++ b/app/views/notes.py
@@ -313,6 +313,12 @@ sco_publish(
sco_edit_ue.edit_ue_set_code_apogee,
Permission.ScoChangeFormation,
)
+sco_publish(
+ "/formsemestre_edit_uecoefs",
+ sco_formsemestre_edit.formsemestre_edit_uecoefs,
+ Permission.ScoView,
+ methods=["GET", "POST"],
+)
sco_publish(
"/formation_table_recap", sco_edit_ue.formation_table_recap, Permission.ScoView
)
diff --git a/app/views/scolar.py b/app/views/scolar.py
index 725573ee6..b5ec950ee 100644
--- a/app/views/scolar.py
+++ b/app/views/scolar.py
@@ -2077,10 +2077,5 @@ sco_publish(
)
#
-sco_publish(
- "/formsemestre_edit_uecoefs",
- sco_formsemestre_edit.formsemestre_edit_uecoefs,
- Permission.ScoView,
-)
context.populate(globals())