37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
from django.db import migrations
|
|
|
|
|
|
def forward(apps, schema_editor):
|
|
PageSnapshot = apps.get_model('data', 'PageSnapshot')
|
|
for snapshot in PageSnapshot.objects.all():
|
|
changed = False
|
|
for cell in snapshot.serialization.get('cells') or []:
|
|
if cell.get('model') not in ['wcs.wcscardinfoscell', 'wcs.wcscardscell']:
|
|
continue
|
|
if cell['model'] == 'wcs.wcscardinfoscell':
|
|
cell['model'] = 'wcs.wcscardcell'
|
|
elif cell['model'] == 'wcs.wcscardscell':
|
|
cell['model'] = 'wcs.wcscardcell'
|
|
cell['fields']['card_ids'] = ''
|
|
cell['fields']['related_card_path'] = '__all__'
|
|
cell['fields']['display_mode'] = 'table'
|
|
cell['fields']['title_type'] = 'auto'
|
|
cell['fields']['custom_schema'] = {}
|
|
if cell['fields'].get('custom_title'):
|
|
cell['fields']['title_type'] = 'manual'
|
|
changed = True
|
|
if changed:
|
|
snapshot.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('data', '0062_page_uuid'),
|
|
('wcs', '0053_new_card_cell'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(forward, reverse_code=migrations.RunPython.noop),
|
|
]
|