Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Enrollment Flow for consistent labeling across apps #2403

Merged
merged 20 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2cd3f7c
refactor(models): change relationship for EnrollmentFlow and TransitA…
lalver1 Sep 25, 2024
c621385
chore(fixtures): remove enrollment_methods field from transitagency f…
machikoyasuda Sep 25, 2024
f401abe
test(fix): update enrollmentflow, agency changes on fixtures
machikoyasuda Sep 25, 2024
68864cc
fix(fixtures): add transit_agency_id to enrollmentflow
machikoyasuda Sep 25, 2024
208cf21
chore(fixtures): remove (CST) from flow label
machikoyasuda Sep 25, 2024
a73179e
chore(fixtures): give enrollmentflow label the human-readable name
machikoyasuda Sep 25, 2024
69f388e
test: update agency/flows relationship in tests
machikoyasuda Sep 25, 2024
2e2e1c0
fix(fixtures): remove digital, inperson only flows for now - breaking…
machikoyasuda Sep 25, 2024
a880802
feat(admin): display agency, supported methods on enrollmentflow list
machikoyasuda Sep 26, 2024
3bf128c
test(views): fix last test w/ mocked flow+session
machikoyasuda Sep 26, 2024
6afab54
feat(migration): add data migration so existing flows have an agency
machikoyasuda Sep 26, 2024
fc2139d
refactor(migration): rename migration to a more descriptive title
machikoyasuda Sep 30, 2024
5f92ab3
fix(fixtures): set transitagency directly with object, not id
machikoyasuda Sep 30, 2024
b73826d
fix(tests): assign transit_agency directly, not by id
machikoyasuda Sep 30, 2024
5d01dea
fix: remove old migration
machikoyasuda Sep 30, 2024
b2f0840
refactor(db): re-word helptext for enrollmentflow label
machikoyasuda Sep 30, 2024
4017f48
feat(db): allow enrollmentflow.transit_agency to be null
machikoyasuda Sep 30, 2024
a230cbf
fix(migration): allow enrollmentflow's transit agency to be null, all…
machikoyasuda Sep 30, 2024
2ffa3d1
refactor(db): combine migration into 1 and add migrate_data()
machikoyasuda Sep 30, 2024
4d7f09f
chore(tests): remove socket-disabling code
machikoyasuda Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions benefits/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def get_readonly_fields(self, request, obj=None):

@admin.register(models.EnrollmentFlow)
class SortableEnrollmentFlowAdmin(SortableAdminMixin, admin.ModelAdmin): # pragma: no cover
list_display = ("label", "transit_agency", "supported_enrollment_methods")

def get_exclude(self, request, obj=None):
if not request.user.is_superuser:
return [
Expand Down
machikoyasuda marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 5.1 on 2024-09-30 23:25

import django.db.models.deletion
from django.db import migrations, models


def migrate_data(apps, schema_editor):
TransitAgency = apps.get_model("core", "TransitAgency")
for agency in TransitAgency.objects.all():
for flow in agency.enrollment_flows.all():
flow.transit_agency = agency
flow.save()


class Migration(migrations.Migration):

dependencies = [
("core", "0027_enrollmentflow_supported_methods"),
]

operations = [
migrations.AddField(
model_name="enrollmentflow",
name="transit_agency",
field=models.ForeignKey(
blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to="core.transitagency"
),
),
migrations.RunPython(migrate_data),
migrations.RemoveField(
model_name="transitagency",
name="enrollment_flows",
),
migrations.AlterField(
model_name="enrollmentflow",
name="label",
field=models.TextField(help_text="A human readable label, used as the display text in Admin.", null=True),
),
]
101 changes: 39 additions & 62 deletions benefits/core/migrations/local_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,36 @@
"scheme": "dev-cal-itp_benefits"
}
},
{
"model": "core.transitagency",
"pk": 1,
"fields": {
"active": true,
"slug": "cst",
"short_name": "CST (local)",
"long_name": "California State Transit (local)",
"info_url": "https://www.agency-website.com",
"phone": "1-800-555-5555",
"index_template": "core/index--cst.html",
"eligibility_index_template": "eligibility/index--cst.html",
"eligibility_api_id": "cst",
"eligibility_api_private_key": 2,
"eligibility_api_public_key": 3,
"eligibility_api_jws_signing_alg": "RS256",
"transit_processor": 1,
"transit_processor_audience": "",
"transit_processor_client_id": "",
"transit_processor_client_secret_name": "cst-transit-processor-client-secret",
"staff_group": 2,
"customer_service_group": 2
}
},
{
"model": "core.enrollmentflow",
"pk": 1,
"fields": {
"system_name": "senior",
"label": "(CST) Senior Discount",
"label": "Older Adult",
"group_id": "group123",
"enrollment_success_template": "enrollment/success--cst.html",
"display_order": 2,
Expand All @@ -62,15 +86,16 @@
"eligibility_start_template": "eligibility/start--senior.html",
"claims_scope": "verify:senior",
"claims_claim": "senior",
"supported_enrollment_methods": ["digital", "in_person"]
"supported_enrollment_methods": ["digital", "in_person"],
"transit_agency": 1
}
},
{
"model": "core.enrollmentflow",
"pk": 2,
"fields": {
"system_name": "veteran",
"label": "(CST) Veteran Discount",
"label": "US Veteran",
"group_id": "group123",
"enrollment_success_template": "enrollment/success--cst.html",
"display_order": 4,
Expand All @@ -79,15 +104,16 @@
"eligibility_start_template": "eligibility/start--veteran.html",
"claims_scope": "verify:veteran",
"claims_claim": "veteran",
"supported_enrollment_methods": ["digital", "in_person"]
"supported_enrollment_methods": ["digital", "in_person"],
"transit_agency": 1
}
},
{
"model": "core.enrollmentflow",
"pk": 3,
"fields": {
"system_name": "agency_card",
"label": "(CST) Agency Card Discount",
"label": "Agency Card",
"group_id": "group123",
"enrollment_index_template": "enrollment/index--agency-card.html",
"enrollment_success_template": "enrollment/success--cst-agency-card.html",
Expand All @@ -104,15 +130,16 @@
"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_enrollment_methods": ["digital", "in_person"]
"supported_enrollment_methods": ["digital", "in_person"],
"transit_agency": 1
}
},
{
"model": "core.enrollmentflow",
"pk": 4,
"fields": {
"system_name": "calfresh",
"label": "(CST) CalFresh",
"label": "CalFresh Cardholder",
"group_id": "group123",
"supports_expiration": "True",
"expiration_days": 5,
Expand All @@ -126,15 +153,16 @@
"help_template": "core/includes/help--calfresh.html",
"claims_scope": "verify:calfresh",
"claims_claim": "calfresh",
"supported_enrollment_methods": ["digital", "in_person"]
"supported_enrollment_methods": ["digital", "in_person"],
"transit_agency": 1
}
},
{
"model": "core.enrollmentflow",
"pk": 5,
"fields": {
"system_name": "medicare",
"label": "(CST) Medicare Discount",
"label": "Medicare Cardholder",
"group_id": "group123",
"enrollment_success_template": "enrollment/success--cst.html",
"display_order": 1,
Expand All @@ -144,34 +172,8 @@
"help_template": "core/includes/help--medicare.html",
"claims_scope": "verify:medicare",
"claims_claim": "medicare",
"supported_enrollment_methods": ["digital", "in_person"]
}
},
{
"model": "core.enrollmentflow",
"pk": 6,
"fields": {
"system_name": "in_person_only",
"label": "(CST) In-person Only",
"group_id": "group123",
"supported_enrollment_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_enrollment_methods": ["digital"]
"supported_enrollment_methods": ["digital", "in_person"],
"transit_agency": 1
}
},
{
Expand All @@ -186,31 +188,6 @@
"portal_url": "https://www.transit-processor-portal.com"
}
},
{
"model": "core.transitagency",
"pk": 1,
"fields": {
"active": true,
"enrollment_flows": [1, 2, 3, 4, 5],
"slug": "cst",
"short_name": "CST (local)",
"long_name": "California State Transit (local)",
"info_url": "https://www.agency-website.com",
"phone": "1-800-555-5555",
"index_template": "core/index--cst.html",
"eligibility_index_template": "eligibility/index--cst.html",
"eligibility_api_id": "cst",
"eligibility_api_private_key": 2,
"eligibility_api_public_key": 3,
"eligibility_api_jws_signing_alg": "RS256",
"transit_processor": 1,
"transit_processor_audience": "",
"transit_processor_client_id": "",
"transit_processor_client_secret_name": "cst-transit-processor-client-secret",
"staff_group": 2,
"customer_service_group": 2
}
},
{
"model": "auth.Group",
"pk": 2,
Expand Down
Loading
Loading