-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(migration): enforce that in-person flows have an eligibility policy
data migration handles removing "in_person" from flows that do not have a policy in the `in_person.context.eligibility_index` dict. `EnrollmentFlow.clean` handles enforcing this rule going forward when creating or editing flows.
- Loading branch information
1 parent
87f9644
commit d27a53e
Showing
3 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
benefits/core/migrations/0036_in_person_enrollmentflows.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0035_enrollmentflow_system_name_choices"), | ||
] | ||
|
||
def migrate_in_person_flows(apps, schema_editor): | ||
EnrollmentFlow = apps.get_model("core", "EnrollmentFlow") | ||
for flow in EnrollmentFlow.objects.all(): | ||
in_person = "in_person" # value of EnrollmentMethods.IN_PERSON as of this migration | ||
if in_person in flow.supported_enrollment_methods: | ||
if flow.system_name not in [ | ||
"senior", | ||
"medicare", | ||
"courtesy_card", | ||
]: # the keys in `in_person.context.eligibility_index` as of this migration | ||
flow.supported_enrollment_methods.remove(in_person) | ||
flow.save() | ||
|
||
operations = [migrations.RunPython(migrate_in_person_flows)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters