From: Marcin Koziej Date: Fri, 30 Dec 2011 12:21:50 +0000 (+0100) Subject: Merge branch 'pretty' of github.com:fnp/wolnelektury into pretty X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/eb59143b0d1b21cfcbe1b7067f027d768fa88fcc?hp=b07520a11332374de645ed22c74959afa8a4b7ed Merge branch 'pretty' of github.com:fnp/wolnelektury into pretty --- diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index c5b904d40..df938a624 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -291,4 +291,8 @@ def book_wide(book): extra_info = book.get_extra_info_value() + has_media = {} + for media_format in ['mp3', 'ogg']: + has_media[media_format] = book.has_media(media_format) + return locals() diff --git a/apps/catalogue/urls.py b/apps/catalogue/urls.py index b6fd3610f..4baf225a5 100644 --- a/apps/catalogue/urls.py +++ b/apps/catalogue/urls.py @@ -6,6 +6,7 @@ from django.conf.urls.defaults import * from catalogue.feeds import AudiobookFeed from catalogue.models import Book from picture.models import Picture +from catalogue.views import CustomPDFFormView SLUG = r'[a-z0-9-]*' @@ -49,6 +50,7 @@ urlpatterns = patterns('picture.views', url(r'^audiobooki/(?Pmp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'), + url(r'^custompdf$', CustomPDFFormView(), name='custom_pdf_form'), url(r'^custompdf/(?P%s).pdf' % SLUG, 'download_custom_pdf'), ) diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 3a3283229..b874c4c0a 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -23,7 +23,8 @@ from django.utils import translation from django.utils.translation import ugettext as _ from django.views.generic.list_detail import object_list -from ajaxable.utils import LazyEncoder, JSONResponse +from ajaxable.utils import LazyEncoder, JSONResponse, AjaxableFormView + from catalogue import models from catalogue import forms from catalogue.utils import (split_tags, AttachmentHttpResponse, @@ -201,12 +202,12 @@ def book_detail(request, slug): book = models.Book.objects.get(slug=slug) except models.Book.DoesNotExist: return pdcounter_views.book_stub_detail(request, kwargs['slug']) - + book_tag = book.book_tag() tags = list(book.tags.filter(~Q(category='set'))) categories = split_tags(tags) book_children = book.children.all().order_by('parent_number', 'sort_key') - + _book = book parents = [] while _book.parent: @@ -454,7 +455,7 @@ def search(request): context_instance=RequestContext(request)) else: form = PublishingSuggestForm(initial={"books": prefix + ", "}) - return render_to_response('catalogue/search_no_hits.html', + return render_to_response('catalogue/search_no_hits.html', {'tags':tag_list, 'prefix':prefix, "pubsuggest_form": form}, context_instance=RequestContext(request)) @@ -465,7 +466,7 @@ def tags_starting_with(request): if len(prefix) < 2: return HttpResponse('') tags_list = [] - result = "" + result = "" for tag in _tags_starting_with(prefix, request.user): if not tag.name in tags_list: result += "\n" + tag.name @@ -704,15 +705,15 @@ def download_zip(request, format, slug=None): return HttpResponseRedirect(urlquote_plus(settings.MEDIA_URL + url, safe='/?=')) -def download_custom_pdf(request, slug): +def download_custom_pdf(request, slug, method='GET'): book = get_object_or_404(models.Book, slug=slug) - if request.method == 'GET': - form = forms.CustomPDFForm(request.GET) + if request.method == method: + form = forms.CustomPDFForm(method == 'GET' and request.GET or request.POST) if form.is_valid(): cust = form.customizations pdf_file = models.get_customized_pdf_path(book, cust) - + if not path.exists(pdf_file): result = async_build_pdf.delay(book.id, cust, pdf_file) result.wait() @@ -721,3 +722,15 @@ def download_custom_pdf(request, slug): raise Http404(_('Incorrect customization options for PDF')) else: raise Http404(_('Bad method')) + + +class CustomPDFFormView(AjaxableFormView): + form_class = forms.CustomPDFForm + title = _('Download custom PDF') + submit = _('Download') + + def __call__(self, request): + if request.method == 'POST': + return download_custom_pdf(request, request.GET['book_id'], method='POST') + else: + return super(CustomPDFFormView, self).__call__(request) diff --git a/wolnelektury/static/css/book_box.css b/wolnelektury/static/css/book_box.css index 9b589dc52..17330083a 100755 --- a/wolnelektury/static/css/book_box.css +++ b/wolnelektury/static/css/book_box.css @@ -15,6 +15,7 @@ .book-wide-box { width: 98.5em; + margin-left: -0.1em; } .book-mini-box a, .book-box-inner { @@ -40,6 +41,10 @@ margin: .5em; } +.book-wide-box .book-box-inner { + height: 24.4em; +} + .book-mini-box img, .book-box img, .book-wide-box img { width: 13.9em; height: 19.3em; @@ -69,6 +74,11 @@ height: 17em; overflow: hidden; } + +.book-wide-box .book-box-body { + height: 21.8em; +} + .book-box-head { min-height: 7em; margin-top: 1.4em; @@ -130,6 +140,10 @@ font-size: 1.1em; } +.book-wide-box .book-box-tools { + margin-left: 14em; +} + .book-box-tools a.downarrow:before { content: "\2609"; font-family: WL-Nav; @@ -186,16 +200,25 @@ ul.book-box-tools { padding: 0.888em; } +ul.inline-items, ul.inline-items li { + margin: 0; + padding: 0; +} + +ul.inline-items li { + display: inline-block; +} + .book-wide-box #other-tools { float: left; width: 14.5em; - margin-left: 1.5em; + margin: 6em 0 0 1.5em; } - .book-wide-box #other-download { float: left; - width 22.5em; - margin: 0em 1.5em 0em 1.5em + width: 22.5em; + margin: 6em 1.5em 0em 1.5em } + diff --git a/wolnelektury/static/css/dialogs.css b/wolnelektury/static/css/dialogs.css index 05b74dcc6..35136e0ca 100755 --- a/wolnelektury/static/css/dialogs.css +++ b/wolnelektury/static/css/dialogs.css @@ -94,3 +94,11 @@ #suggest-publishing-window textarea { height: 3em; } + +#custom-pdf-window { + width: 24em; +} + +#custom-pdf-window label { + display: inline; +} diff --git a/wolnelektury/templates/catalogue/book_wide.html b/wolnelektury/templates/catalogue/book_wide.html index 1cfde2e14..59abe0f0f 100644 --- a/wolnelektury/templates/catalogue/book_wide.html +++ b/wolnelektury/templates/catalogue/book_wide.html @@ -12,12 +12,12 @@

{% trans "See" %}

-

{% trans "Download" %}

-

{% trans "Download all audiobooks for this book" %}

+
    +
  • + {% if has_media.mp3 or has_media.ogg %} + {% trans "Download all audiobooks for this book" %}: + {% if has_media.mp3 %}MP3{% endif %}{% if has_media.mp4 and has_media.ogg %},{% endif %} + {% if has_media.ogg %}OGG{% endif %}. + {% endif %} +
  • +
  • + {% trans "Download a custom PDF" %} +
  • +
{% endblock %}