fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
69b59e1
)
make custom pdf optional
author
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 26 Apr 2012 09:30:54 +0000
(11:30 +0200)
committer
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 26 Apr 2012 09:30:54 +0000
(11:30 +0200)
apps/catalogue/templates/catalogue/book_text.html
patch
|
blob
|
history
apps/catalogue/templates/catalogue/book_wide.html
patch
|
blob
|
history
apps/catalogue/templates/catalogue/snippets/custom_pdf_link_li.html
[new file with mode: 0644]
patch
|
blob
apps/catalogue/templatetags/catalogue_tags.py
patch
|
blob
|
history
apps/catalogue/views.py
patch
|
blob
|
history
apps/sponsors/static/sponsors/js/sponsors.js
patch
|
blob
|
history
wolnelektury/settings/custom.py
patch
|
blob
|
history
diff --git
a/apps/catalogue/templates/catalogue/book_text.html
b/apps/catalogue/templates/catalogue/book_text.html
index
e844c96
..
d2d5d33
100644
(file)
--- a/
apps/catalogue/templates/catalogue/book_text.html
+++ b/
apps/catalogue/templates/catalogue/book_text.html
@@
-49,7
+49,7
@@
{% if book.txt_file %}
<li><a href="{{ book.txt_file.url}}">TXT</a> {% trans "for advanced usage" %}</li>
{% endif %}
{% 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>
{% if related.media.mp3 or related.media.ogg or related.media.daisy %}
<li>{% trans "Download all audiobooks for this book" %}:
{% download_audio book %}</li>
diff --git
a/apps/catalogue/templates/catalogue/book_wide.html
b/apps/catalogue/templates/catalogue/book_wide.html
index
9213560
..
8d83413
100644
(file)
--- a/
apps/catalogue/templates/catalogue/book_wide.html
+++ b/
apps/catalogue/templates/catalogue/book_wide.html
@@
-1,6
+1,6
@@
{% extends "catalogue/book_short.html" %}
{% load i18n %}
{% 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 %}
{% load cite_promo from social_tags %}
@@
-60,9
+60,7
@@
{% download_audio book %}.
{% endif %}
</li>
{% 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>
</ul>
</div>
</div>
diff --git a/apps/catalogue/templates/catalogue/snippets/custom_pdf_link_li.html
b/apps/catalogue/templates/catalogue/snippets/custom_pdf_link_li.html
new file mode 100644
(file)
index 0000000..
380844a
--- /dev/null
+++ b/
apps/catalogue/templates/catalogue/snippets/custom_pdf_link_li.html
@@ -0,0
+1,8
@@
+{% 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 %}
diff --git
a/apps/catalogue/templatetags/catalogue_tags.py
b/apps/catalogue/templatetags/catalogue_tags.py
index
fdd0a73
..
4f84dad
100644
(file)
--- a/
apps/catalogue/templatetags/catalogue_tags.py
+++ b/
apps/catalogue/templatetags/catalogue_tags.py
@@
-5,6
+5,7
@@
import datetime
import feedparser
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 import template
from django.template import Node, Variable, Template, Context
from django.core.cache import cache
@@
-12,7
+13,6
@@
from django.core.urlresolvers import reverse
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.utils.translation import ugettext as _
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
from catalogue.utils import split_tags
from catalogue.models import Book, BookMedia, Fragment, Tag
@@
-406,3
+406,11
@@
def download_audio(book, daisy=True):
links.append("<a href='%s'>%s</a>" %
(dsy.file.url, BookMedia.formats['daisy'].name))
return ", ".join(links)
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,
+ }
diff --git
a/apps/catalogue/views.py
b/apps/catalogue/views.py
index
599fde1
..
fc27e02
100644
(file)
--- a/
apps/catalogue/views.py
+++ b/
apps/catalogue/views.py
@@
-536,6
+536,11
@@
class CustomPDFFormView(AjaxableFormView):
submit = ugettext_lazy('Download')
honeypot = True
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 form_args(self, request, obj):
"""Override to parse view args and give additional args to the form."""
return (obj,), {}
diff --git
a/apps/sponsors/static/sponsors/js/sponsors.js
b/apps/sponsors/static/sponsors/js/sponsors.js
index
7674379
..
fbfbaeb
100755
(executable)
--- a/
apps/sponsors/static/sponsors/js/sponsors.js
+++ b/
apps/sponsors/static/sponsors/js/sponsors.js
@@
-4,5
+4,5
@@
$('.sponsor-logos').cycle({timeout: 3000});
});
$('.sponsor-logos').cycle({timeout: 3000});
});
-})(jQuery)
+})(jQuery)
;
diff --git
a/wolnelektury/settings/custom.py
b/wolnelektury/settings/custom.py
index
552188a
..
e059b8f
100644
(file)
--- a/
wolnelektury/settings/custom.py
+++ b/
wolnelektury/settings/custom.py
@@
-9,6
+9,7
@@
NO_BUILD_EPUB = False
NO_BUILD_TXT = False
# You'll need XeLaTeX to generate PDF files.
NO_BUILD_PDF = True
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
# You'll need Calibre installed to generate MOBI files.
NO_BUILD_MOBI = True