1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
4 from django.db import migrations, models
7 def init_tag_for_books_pictures(apps, schema_editor):
8 Tag = apps.get_model('catalogue', 'Tag')
9 db_alias = schema_editor.connection.alias
10 tag_objects = Tag.objects.using(db_alias).exclude(category='set')
11 tags_for_books = tag_objects.filter(items__content_type__model__in=('book', 'fragment')).distinct()
12 tags_for_books.update(for_books=True)
13 tags_for_pictures = tag_objects.filter(items__content_type__model__in=('picture', 'picturearea')).distinct()
14 tags_for_pictures.update(for_pictures=True)
17 class Migration(migrations.Migration):
20 ('catalogue', '0018_auto_20171221_1106'),
27 field=models.BooleanField(default=False),
32 field=models.BooleanField(default=False),
34 migrations.RunPython(init_tag_for_books_pictures, migrations.RunPython.noop)