Str/bytes fix for publishing audiobooks.
[wolnelektury.git] / src / social / migrations / 0006_legacy_group.py
1 from django.db import migrations
2
3
4 def legacy_group(apps, schema_editor):
5     Cite = apps.get_model('social', 'Cite')
6     BannerGroup = apps.get_model('social', 'BannerGroup')
7
8     traditional = BannerGroup.objects.create(name='Tradycyjne cytaty')
9     banners = BannerGroup.objects.create(name='Bannery')
10
11     Cite.objects.exclude(book=None).update(group=traditional)
12     Cite.objects.filter(book=None).update(group=banners)
13
14
15 class Migration(migrations.Migration):
16
17     dependencies = [
18         ('social', '0005_auto_20190318_1309'),
19     ]
20
21     operations = [
22         migrations.RunPython(
23             legacy_group,
24             migrations.RunPython.noop
25         )
26     ]