from basicauth import logged_in_or_basicauth, factory_decorator
from catalogue.models import Book, Tag
from search.utils import UnaccentSearchQuery, UnaccentSearchVector
+from social.models import UserList
import operator
import logging
return "Półki użytkownika %s" % user.username
def items(self, user):
- return Tag.objects.filter(category='set', user=user).exclude(items=None)
+ return UserList.objects.filter(user=user, deleted=False)
def item_title(self, item):
return item.name
return "Spis utworów na stronie http://WolneLektury.pl"
def get_object(self, request, slug):
- return get_object_or_404(Tag, category='set', slug=slug, user=request.user)
+ return get_object_or_404(UserList, deleted=False, slug=slug, user=request.user)
def items(self, tag):
- return Book.tagged.with_any([tag])
+ return tag.get_books()
@piwik_track
).filter(search_vector=UnaccentSearchQuery(criteria['categories'], config=settings.SEARCH_CONFIG))
books = books.filter(tag_relations__tag__in=tags)
if criteria['translator']:
- # TODO
- pass
+ authors = Tag.objects.filter(category='author').annotate(
+ search_vector=UnaccentSearchVector('name_pl')
+ ).filter(search_vector=UnaccentSearchQuery(criteria['translator'], config=settings.SEARCH_CONFIG))
+ books = books.filter(translators__in=authors)
if criteria['title']:
books = books.filter(
search_vector=UnaccentSearchQuery(criteria['title'], config=settings.SEARCH_CONFIG)