Skip to content

Commit

Permalink
feat(admin): add SupportedMethods (digital, in-person) multiselect to…
Browse files Browse the repository at this point in the history
… EnrollmentFlow
  • Loading branch information
machikoyasuda committed Sep 19, 2024
1 parent feb06d2 commit d0c55ab
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
24 changes: 24 additions & 0 deletions benefits/core/migrations/0027_enrollmentflow_supported_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1 on 2024-09-19 20:45

import multiselectfield.db.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("core", "0026_enrollmentevent"),
]

operations = [
migrations.AddField(
model_name="enrollmentflow",
name="supported_methods",
field=multiselectfield.db.fields.MultiSelectField(
choices=[("digital", "Digital"), ("in_person", "In-person")],
default=["digital", "in_person"],
help_text="If the flow is supported by digital enrollment, in-person enrollment, or both",
max_length=17,
),
),
]
23 changes: 18 additions & 5 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from benefits.routes import routes
from benefits.secrets import NAME_VALIDATOR, get_secret_by_name
from multiselectfield import MultiSelectField


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -104,6 +105,17 @@ def __str__(self) -> str:
return self.client_name


class EnrollmentMethods:
DIGITAL = "digital"
IN_PERSON = "in_person"


SUPPORTED_METHODS = (
(EnrollmentMethods.DIGITAL, EnrollmentMethods.DIGITAL.capitalize()),
(EnrollmentMethods.IN_PERSON, EnrollmentMethods.IN_PERSON.replace("_", "-").capitalize()),
)


class EnrollmentFlow(models.Model):
"""Represents a user journey through the Benefits app for a single eligibility type."""

Expand Down Expand Up @@ -216,6 +228,12 @@ class EnrollmentFlow(models.Model):
enrollment_success_template = models.TextField(
default="enrollment/success.html", help_text="Template for a successful enrollment associated with the enrollment flow"
)
supported_methods = MultiSelectField(
choices=SUPPORTED_METHODS,
max_choices=2,
default=[EnrollmentMethods.DIGITAL, EnrollmentMethods.IN_PERSON],
help_text="If the flow is supported by digital enrollment, in-person enrollment, or both",
)

class Meta:
ordering = ["display_order"]
Expand Down Expand Up @@ -426,11 +444,6 @@ def for_user(user: User):
return None


class EnrollmentMethods:
DIGITAL = "digital"
IN_PERSON = "in_person"


class EnrollmentEvent(models.Model):
"""A record of a successful enrollment."""

Expand Down
7 changes: 7 additions & 0 deletions tests/pytest/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ def test_EnrollmentFlow_enrollment_success_template():
assert new_flow.enrollment_success_template == "enrollment/success.html"


@pytest.mark.django_db
def test_EnrollmentFlow_supported_methods():
new_flow = EnrollmentFlow.objects.create()

assert new_flow.supported_methods == ["digital", "in_person"]


class SampleFormClass:
"""A class for testing EligibilityVerificationForm references."""

Expand Down

0 comments on commit d0c55ab

Please sign in to comment.