2017-09-12 19:10:32 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
2017-09-17 15:35:47 +00:00
|
|
|
|
2017-09-12 19:10:32 +00:00
|
|
|
from club.models import Club
|
2017-09-17 15:35:47 +00:00
|
|
|
from core.operations import PsqlRunOnly
|
2017-09-12 19:10:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
def generate_club_pages(apps, schema_editor):
|
2017-09-17 12:59:50 +00:00
|
|
|
def recursive_generate_club_page(club):
|
2017-09-12 19:10:32 +00:00
|
|
|
club.make_page()
|
2017-09-17 12:59:50 +00:00
|
|
|
for child in Club.objects.filter(parent=club).all():
|
|
|
|
recursive_generate_club_page(child)
|
|
|
|
for club in Club.objects.filter(parent=None).all():
|
|
|
|
recursive_generate_club_page(club)
|
2017-09-12 19:10:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
('core', '0024_auto_20170906_1317'),
|
2017-09-26 14:07:49 +00:00
|
|
|
('club', '0010_club_logo'),
|
2017-09-12 19:10:32 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
|
|
|
model_name='club',
|
|
|
|
name='is_active',
|
|
|
|
field=models.BooleanField(default=True, verbose_name='is active'),
|
|
|
|
),
|
|
|
|
migrations.AddField(
|
|
|
|
model_name='club',
|
|
|
|
name='page',
|
|
|
|
field=models.OneToOneField(related_name='club', blank=True, null=True, to='core.Page'),
|
|
|
|
),
|
2017-09-26 14:07:49 +00:00
|
|
|
migrations.AddField(
|
|
|
|
model_name='club',
|
|
|
|
name='short_description',
|
|
|
|
field=models.CharField(verbose_name='short description', max_length=1000, default='', blank=True, null=True),
|
|
|
|
),
|
2017-09-17 15:35:47 +00:00
|
|
|
PsqlRunOnly('SET CONSTRAINTS ALL IMMEDIATE', reverse_sql=migrations.RunSQL.noop),
|
2017-09-12 19:10:32 +00:00
|
|
|
migrations.RunPython(generate_club_pages),
|
2017-09-17 15:35:47 +00:00
|
|
|
PsqlRunOnly(migrations.RunSQL.noop, reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
|
2017-09-12 19:10:32 +00:00
|
|
|
]
|