0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Create reverse migration for wagtailadmin 0001

This commit is contained in:
Benjamin Bach 2015-12-28 02:36:07 +01:00 committed by Karl Hobley
parent f9dc7c485a
commit bb75190ec6

View File

@ -37,6 +37,21 @@ def create_admin_access_permissions(apps, schema_editor):
group.permissions.add(admin_permission)
def remove_admin_access_permissions(apps, schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model('contenttypes.ContentType')
Permission = apps.get_model('auth.Permission')
wagtailadmin_content_type = ContentType.objects.get(
app_label='wagtailadmin',
model='admin',
)
# This cascades to Group
Permission.objects.filter(
content_type=wagtailadmin_content_type,
codename='access_admin',
).delete()
class Migration(migrations.Migration):
dependencies = [
@ -45,5 +60,5 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(create_admin_access_permissions),
migrations.RunPython(create_admin_access_permissions, remove_admin_access_permissions),
]