Merge branch 'pretty' of github.com:fnp/wolnelektury into pretty
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 12:08:29 +0000 (13:08 +0100)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 12:09:36 +0000 (13:09 +0100)
Conflicts:
apps/catalogue/urls.py
apps/catalogue/views.py

apps/catalogue/templatetags/catalogue_tags.py
apps/catalogue/urls.py
apps/catalogue/views.py
lib/librarian
wolnelektury/static/css/book_box.css
wolnelektury/static/css/dialogs.css
wolnelektury/templates/catalogue/book_wide.html

index c5b904d..df938a6 100644 (file)
@@ -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()
index b6fd361..4baf225 100644 (file)
@@ -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/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
 
+    url(r'^custompdf$', CustomPDFFormView(), name='custom_pdf_form'),
     url(r'^custompdf/(?P<slug>%s).pdf' % SLUG, 'download_custom_pdf'),
 
 ) 
index 3a32832..b874c4c 100644 (file)
@@ -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)
index a34b95a..cbabbda 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a34b95aa7ba5fd4838541d1cdcd28358fb808062
+Subproject commit cbabbdaa7ab6c6be8cd22b77860331444ddf6119
index 9b589dc..1733008 100755 (executable)
@@ -15,6 +15,7 @@
 
 .book-wide-box {
     width: 98.5em;
+    margin-left: -0.1em;
 }
 
 .book-mini-box a, .book-box-inner {
     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;
     height: 17em;
     overflow: hidden;
 }
+
+.book-wide-box .book-box-body {
+    height: 21.8em;
+}
+
 .book-box-head {
     min-height: 7em;
     margin-top: 1.4em;
     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
 }
+
index dc76e6c..b3876c3 100755 (executable)
        width: 21em;
     height: 3em;
 }
+
+#custom-pdf-window {
+    width: 24em;   
+}
+
+#custom-pdf-window label {
+    display: inline;
+}
\ No newline at end of file
index 1cfde2e..59abe0f 100644 (file)
 
   <div id="other-tools">
     <h2 class="mono">{% trans "See" %}</h2>
-    <ul>
+    <ul class="inline-items">
       {% if extra_info.source_url %}
-      <li><a href="{{ extra_info.source_url }}">{% trans "Source of the book" %}</a></li>
+      <li><a href="{{ extra_info.source_url }}">{% trans "Source" %}</a> {% trans "of the book" %}</li>
       {% endif %}
       {% if extra_info.about and not hide_about %}
-      <li><a href="{{ extra_info.about }}">{% trans "Book on the Editor's Platform" %}</a></li>
+      <li>{% trans "Book on" %} <a href="{{ extra_info.about }}">{% trans "Editor's Platform" %}</a></li>
       {% endif %}
       {% if book.gazeta_link %}
       <li><a href="{{ book.gazeta_link }}">{% trans "Book description on Lektury.Gazeta.pl" %}</a></li>
   </div>
   <div id="other-download">
     <h2 class="mono">{% trans "Download" %}</h2>
-    <p>{% trans "Download all audiobooks for this book" %}</p>
+    <ul class="inline-items">
+      <li>
+       {% if has_media.mp3 or has_media.ogg %}
+       {% trans "Download all audiobooks for this book" %}: 
+       {% if has_media.mp3 %}<a href="{% url download_zip_mp3 book.slug %}">MP3</a>{% endif %}{% if has_media.mp4 and has_media.ogg %},{% endif %}
+       {% if has_media.ogg %}<a href="{% url download_zip_ogg book.slug %}">OGG</a>{% endif %}.
+       {% endif %}
+      </li>
+      <li>
+       <a href="{% url custom_pdf_form %}?book_id={{book.fileid}}" id="custom-pdf" class="ajaxable">{% trans "Download a custom PDF" %}</a>
+      </li>
+    </ul>
   </div>
 </div>
 {% endblock %}