You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
# Stub Generated by Django 4.0.1 on 2023-04-02 08:29 and edited manually
|
|
|
|
from django.db import migrations
|
|
|
|
def rename_permissions(apps, schema_editor):
|
|
Permission = apps.get_model("auth", "Permission")
|
|
|
|
for modelcodename in ["klettertreffattendee", "member", "newmemberonlist"]:
|
|
for action in ["view", "add", "change", "delete"]:
|
|
Permission.objects \
|
|
.filter(codename="{action}_{modelcodename}".format(action=action, modelcodename=modelcodename)) \
|
|
.update(name='Can {action} {modelcodename}'.format(action=action, modelcodename=modelcodename))
|
|
|
|
|
|
def remove_old_memberlist_permissions(apps, schema_editor):
|
|
Permission = apps.get_model("auth", "Permission")
|
|
|
|
for action in ["view", "add", "change", "delete"]:
|
|
Permission.objects.filter(codename="{action}_oldmemberonlist".format(action=action)).delete()
|
|
Permission.objects.filter(codename="{action}_memberlist".format(action=action)).delete()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('members', '0005_remove_oldmemberonlist_member_and_more'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(rename_permissions, migrations.RunPython.noop),
|
|
migrations.RunPython(remove_old_memberlist_permissions, migrations.RunPython.noop),
|
|
]
|