Qq corrections cosmétiques du HTML + config mypy

This commit is contained in:
Emmanuel Viennet 2023-12-07 15:34:49 +01:00
parent cf3319dcc0
commit 772293e06f
3 changed files with 13 additions and 12 deletions

2
.mypy.ini Normal file
View File

@ -0,0 +1,2 @@
[mypy-flask_login.*]
ignore_missing_imports = True

View File

@ -429,7 +429,7 @@ class TF(object):
buttons_markup = "" buttons_markup = ""
if self.submitbutton: if self.submitbutton:
buttons_markup += ( buttons_markup += (
'<input type="submit" name="%s_submit" id="%s_submit" value="%s" %s>' '<input type="submit" name="%s_submit" id="%s_submit" value="%s" %s/>'
% ( % (
self.formid, self.formid,
self.formid, self.formid,
@ -471,9 +471,9 @@ class TF(object):
R.append( R.append(
f"""<input type="hidden" name="csrf_token" value="{ f"""<input type="hidden" name="csrf_token" value="{
flask_wtf.csrf.generate_csrf() flask_wtf.csrf.generate_csrf()
}">""" }"/>"""
) )
R.append(f"""<input type="hidden" name="{self.formid}_submitted" value="1">""") R.append(f"""<input type="hidden" name="{self.formid}_submitted" value="1"/>""")
if self.top_buttons: if self.top_buttons:
R.append(buttons_markup + "<p></p>") R.append(buttons_markup + "<p></p>")
R.append(self.before_table.format(title=self.title)) R.append(self.before_table.format(title=self.title))
@ -524,7 +524,7 @@ class TF(object):
else: else:
checked = "" checked = ""
lab.append( lab.append(
'<input type="checkbox" name="%s:list" value="%s" onclick="tf_enable_elem(this)" %s>' '<input type="checkbox" name="%s:list" value="%s" onclick="tf_enable_elem(this)" %s/>'
% ("tf-checked", field, checked) % ("tf-checked", field, checked)
) )
if title_bubble: if title_bubble:
@ -663,12 +663,12 @@ class TF(object):
if descr.get("type", "") == "list": if descr.get("type", "") == "list":
for v in values[field]: for v in values[field]:
lem.append( lem.append(
'<input type="hidden" name="%s:list" value="%s" %s >' '<input type="hidden" name="%s:list" value="%s" %s />'
% (field, v, attribs) % (field, v, attribs)
) )
else: else:
lem.append( lem.append(
'<input type="hidden" name="%s" id="%s" value="%s" %s >' '<input type="hidden" name="%s" id="%s" value="%s" %s />'
% (field, wid, values[field], attribs) % (field, wid, values[field], attribs)
) )
elif (input_type == "separator") or (input_type == "table_separator"): elif (input_type == "separator") or (input_type == "table_separator"):
@ -746,7 +746,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
break; break;
i = i + 1; i = i + 1;
while (i < elem.form.elements.length) { while (i < elem.form.elements.length) {
if ((elem.form.elements[i].type == "text") if ((elem.form.elements[i].type == "text")
&& (!(elem.form.elements[i].disabled)) && (!(elem.form.elements[i].disabled))
&& ($(elem.form.elements[i]).is(':visible'))) && ($(elem.form.elements[i]).is(':visible')))
{ {
@ -760,7 +760,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
elem.blur(); elem.blur();
} }
return false; return false;
} }
else else
return true; return true;
}</script> }</script>
@ -771,7 +771,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
# => only one form with text_suggest field on a page. # => only one form with text_suggest field on a page.
R.append( R.append(
"""<script type="text/javascript"> """<script type="text/javascript">
function init_tf_form(formid) { function init_tf_form(formid) {
%s %s
} }
</script>""" </script>"""
@ -839,7 +839,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
bool_val = 0 bool_val = 0
R.append(labels[bool_val]) R.append(labels[bool_val])
if bool_val: if bool_val:
R.append('<input type="hidden" name="%s" value="1">' % field) R.append(f'<input type="hidden" name="{field}" value="1"/>')
else: else:
labels = descr.get("labels", descr["allowed_values"]) labels = descr.get("labels", descr["allowed_values"])
for i in range(len(labels)): for i in range(len(labels)):
@ -858,7 +858,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
elif input_type == "file": elif input_type == "file":
R.append("'%s'" % self.values[field]) R.append("'%s'" % self.values[field])
else: else:
raise ValueError("unkown input_type for form (%s)!" % input_type) raise ValueError(f"unkown input_type for form ({input_type})!")
explanation = descr.get("explanation", "") explanation = descr.get("explanation", "")
if explanation: if explanation:

View File

@ -222,7 +222,6 @@ def create_user_form(user_name=None, edit=0, all_roles=True):
all_roles = int(all_roles) all_roles = int(all_roles)
H = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
bodyOnLoad="init_tf_form('')",
javascripts=["js/user_form.js"], javascripts=["js/user_form.js"],
) )
] ]