snapshot: preserve handbook, bilingual phase 2, and logo updates

This commit is contained in:
Md Bayazid Bostame
2026-03-24 12:25:43 +01:00
parent 0f285aa2cf
commit 4d3c7bdf6e
26 changed files with 625 additions and 66 deletions

View File

@@ -1,4 +1,5 @@
from collections import OrderedDict
from django.utils.translation import get_language
from .models import FormFieldConfig
@@ -154,17 +155,20 @@ def apply_form_field_config(form_type: str, form) -> None:
field_names = list(form.fields.keys())
configs = _ensure_configs(form_type, field_names)
locked = LOCKED_FIELD_RULES.get(form_type, set())
language_code = get_language()
for field_name, field in list(form.fields.items()):
cfg = configs.get(field_name)
if not cfg:
continue
if cfg.label_override.strip():
field.label = cfg.label_override.strip()
translated_label = cfg.translated_label_override(language_code)
if translated_label:
field.label = translated_label
if cfg.help_text_override.strip():
field.help_text = cfg.help_text_override.strip()
translated_help_text = cfg.translated_help_text_override(language_code)
if translated_help_text:
field.help_text = translated_help_text
if field_name not in locked and cfg.is_required is not None:
field.required = cfg.is_required