+def book_info(request, id, lang='pl'):
+ book = get_object_or_404(models.Book, id=id)
+ # set language by hand
+ translation.activate(lang)
+ return render_to_response('catalogue/book_info.html', locals(),
+ context_instance=RequestContext(request))
+
+
+def tag_info(request, id):
+ tag = get_object_or_404(models.Tag, id=id)
+ return HttpResponse(tag.description)
+
+
+def download_zip(request, format, slug=None):
+ url = None
+ if format in models.Book.ebook_formats:
+ url = models.Book.zip_format(format)
+ elif format in ('mp3', 'ogg') and slug is not None:
+ book = get_object_or_404(models.Book, slug=slug)
+ url = book.zip_audiobooks(format)
+ else:
+ raise Http404('No format specified for zip package')
+ return HttpResponseRedirect(urlquote_plus(settings.MEDIA_URL + url, safe='/?='))
+
+
+class CustomPDFFormView(AjaxableFormView):
+ form_class = forms.CustomPDFForm
+ title = ugettext_lazy('Download custom PDF')
+ submit = ugettext_lazy('Download')
+ honeypot = True
+
+ def __call__(self, *args, **kwargs):
+ if settings.NO_CUSTOM_PDF:
+ raise Http404('Custom PDF is disabled')
+ return super(CustomPDFFormView, self).__call__(*args, **kwargs)
+
+ def form_args(self, request, obj):
+ """Override to parse view args and give additional args to the form."""
+ return (obj,), {}
+
+ def get_object(self, request, slug, *args, **kwargs):
+ return get_object_or_404(models.Book, slug=slug)
+
+ def context_description(self, request, obj):
+ return obj.pretty_title()