From 2983d583c9de4c33ed73d6c06d9d6eb54b30f15e Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Tue, 3 Jul 2018 12:09:29 +0200 Subject: [PATCH 1/1] vary template cache on language --- src/catalogue/templates/catalogue/book_detail.html | 3 ++- src/catalogue/templates/catalogue/book_text.html | 3 ++- src/catalogue/templates/catalogue/work-list.html | 12 +++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/catalogue/templates/catalogue/book_detail.html b/src/catalogue/templates/catalogue/book_detail.html index 3b13624a4..cf26b125a 100644 --- a/src/catalogue/templates/catalogue/book_detail.html +++ b/src/catalogue/templates/catalogue/book_detail.html @@ -13,7 +13,8 @@ {% block bodyid %}book-detail{% endblock %} {% block body %} - {% cache 86400 book_wide book.pk book|status:user %} + {% get_current_language as LANGUAGE_CODE %} + {% cache 86400 book_wide book.pk book|status:user LANGUAGE_CODE %} {% include 'catalogue/book_wide.html' %} {% endcache %} diff --git a/src/catalogue/templates/catalogue/book_text.html b/src/catalogue/templates/catalogue/book_text.html index f697e4ee2..5894fe825 100644 --- a/src/catalogue/templates/catalogue/book_text.html +++ b/src/catalogue/templates/catalogue/book_text.html @@ -110,7 +110,8 @@
- {% cache 86400 catalogue_book_short book.pk book|status:user %} + {% get_current_language as LANGUAGE_CODE %} + {% cache 86400 book_short book.pk book|status:user LANGUAGE_CODE %} {% include 'catalogue/book_short.html' %} {% endcache %}
diff --git a/src/catalogue/templates/catalogue/work-list.html b/src/catalogue/templates/catalogue/work-list.html index 03833c16f..178654c70 100755 --- a/src/catalogue/templates/catalogue/work-list.html +++ b/src/catalogue/templates/catalogue/work-list.html @@ -1,7 +1,10 @@ {% spaceless %} + {% load cache %} + {% load i18n %} {% load pagination_tags %} {% load class_name from catalogue_tags %} + {% load status from catalogue_tags %} {% load ssi_include from ssify %} {% autopaginate object_list 10 %} @@ -9,7 +12,14 @@
    {% for item in object_list %}
  1. - {% ssi_include item.short_html_url_name pk=item.pk %} + {% if item|class_name == 'Book' %} + {% get_current_language as LANGUAGE_CODE %} + {% cache 86400 book_short item.pk item|status:request.user LANGUAGE_CODE %} + {% include "catalogue/book_short.html" with book=item %} + {% endcache %} + {% else %} + {% ssi_include item.short_html_url_name pk=item.pk %} + {% endif %}
  2. {% endfor %}
-- 2.20.1