From bb75190ec69f3d92c799edaaf8a59da35b0c172f Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Mon, 28 Dec 2015 02:36:07 +0100 Subject: [PATCH] Create reverse migration for wagtailadmin 0001 --- .../0001_create_admin_access_permissions.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wagtail/wagtailadmin/migrations/0001_create_admin_access_permissions.py b/wagtail/wagtailadmin/migrations/0001_create_admin_access_permissions.py index 0546d2706e..0df1361ceb 100644 --- a/wagtail/wagtailadmin/migrations/0001_create_admin_access_permissions.py +++ b/wagtail/wagtailadmin/migrations/0001_create_admin_access_permissions.py @@ -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), ]