22 lines
1.7 KiB
Python
22 lines
1.7 KiB
Python
from django.db import migrations
|
|
|
|
|
|
ROWS = [('about', 'start', '8.88672', '3.41880', 'Series introduction'), ('upcoming', 'upcoming', '55.46875', '6.58120', 'Next releases'), ('cast', 'cast', '66.65039', '17.09402', 'Meet the cast'), ('world', 'world', '88.47656', '26.66667', 'World archive'), ('blog', 'blog', '13.81836', '39.40171', 'Studio blog'), ('chapters', 'chapters', '35.44922', '43.33333', 'Read chapters'), ('reviews', 'reviews', '53.36914', '48.97436', 'Reader reviews'), ('live', 'live', '62.45117', '60.76923', 'SLX Live'), ('membership', 'membership', '41.55273', '67.43590', 'Membership'), ('shop', 'shop', '74.90234', '73.33333', 'Shop'), ('cart', 'cart', '96.53320', '73.58974', 'Shopping cart'), ('newsletter', 'newsletter', '11.37695', '81.11111', 'Newsletter'), ('library', 'library', '15.18555', '84.87179', 'My library'), ('countdown', 'release', '61.13281', '88.88889', 'Release countdown')]
|
|
|
|
|
|
def seed(apps, schema_editor):
|
|
Page = apps.get_model('catalog', 'ManagedPage')
|
|
Location = apps.get_model('catalog', 'MapLocation')
|
|
db = schema_editor.connection.alias
|
|
for position, (slot, key, x, y, title) in enumerate(ROWS):
|
|
page = Page.objects.using(db).filter(map_slot=slot).first()
|
|
fallback = {'cart': '/shop/cart/', 'library': '/fan/library/', 'release': '/coming-soon/'}.get(key, '/' + slot + '/')
|
|
Location.objects.using(db).get_or_create(key=key, defaults=dict(
|
|
title=title, x=x, y=y, page_id=page.pk if page else None,
|
|
fallback_path=fallback, position=position))
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [('catalog', '0029_map_location')]
|
|
operations = [migrations.RunPython(seed, migrations.RunPython.noop)]
|