From 6996596872876053a2a46eb04ec194e1218ddcb0 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Sep 2024 21:35:27 +0000 Subject: [PATCH 1/4] feat(enrollmentflow): add supported_method field with multiselct radio buttons --- .../0027_enrollmentflow_supported_methods.py | 24 +++++++++++++++++++ benefits/core/models.py | 24 +++++++++++++++---- pyproject.toml | 1 + tests/pytest/core/test_models.py | 7 ++++++ 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 benefits/core/migrations/0027_enrollmentflow_supported_methods.py diff --git a/benefits/core/migrations/0027_enrollmentflow_supported_methods.py b/benefits/core/migrations/0027_enrollmentflow_supported_methods.py new file mode 100644 index 000000000..fb4822b91 --- /dev/null +++ b/benefits/core/migrations/0027_enrollmentflow_supported_methods.py @@ -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=50, + ), + ), + ] diff --git a/benefits/core/models.py b/benefits/core/models.py index 25abfea16..421d9bc0d 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -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__) @@ -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.""" @@ -216,6 +228,13 @@ 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, + max_length=50, + 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"] @@ -426,11 +445,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.""" diff --git a/pyproject.toml b/pyproject.toml index c960d9b11..daa60768a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ dependencies = [ "requests==2.32.3", "sentry-sdk==2.14.0", "six==1.16.0", + "django-multiselectfield==0.1.12", ] [project.optional-dependencies] diff --git a/tests/pytest/core/test_models.py b/tests/pytest/core/test_models.py index ac49a08df..4afb331c5 100644 --- a/tests/pytest/core/test_models.py +++ b/tests/pytest/core/test_models.py @@ -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.""" From b50477e8c1033c41cdad3c31ae0a2adf67244e15 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Mon, 23 Sep 2024 19:13:04 +0000 Subject: [PATCH 2/4] chore: update django-multiselectfield to latest --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index daa60768a..d8513f858 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dependencies = [ "requests==2.32.3", "sentry-sdk==2.14.0", "six==1.16.0", - "django-multiselectfield==0.1.12", + "django-multiselectfield==0.1.13", ] [project.optional-dependencies] From 8a878ad6f1a5545aa0b93d96cd2feba78a07bb83 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Mon, 23 Sep 2024 21:31:22 +0000 Subject: [PATCH 3/4] chore(fixtures): set existing flows to both and add in-person, digital only flows --- benefits/core/migrations/local_fixtures.json | 42 +++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/benefits/core/migrations/local_fixtures.json b/benefits/core/migrations/local_fixtures.json index 48994f3e4..5280364c0 100644 --- a/benefits/core/migrations/local_fixtures.json +++ b/benefits/core/migrations/local_fixtures.json @@ -61,7 +61,8 @@ "selection_label_template": "eligibility/includes/selection-label--senior.html", "eligibility_start_template": "eligibility/start--senior.html", "claims_scope": "verify:senior", - "claims_claim": "senior" + "claims_claim": "senior", + "supported_methods": ["digital", "in_person"] } }, { @@ -77,7 +78,8 @@ "selection_label_template": "eligibility/includes/selection-label--veteran.html", "eligibility_start_template": "eligibility/start--veteran.html", "claims_scope": "verify:veteran", - "claims_claim": "veteran" + "claims_claim": "veteran", + "supported_methods": ["digital", "in_person"] } }, { @@ -101,7 +103,8 @@ "eligibility_start_template": "eligibility/start--cst-agency-card.html", "eligibility_form_class": "benefits.eligibility.forms.CSTAgencyCard", "eligibility_unverified_template": "eligibility/unverified--cst-agency-card.html", - "help_template": "core/includes/help--cst-agency-card.html" + "help_template": "core/includes/help--cst-agency-card.html", + "supported_methods": ["digital", "in_person"] } }, { @@ -122,7 +125,8 @@ "eligibility_start_template": "eligibility/start--calfresh.html", "help_template": "core/includes/help--calfresh.html", "claims_scope": "verify:calfresh", - "claims_claim": "calfresh" + "claims_claim": "calfresh", + "supported_methods": ["digital", "in_person"] } }, { @@ -138,7 +142,35 @@ "selection_label_template": "eligibility/includes/selection-label--medicare.html", "eligibility_start_template": "eligibility/start--medicare.html", "claims_scope": "verify:medicare", - "claims_claim": "medicare" + "claims_claim": "medicare", + "supported_methods": ["digital", "in_person"] + } + }, + { + "model": "core.enrollmentflow", + "pk": 6, + "fields": { + "system_name": "in_person_only", + "label": "(CST) In-person Only", + "group_id": "group123", + "supported_methods": ["in_person"] + } + }, + { + "model": "core.enrollmentflow", + "pk": 7, + "fields": { + "system_name": "digital_only", + "label": "(CST) Digital Only", + "group_id": "group123", + "enrollment_success_template": "enrollment/success--cst.html", + "display_order": 5, + "claims_provider": 1, + "selection_label_template": "eligibility/includes/selection-label--senior.html", + "eligibility_start_template": "eligibility/start--senior.html", + "claims_scope": "verify:senior", + "claims_claim": "senior", + "supported_methods": ["digital"] } }, { From 0162e645bfadd8242d54195d1d8107f1e2071892 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Mon, 23 Sep 2024 21:42:42 +0000 Subject: [PATCH 4/4] refactor: rename to supported_enrollment_methods --- .../0027_enrollmentflow_supported_methods.py | 2 +- benefits/core/migrations/local_fixtures.json | 14 +++++++------- benefits/core/models.py | 2 +- tests/pytest/core/test_models.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benefits/core/migrations/0027_enrollmentflow_supported_methods.py b/benefits/core/migrations/0027_enrollmentflow_supported_methods.py index fb4822b91..038c2a32d 100644 --- a/benefits/core/migrations/0027_enrollmentflow_supported_methods.py +++ b/benefits/core/migrations/0027_enrollmentflow_supported_methods.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name="enrollmentflow", - name="supported_methods", + name="supported_enrollment_methods", field=multiselectfield.db.fields.MultiSelectField( choices=[("digital", "Digital"), ("in_person", "In-person")], default=["digital", "in_person"], diff --git a/benefits/core/migrations/local_fixtures.json b/benefits/core/migrations/local_fixtures.json index 5280364c0..f23679537 100644 --- a/benefits/core/migrations/local_fixtures.json +++ b/benefits/core/migrations/local_fixtures.json @@ -62,7 +62,7 @@ "eligibility_start_template": "eligibility/start--senior.html", "claims_scope": "verify:senior", "claims_claim": "senior", - "supported_methods": ["digital", "in_person"] + "supported_enrollment_methods": ["digital", "in_person"] } }, { @@ -79,7 +79,7 @@ "eligibility_start_template": "eligibility/start--veteran.html", "claims_scope": "verify:veteran", "claims_claim": "veteran", - "supported_methods": ["digital", "in_person"] + "supported_enrollment_methods": ["digital", "in_person"] } }, { @@ -104,7 +104,7 @@ "eligibility_form_class": "benefits.eligibility.forms.CSTAgencyCard", "eligibility_unverified_template": "eligibility/unverified--cst-agency-card.html", "help_template": "core/includes/help--cst-agency-card.html", - "supported_methods": ["digital", "in_person"] + "supported_enrollment_methods": ["digital", "in_person"] } }, { @@ -126,7 +126,7 @@ "help_template": "core/includes/help--calfresh.html", "claims_scope": "verify:calfresh", "claims_claim": "calfresh", - "supported_methods": ["digital", "in_person"] + "supported_enrollment_methods": ["digital", "in_person"] } }, { @@ -143,7 +143,7 @@ "eligibility_start_template": "eligibility/start--medicare.html", "claims_scope": "verify:medicare", "claims_claim": "medicare", - "supported_methods": ["digital", "in_person"] + "supported_enrollment_methods": ["digital", "in_person"] } }, { @@ -153,7 +153,7 @@ "system_name": "in_person_only", "label": "(CST) In-person Only", "group_id": "group123", - "supported_methods": ["in_person"] + "supported_enrollment_methods": ["in_person"] } }, { @@ -170,7 +170,7 @@ "eligibility_start_template": "eligibility/start--senior.html", "claims_scope": "verify:senior", "claims_claim": "senior", - "supported_methods": ["digital"] + "supported_enrollment_methods": ["digital"] } }, { diff --git a/benefits/core/models.py b/benefits/core/models.py index 421d9bc0d..644ddd0e2 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -228,7 +228,7 @@ 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( + supported_enrollment_methods = MultiSelectField( choices=SUPPORTED_METHODS, max_choices=2, max_length=50, diff --git a/tests/pytest/core/test_models.py b/tests/pytest/core/test_models.py index 4afb331c5..b09f86d40 100644 --- a/tests/pytest/core/test_models.py +++ b/tests/pytest/core/test_models.py @@ -187,10 +187,10 @@ def test_EnrollmentFlow_enrollment_success_template(): @pytest.mark.django_db -def test_EnrollmentFlow_supported_methods(): +def test_EnrollmentFlow_supported_enrollment_methods(): new_flow = EnrollmentFlow.objects.create() - assert new_flow.supported_methods == ["digital", "in_person"] + assert new_flow.supported_enrollment_methods == ["digital", "in_person"] class SampleFormClass: