template fix
[wolnelektury.git] / apps / search / management / commands / reindex.py
1 from django.core.management.base import BaseCommand
2
3 class Command(BaseCommand):
4     help = 'Reindex everything.'
5     args = ''
6
7     def handle(self, *args, **opts):
8         from catalogue.models import Book
9         import search
10         idx = search.ReusableIndex()
11         idx.open()
12
13         if args:
14             books = []
15             for a in args:
16                 books += Book.objects.filter(slug=a).all()
17         else:
18             books = Book.objects.all()
19             
20         for b in books:
21             print b.title
22             idx.index_book(b, None)
23         print 'Reindexing tags.'
24         idx.index_tags()
25         idx.close()