From: Radek Czajka Date: Tue, 11 May 2010 11:12:53 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://github.com/fnp/wolnelektury X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/c3477585380d327f5a2029201721151d25f5b2b5?hp=6af842bbee5e81d3d6eecb69d61e61918e5b958b Merge branch 'master' of git+ssh://github.com/fnp/wolnelektury --- diff --git a/apps/catalogue/migrations/0008_fix_shelf_book_count.py b/apps/catalogue/migrations/0008_fix_shelf_book_count.py new file mode 100644 index 000000000..b4ee91506 --- /dev/null +++ b/apps/catalogue/migrations/0008_fix_shelf_book_count.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from south.db import db +from django.db import models +from catalogue.models import Tag, Book + +class Migration: + + def forwards(self): + "Write your forwards migration here" + for tag in Tag.objects.filter(user__isnull=False): + books = Tag.intermediary_table_model.objects.get_intersection_by_model(Book, [tag]) + tag.book_count = len(books) + tag.save() + + def backwards(self, orm): + "Write your backwards migration here" + pass