March 17 2026: form editor - add pass/fail element

This commit is contained in:
2026-03-17 12:09:40 -04:00
parent 46df092a61
commit 33166bbc6b
7 changed files with 85 additions and 8 deletions
+10
View File
@@ -386,6 +386,8 @@ def _form_fields_section(form_fields, form_data, static_folder):
if ftype == 'checkbox':
# stored as 'true'/'false' by _collect_form_responses
return val not in ('yes', 'true')
if ftype == 'pass_fail':
return not val
if ftype == 'checkbox_group':
return not val or not isinstance(val, list) or len(val) == 0
if ftype == 'table':
@@ -429,6 +431,14 @@ def _form_fields_section(form_fields, form_data, static_folder):
elif ftype == 'checkbox':
val_p = Paragraph('Yes', STYLES['FieldValue'])
elif ftype == 'pass_fail':
is_pass = str(val).lower() in ('pass', 'yes', 'ok', 'good', 'acceptable', 'compliant')
colour = C_GREEN if is_pass else C_RED
val_p = Paragraph(
f'<font color="{colour.hexval()}">{str(val)}</font>',
STYLES['FieldValue'],
)
elif ftype == 'checkbox_group':
val_p = Paragraph(', '.join(val), STYLES['FieldValue'])