Skip to content

Commit

Permalink
chore(admin): update permission names for EnrollmentFlow
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Aug 12, 2024
1 parent 30cb969 commit 950f0ef
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
# Generated by Django 5.0.7 on 2024-08-07 21:22

import benefits.core.models
import benefits.secrets
from django.contrib.auth.management import create_permissions
import django.db.models.deletion
from django.db import migrations, models

import benefits.core.models
import benefits.secrets


def create_all_permissions(apps, schema_editor):
for app_config in apps.get_app_configs():
app_config.models_module = True
create_permissions(app_config, apps=apps, verbosity=0)
app_config.models_module = None


def update_permissions(apps, schema_editor):
Group = apps.get_model("auth", "Group")
staff_group = Group.objects.get(name="Cal-ITP")

Permission = apps.get_model("auth", "Permission")

remove_permissions = ["Can view", "Can change", "Can add", "Can delete"]
for remove_permission in remove_permissions:
current_permission = Permission.objects.get(name=f"{remove_permission} eligibility verifier")
staff_group.permissions.remove(current_permission)
current_permission.delete()

add_permissions = ["Can view", "Can change"]
for add_permission in add_permissions:
new_permission = Permission.objects.get(name=f"{add_permission} enrollment flow")
staff_group.permissions.add(new_permission)


class Migration(migrations.Migration):

Expand Down Expand Up @@ -149,4 +176,6 @@ class Migration(migrations.Migration):
help_text="Path to a Django template that defines the end-user UI for selecting this flow among other options."
),
),
migrations.RunPython(create_all_permissions),
migrations.RunPython(update_permissions),
]

0 comments on commit 950f0ef

Please sign in to comment.