Merge branch 'production'
[wolnelektury.git] / apps / catalogue / migrations / 0008_fix_shelf_book_count.py
1 # -*- coding: utf-8 -*-
2
3 from south.db import db
4 from django.db import models
5 from catalogue.models import Tag, Book
6
7 class Migration:
8     
9     def forwards(self):
10         "Write your forwards migration here"
11         for tag in Tag.objects.filter(user__isnull=False):
12             books = Tag.intermediary_table_model.objects.get_intersection_by_model(Book, [tag])
13             tag.book_count = len(books)
14             tag.save()
15     
16     def backwards(self, orm):
17         "Write your backwards migration here"
18         pass