From: Jan Szejko Date: Tue, 12 Apr 2016 09:56:01 +0000 (+0200) Subject: book mini box: cache instead of ssi X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/0bd6d7d8e87e1d538661b6167d0a5d99428dfc39?hp=4d9f6719c754615261fc5c63d5a7081e598ed711 book mini box: cache instead of ssi --- diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 3811bbac1..d3e2a7756 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -153,6 +153,9 @@ class Book(models.Model): def language_name(self): return dict(settings.LANGUAGES).get(self.language_code(), "") + def is_foreign(self): + return self.language_code() != settings.LANGUAGE_CODE + def has_media(self, type_): if type_ in Book.formats: return bool(getattr(self, "%s_file" % type_)) diff --git a/src/catalogue/templates/catalogue/book_detail.html b/src/catalogue/templates/catalogue/book_detail.html index b87e9eb1f..308318161 100644 --- a/src/catalogue/templates/catalogue/book_detail.html +++ b/src/catalogue/templates/catalogue/book_detail.html @@ -3,6 +3,7 @@ {% load common_tags catalogue_tags %} {% load ssify %} {% load build_absolute_uri from fnp_common %} +{% load cache %} {% block titleextra %}{{ book.pretty_title }}{% endblock %} {% block ogimage %}{% if book.cover %}{{ book.cover.url|build_absolute_uri:request }}{% endif %}{% endblock %} @@ -22,7 +23,10 @@

{% trans "Other versions" %}:

{% for rel in book.other_versions %} - {% ssi_include 'catalogue_book_mini' pk=rel.pk %} + {% cache 86400 book_mini_box rel.pk %} + {% include 'catalogue/book_mini_box.html' with book=rel %} + {% endcache %} + {#% ssi_include 'catalogue_book_mini' pk=rel.pk %#} {% endfor %}
{% endif %} diff --git a/src/catalogue/templates/catalogue/book_mini_box.html b/src/catalogue/templates/catalogue/book_mini_box.html index d77f91062..b74d6519f 100755 --- a/src/catalogue/templates/catalogue/book_mini_box.html +++ b/src/catalogue/templates/catalogue/book_mini_box.html @@ -1,22 +1,24 @@ {% spaceless %} -
- + {% endwith %} {% endspaceless %} \ No newline at end of file diff --git a/src/catalogue/templates/catalogue/book_text.html b/src/catalogue/templates/catalogue/book_text.html index 339cfc7b2..f51e565e6 100644 --- a/src/catalogue/templates/catalogue/book_text.html +++ b/src/catalogue/templates/catalogue/book_text.html @@ -2,6 +2,7 @@ {% load i18n %} {% load catalogue_tags ssify %} {% load thumbnail %} +{% load cache %} {% block title %}{{ book.pretty_title }}{% endblock %} @@ -75,11 +76,15 @@