diff --git a/benefits/core/widgets.py b/benefits/core/widgets.py index 5ea06d2f9..9500215db 100644 --- a/benefits/core/widgets.py +++ b/benefits/core/widgets.py @@ -24,9 +24,10 @@ class VerifierRadioSelect(widgets.RadioSelect): template_name = "core/widgets/verifier_radio_select.html" option_template_name = "core/widgets/verifier_radio_select_option.html" - def __init__(self, selection_label_templates=(), *args, **kwargs): + def __init__(self, selection_label_templates=(), csp_nonce=None, *args, **kwargs): super().__init__(*args, **kwargs) self.selection_label_templates = list(selection_label_templates) + self.csp_nonce = csp_nonce def __deepcopy__(self, memo): obj = super().__deepcopy__(memo) @@ -37,6 +38,6 @@ def create_option(self, name, value, label, selected, index, subindex, attrs): option = super().create_option(name, value, label, selected, index, subindex, attrs) # this implementation does not support groups from ChoiceWidget.optgroups if value in self.selection_label_templates: - option.update({"selection_label_template": self.selection_label_templates[value]}) + option.update({"selection_label_template": self.selection_label_templates[value], "csp_nonce": self.csp_nonce}) return option diff --git a/benefits/eligibility/forms.py b/benefits/eligibility/forms.py index d92d7e0ab..15123f76c 100644 --- a/benefits/eligibility/forms.py +++ b/benefits/eligibility/forms.py @@ -23,7 +23,7 @@ class EligibilityVerifierSelectionForm(forms.Form): # sets label to empty string so the radio_select template can override the label style submit_value = _("eligibility.buttons.choose") - def __init__(self, agency: models.TransitAgency, *args, **kwargs): + def __init__(self, agency: models.TransitAgency, csp_nonce=None, *args, **kwargs): super().__init__(*args, **kwargs) verifiers = agency.eligibility_verifiers.all() @@ -32,6 +32,7 @@ def __init__(self, agency: models.TransitAgency, *args, **kwargs): # therefore set to None self.fields["verifier"].choices = [(v.id, None) for v in verifiers] self.fields["verifier"].widget.selection_label_templates = {v.id: v.selection_label_template for v in verifiers} + self.fields["verifier"].widget.csp_nonce = csp_nonce def clean(self): if not recaptcha.verify(self.data): diff --git a/benefits/eligibility/templates/eligibility/includes/selection-label--senior.html b/benefits/eligibility/templates/eligibility/includes/selection-label--senior.html index 59149f313..afd3ad46e 100644 --- a/benefits/eligibility/templates/eligibility/includes/selection-label--senior.html +++ b/benefits/eligibility/templates/eligibility/includes/selection-label--senior.html @@ -14,4 +14,11 @@ {% include "eligibility/includes/modal--senior-help.html" with id="login-gov-help" %} + + {% endblock description %} diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py index ced9f3164..e71473751 100644 --- a/benefits/eligibility/views.py +++ b/benefits/eligibility/views.py @@ -61,7 +61,7 @@ def index(request, agency=None): title=_("eligibility.pages.index.title"), headline=_("eligibility.pages.index.headline"), paragraphs=[intro], - forms=forms.EligibilityVerifierSelectionForm(agency=agency), + forms=forms.EligibilityVerifierSelectionForm(agency=agency, csp_nonce=request.csp_nonce), ) ctx = page.context_dict()