From 0bd6d7d8e87e1d538661b6167d0a5d99428dfc39 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Tue, 12 Apr 2016 11:56:01 +0200 Subject: [PATCH] book mini box: cache instead of ssi --- src/catalogue/models/book.py | 3 + .../templates/catalogue/book_detail.html | 6 +- .../templates/catalogue/book_mini_box.html | 32 +-- .../templates/catalogue/book_text.html | 15 +- .../templates/catalogue/collection_box.html | 8 +- .../templates/catalogue/related_books.html | 6 +- src/catalogue/views.py | 4 +- src/wolnelektury/templates/main_page.html | 248 +++++++++--------- 8 files changed, 175 insertions(+), 147 deletions(-) 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 @@