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-]*'
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'),
)
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,
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:
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))
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
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()
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)
.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;
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
}
+
<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 %}