Make wagtailcore 0002 reversible

pull/2073/head
Benjamin Bach 2015-12-28 02:46:14 +01:00
rodzic 07d9f09e1d
commit 56c85f8984
2 zmienionych plików z 55 dodań i 5 usunięć

Wyświetl plik

@ -45,15 +45,15 @@ def initial_data(apps, schema_editor):
)
# Create default site
Site.objects.create(
Site.objects.get_or_create(
hostname='localhost',
root_page_id=homepage.id,
is_default_site=True
)
# Create auth groups
moderators_group = Group.objects.create(name='Moderators')
editors_group = Group.objects.create(name='Editors')
moderators_group, created = Group.objects.get_or_create(name='Moderators')
editors_group, created = Group.objects.get_or_create(name='Editors')
# Create group permissions
GroupPagePermission.objects.create(
@ -91,6 +91,31 @@ def initial_data(apps, schema_editor):
)
def remove_initial_data(apps, schema_editor):
"""This function does nothing. The below code is commented out together
with an explanation of why we don't need to bother reversing any of the
initial data"""
pass
# This does not need to be deleted, Django takes care of it.
# page_content_type = ContentType.objects.get(
# model='page',
# app_label='wagtailcore',
# )
# Page objects: Do nothing, the table will be deleted when reversing 0001
# Do not reverse Site creation since other models might depend on it
# Remove auth groups -- is this safe? External objects might depend
# on these groups... seems unsafe.
# Group.objects.filter(
# name__in=('Moderators', 'Editors')
# ).delete()
#
# Likewise, we're leaving all GroupPagePermission unchanged as users may
# have been assigned such permissions and its harmless to leave them.
class Migration(migrations.Migration):
replaces = [
@ -306,6 +331,6 @@ class Migration(migrations.Migration):
options={'verbose_name': 'Site'},
),
migrations.RunPython(
initial_data,
initial_data, remove_initial_data
),
]

Wyświetl plik

@ -81,6 +81,31 @@ def initial_data(apps, schema_editor):
)
def remove_initial_data(apps, schema_editor):
"""This function does nothing. The below code is commented out together
with an explanation of why we don't need to bother reversing any of the
initial data"""
pass
# This does not need to be deleted, Django takes care of it.
# page_content_type = ContentType.objects.get(
# model='page',
# app_label='wagtailcore',
# )
# Page objects: Do nothing, the table will be deleted when reversing 0001
# Do not reverse Site creation since other models might depend on it
# Remove auth groups -- is this safe? External objects might depend
# on these groups... seems unsafe.
# Group.objects.filter(
# name__in=('Moderators', 'Editors')
# ).delete()
#
# Likewise, we're leaving all GroupPagePermission unchanged as users may
# have been assigned such permissions and its harmless to leave them.
class Migration(migrations.Migration):
dependencies = [
@ -88,5 +113,5 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(initial_data),
migrations.RunPython(initial_data, remove_initial_data),
]