diff --git a/benefits/core/models/enrollment.py b/benefits/core/models/enrollment.py index 14f897747..59975425a 100644 --- a/benefits/core/models/enrollment.py +++ b/benefits/core/models/enrollment.py @@ -264,7 +264,7 @@ def in_person_eligibility_context(self): return eligibility[system_name].dict() if system_name in eligibility.keys() else {} def clean(self): - template_errors = [] + errors = [] if self.transit_agency: templates = [ @@ -282,10 +282,14 @@ def clean(self): # so just create directly for a missing template for t in templates: if not template_path(t): - template_errors.append(ValidationError(f"Template not found: {t}")) + errors.append(ValidationError(f"Template not found: {t}")) - if template_errors: - raise ValidationError(template_errors) + if EnrollmentMethods.IN_PERSON in self.supported_enrollment_methods: + if not self.in_person_eligibility_context: + errors.append(ValidationError(f"In-person eligibility context not found for: {self.system_name}")) + + if errors: + raise ValidationError(errors) def eligibility_form_instance(self, *args, **kwargs): """Return an instance of this flow's EligibilityForm, or None.""" diff --git a/benefits/in_person/forms.py b/benefits/in_person/forms.py index 40a6e59fa..09512a836 100644 --- a/benefits/in_person/forms.py +++ b/benefits/in_person/forms.py @@ -30,7 +30,7 @@ def __init__(self, agency: models.TransitAgency, *args, **kwargs): self.classes = "in-person-eligibility-form" flow_field = self.fields["flow"] - flow_field.choices = [(f.id, f.label) for f in flows] + flow_field.choices = [(f.id, f.label) for f in flows if self.get_policy_details(f)] flow_field.widget.attrs.update({"data-custom-validity": self.flow_field_error_message}) # dynamically add a BooleanField for each flow