{% if book.txt_file %}
<li><a href="{{ book.txt_file.url}}">TXT</a> {% trans "for advanced usage" %}</li>
{% endif %}
- <li><a href="{% url "custom_pdf_form" book.slug %}">{% trans "Download a custom PDF" %}</a></li>
+ {% custom_pdf_link_li book %}
{% if related.media.mp3 or related.media.ogg or related.media.daisy %}
<li>{% trans "Download all audiobooks for this book" %}:
{% download_audio book %}</li>
{% extends "catalogue/book_short.html" %}
{% load i18n %}
-{% load download_audio tag_list from catalogue_tags %}
+{% load download_audio tag_list custom_pdf_link_li from catalogue_tags %}
{% load cite_promo from social_tags %}
{% download_audio book %}.
{% endif %}
</li>
- <li>
- <a href="{% url custom_pdf_form book.slug %}" id="custom-pdf" class="ajaxable">{% trans "Download a custom PDF" %}</a>
- </li>
+ {% custom_pdf_link_li book %}
</ul>
</div>
</div>
--- /dev/null
+{% load i18n %}
+{% load url from future %}
+{% if not NO_CUSTOM_PDF %}
+<li>
+ <a href="{% url 'custom_pdf_form' book.slug %}" id="custom-pdf"
+ class="ajaxable">{% trans "Download a custom PDF" %}</a>
+</li>
+{% endif %}
import datetime
import feedparser
+from django.conf import settings
from django import template
from django.template import Node, Variable, Template, Context
from django.core.cache import cache
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.utils.translation import ugettext as _
-from catalogue import forms
from catalogue.utils import split_tags
from catalogue.models import Book, BookMedia, Fragment, Tag
links.append("<a href='%s'>%s</a>" %
(dsy.file.url, BookMedia.formats['daisy'].name))
return ", ".join(links)
+
+
+@register.inclusion_tag("catalogue/snippets/custom_pdf_link_li.html")
+def custom_pdf_link_li(book):
+ return {
+ 'book': book,
+ 'NO_CUSTOM_PDF': settings.NO_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,), {}
$('.sponsor-logos').cycle({timeout: 3000});
});
-})(jQuery)
+})(jQuery);
NO_BUILD_TXT = False
# You'll need XeLaTeX to generate PDF files.
NO_BUILD_PDF = True
+NO_CUSTOM_PDF = True
# You'll need Calibre installed to generate MOBI files.
NO_BUILD_MOBI = True