X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/50aec69a46276ec94d7d4d2ab3c59bc383d07a2c..e6239f4e83a99503be4c09c329029df1d3f2b5b9:/src/opds/views.py diff --git a/src/opds/views.py b/src/opds/views.py index 38f34efd5..d2d7b6e09 100644 --- a/src/opds/views.py +++ b/src/opds/views.py @@ -17,6 +17,7 @@ from django.utils.functional import lazy 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 @@ -318,7 +319,7 @@ class UserFeed(Feed): 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 @@ -343,10 +344,10 @@ class UserSetFeed(AcquisitionFeed): 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 @@ -443,8 +444,10 @@ class SearchFeed(AcquisitionFeed): ).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)