Fundraising in PDF.
[wolnelektury.git] / src / social / migrations / 0006_legacy_group.py
1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
3 #
4 from django.db import migrations
5
6
7 def legacy_group(apps, schema_editor):
8     Cite = apps.get_model('social', 'Cite')
9     BannerGroup = apps.get_model('social', 'BannerGroup')
10
11     traditional = BannerGroup.objects.create(name='Tradycyjne cytaty')
12     banners = BannerGroup.objects.create(name='Bannery')
13
14     Cite.objects.exclude(book=None).update(group=traditional)
15     Cite.objects.filter(book=None).update(group=banners)
16
17
18 class Migration(migrations.Migration):
19
20     dependencies = [
21         ('social', '0005_auto_20190318_1309'),
22     ]
23
24     operations = [
25         migrations.RunPython(
26             legacy_group,
27             migrations.RunPython.noop
28         )
29     ]