From: Marcin Koziej Date: Wed, 21 Nov 2012 10:03:44 +0000 (+0100) Subject: Merge branch 'master' of github.com:fnp/wolnelektury X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/40a38822c70cb40ccda6770fe81d74624ecaecd7?hp=b34b62e9545e4c8a887c4ea54203082fb6ecec42 Merge branch 'master' of github.com:fnp/wolnelektury --- diff --git a/apps/api/handlers.py b/apps/api/handlers.py index 437b3be4c..dbe905b00 100644 --- a/apps/api/handlers.py +++ b/apps/api/handlers.py @@ -12,6 +12,7 @@ from django.core.cache import get_cache from django.core.urlresolvers import reverse from piston.handler import AnonymousBaseHandler, BaseHandler from piston.utils import rc +from sorl.thumbnail import default from api.helpers import timestamp from api.models import Deleted @@ -134,6 +135,11 @@ class BookDetails(object): def cover(cls, book): return MEDIA_BASE + book.cover.url if book.cover else '' + @classmethod + def cover_thumb(cls, book): + return MEDIA_BASE + default.backend.get_thumbnail( + book.cover, "139x193").url if book.cover else '' + class BookDetailHandler(BaseHandler, BookDetails): @@ -143,7 +149,7 @@ class BookDetailHandler(BaseHandler, BookDetails): """ allowed_methods = ['GET'] fields = ['title', 'parent', 'children'] + Book.formats + [ - 'media', 'url', 'cover'] + [ + 'media', 'url', 'cover', 'cover_thumb'] + [ category_plural[c] for c in book_tag_categories] @piwik_track @@ -192,9 +198,9 @@ class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails): if top_level: books = books.filter(parent=None) if audiobooks: - books = books.filter(media__type='mp3') + books = books.filter(media__type='mp3').distinct() if daisy: - books = books.filter(media__type='daisy') + books = books.filter(media__type='daisy').distinct() if books.exists(): return books @@ -224,6 +230,10 @@ class BooksHandler(BookDetailHandler): return rc.NOT_FOUND +class EBooksHandler(AnonymousBooksHandler): + fields = ('author', 'href', 'title', 'cover') + tuple(Book.ebook_formats) + + # add categorized tags fields for Book def _tags_getter(category): @classmethod diff --git a/apps/api/urls.py b/apps/api/urls.py index e24c3c523..8a1451909 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -15,6 +15,7 @@ tag_changes_resource = Resource(handler=handlers.TagChangesHandler) changes_resource = Resource(handler=handlers.ChangesHandler) book_list_resource = CsrfExemptResource(handler=handlers.BooksHandler, authentication=auth) +ebook_list_resource = Resource(handler=handlers.EBooksHandler) #book_list_resource = Resource(handler=handlers.BooksHandler) book_resource = Resource(handler=handlers.BookDetailHandler) @@ -57,8 +58,12 @@ urlpatterns = patterns( # books by tags url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})books/$', book_list_resource, name='api_book_list'), + url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})ebooks/$', + ebook_list_resource, name='api_ebook_list'), url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})parent_books/$', book_list_resource, {"top_level": True}, name='api_parent_book_list'), + url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})parent_ebooks/$', + ebook_list_resource, {"top_level": True}, name='api_parent_ebook_list'), url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})audiobooks/$', book_list_resource, {"audiobooks": True}, name='api_audiobook_list'), url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})daisy/$', diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo index dfd8de096..ed68b42f9 100644 Binary files a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo and b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.po b/apps/catalogue/locale/pl/LC_MESSAGES/django.po index f97d11926..7682cd2da 100644 --- a/apps/catalogue/locale/pl/LC_MESSAGES/django.po +++ b/apps/catalogue/locale/pl/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-08-22 14:06+0200\n" -"PO-Revision-Date: 2012-08-22 14:12+0100\n" +"POT-Creation-Date: 2012-11-08 16:21+0100\n" +"PO-Revision-Date: 2012-11-08 16:21+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -73,7 +73,7 @@ msgstr "Duży" msgid "Queue is full. Please try again later." msgstr "" -#: views.py:500 +#: views.py:525 #, python-format msgid "" "An error occurred: %(exception)s\n" @@ -84,20 +84,20 @@ msgstr "" "\n" "%(tb)s" -#: views.py:501 +#: views.py:526 msgid "Book imported successfully" msgstr "Książka zaimportowana" -#: views.py:503 +#: views.py:528 #, python-format msgid "Error importing file: %r" msgstr "Błąd podczas importowania pliku: %r" -#: views.py:535 +#: views.py:560 msgid "Download custom PDF" msgstr "Stwórz własny PDF" -#: views.py:536 +#: views.py:561 #: templates/catalogue/book_short.html:92 #: templates/catalogue/book_text.html:28 #: templates/catalogue/book_wide.html:63 @@ -127,10 +127,10 @@ msgid "language code" msgstr "Kod języka" #: models/book.py:35 -#: models/book.py:140 +#: models/book.py:145 #: models/collection.py:13 #: models/tag.py:34 -#: models/tag.py:76 +#: models/tag.py:83 msgid "description" msgstr "opis" @@ -164,17 +164,17 @@ msgstr "książka" msgid "books" msgstr "książki" -#: models/book.py:238 +#: models/book.py:243 #, python-format msgid "Book \"%s\" does not exist." msgstr "Utwór \"%s\" nie istnieje." -#: models/book.py:252 +#: models/book.py:257 #, python-format msgid "Book %s already exists" msgstr "Książka %s już istnieje" -#: models/book.py:585 +#: models/book.py:589 #: models/bookmedia.py:22 #, python-format msgid "%s file" @@ -331,7 +331,7 @@ msgstr "" msgid "Table of Content" msgstr "" -#: templates/catalogue/book_list.html:48 +#: templates/catalogue/book_list.html:30 msgid "↑ top ↑" msgstr "" @@ -415,7 +415,7 @@ msgid "Table of contents" msgstr "" #: templates/catalogue/book_text.html:24 -#: templates/catalogue/menu.html:27 +#: templatetags/catalogue_tags.py:412 #, fuzzy msgid "Themes" msgstr "motyw" @@ -497,32 +497,32 @@ msgid "Download the catalogue in PDF format." msgstr "" #: templates/catalogue/catalogue.html:19 -#: templates/catalogue/menu.html:7 #: templates/catalogue/search_multiple_hits.html:17 #: templates/catalogue/tagged_object_list.html:26 +#: templatetags/catalogue_tags.py:408 #, fuzzy msgid "Authors" msgstr "autor" #: templates/catalogue/catalogue.html:22 -#: templates/catalogue/menu.html:17 #: templates/catalogue/search_multiple_hits.html:25 #: templates/catalogue/tagged_object_list.html:34 +#: templatetags/catalogue_tags.py:410 msgid "Kinds" msgstr "" #: templates/catalogue/catalogue.html:25 -#: templates/catalogue/menu.html:12 #: templates/catalogue/search_multiple_hits.html:33 #: templates/catalogue/tagged_object_list.html:42 +#: templatetags/catalogue_tags.py:409 #, fuzzy msgid "Genres" msgstr "gatunek" #: templates/catalogue/catalogue.html:28 -#: templates/catalogue/menu.html:22 #: templates/catalogue/search_multiple_hits.html:41 #: templates/catalogue/tagged_object_list.html:50 +#: templatetags/catalogue_tags.py:411 #, fuzzy msgid "Epochs" msgstr "epoka" @@ -580,17 +580,21 @@ msgstr "fragment" msgid "See full category" msgstr "kategoria" -#: templates/catalogue/menu.html:32 +#: templates/catalogue/menu.html:9 +msgid "Please wait…" +msgstr "" + +#: templates/catalogue/menu.html:16 #, fuzzy msgid "All books" msgstr "książki" -#: templates/catalogue/menu.html:36 +#: templates/catalogue/menu.html:20 #, fuzzy msgid "Audiobooks" msgstr "książki" -#: templates/catalogue/menu.html:40 +#: templates/catalogue/menu.html:24 #, fuzzy msgid "DAISY" msgstr "Plik DAISY" @@ -683,19 +687,23 @@ msgstr "" msgid "Did you mean" msgstr "" -#: templates/catalogue/search_multiple_hits.html:54 -msgid "Results by authors" +#: templates/catalogue/search_multiple_hits.html:52 +msgid "Results by title" msgstr "" #: templates/catalogue/search_multiple_hits.html:67 -msgid "Results by title" +msgid "Results by authors" msgstr "" -#: templates/catalogue/search_multiple_hits.html:82 +#: templates/catalogue/search_multiple_hits.html:80 +msgid "Results by translators" +msgstr "Znalezieni tłumacze" + +#: templates/catalogue/search_multiple_hits.html:93 msgid "Results in text" msgstr "" -#: templates/catalogue/search_multiple_hits.html:99 +#: templates/catalogue/search_multiple_hits.html:110 msgid "Other results" msgstr "" @@ -826,9 +834,6 @@ msgstr "" #~ msgid "goes to public domain" #~ msgstr "trafia do domeny publicznej" -#~ msgid "translator" -#~ msgstr "tłumacz" - #~ msgid "year of translator's death" #~ msgstr "rok śmierci tłumacza" diff --git a/apps/catalogue/tests/tags.py b/apps/catalogue/tests/tags.py index 3eab3da4d..2608eb632 100644 --- a/apps/catalogue/tests/tags.py +++ b/apps/catalogue/tests/tags.py @@ -277,12 +277,11 @@ class BookTagsTests(WLTestCase): self.assertEqual([(tag.name, tag.count) for tag in related_themes], [('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)]) - def test_main_page_tags(self): + def test_catalogue_tags(self): """ test main page tags and counts """ - from catalogue.templatetags.catalogue_tags import catalogue_menu - menu = catalogue_menu() - self.assertEqual([(tag.name, tag.book_count) for tag in menu['author']], + context = self.client.get('/katalog/').context + self.assertEqual([(tag.name, tag.book_count) for tag in context['categories']['author']], [('Jim Lazy', 1), ('Common Man', 1)]) - self.assertEqual([(tag.name, tag.book_count) for tag in menu['theme']], + self.assertEqual([(tag.name, tag.book_count) for tag in context['categories']['theme']], [('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)]) diff --git a/requirements.txt b/requirements.txt index c7e33c2f2..036031e93 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ South>=0.7 # migrations for django django-pipeline>=1.2 django-pagination>=1.0 django-maintenancemode>=0.10 -django-piston<=0.2.3 +django-piston==0.2.2 #django-jsonfield -e git+git://github.com/bradjasper/django-jsonfield.git@2f427368ad70bf8d9a0580df58ec0eb0654d62ae#egg=django-jsonfield django-picklefield