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
link_rel = "subsection"
link_type = "application/atom+xml"
- _book_parent_img = lazy(lambda: full_url(os.path.join(settings.STATIC_URL, "img/book-parent.png")), str)()
+ _book_parent_img = lazy(lambda: full_url(os.path.join(settings.PROJECT_DIR, "static/img/book-parent.png")), str)()
try:
- _book_parent_img_size = str(os.path.getsize(os.path.join(settings.STATIC_ROOT, "img/book-parent.png")))
+ _book_parent_img_size = str(os.path.getsize(os.path.join(settings.PROJECT_DIR, "static/img/book-parent.png")))
except OSError:
_book_parent_img_size = ''
- _book_img = lazy(lambda: full_url(os.path.join(settings.STATIC_URL, "img/book.png")), str)()
+ _book_img = lazy(lambda: full_url(os.path.join(settings.PROJECT_DIR, "static/img/book.png")), str)()
try:
- _book_img_size = str(os.path.getsize(os.path.join(settings.STATIC_ROOT, "img/book.png")))
+ _book_img_size = str(os.path.getsize(os.path.join(settings.PROJECT_DIR, "static/img/book.png")))
except OSError:
_book_img_size = ''
if book.has_mp3_file():
e = Enclosure(
url=full_url(reverse('download_zip_mp3', args=[book.slug])),
- length=sum(bm.file.size for bm in book.get_media('mp3')),
+ length=sum(bm.file_size for bm in book.get_media('mp3')),
mime_type="application/zip"
)
e.indirect = 'audio/mpeg'
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)