rework book box caching
[wolnelektury.git] / src / catalogue / templates / catalogue / book_short.html
1 {% spaceless %}
2   {% load i18n %}
3   {% load cache %}
4   {% load catalogue_tags %}
5   {% load book_shelf_tags from social_tags %}
6   {% load static %}
7
8   {% with ga=book.get_audiobooks %}
9   {% with audiobooks=ga.0 %}
10   <div class="{% block box-class %}book-box{% if audiobooks %} audiobook-box{% endif %}{% endblock %}">
11     <div class="book-box-inner">
12
13     {% block book-box-pre %}
14       {% include "catalogue/snippets/like_button.html" %}
15     {% endblock %}
16
17     {% with book.tags_by_category as tags %}
18     <div class="book-left-column">
19       <div class="book-box-body">
20         {% block book-box-body-pre %}
21         {% endblock %}
22
23         <div class="cover-area">
24           {% if book.cover_thumb %}
25             <a href="{{ book.get_absolute_url }}">
26               <img src="{{ book.cover_thumb.url }}" alt="Cover" class="cover" />
27             </a>
28           {% endif %}
29           {% block cover-area-extra %}{% endblock %}
30         </div>
31
32         {% get_current_language as LANGUAGE_CODE %}
33         {% cache 86400 book_box_head_tags book.pk LANGUAGE_CODE %}
34         <div class="book-box-head">
35           <div class="author">
36             {% for tag in tags.author %}
37               <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>{% if not forloop.last %},
38             {% endif %}{% endfor %}{% for parent in book.parents %},
39               <a href="{{ parent.get_absolute_url }}">{{ parent.title }}</a>{% endfor %}
40           </div>
41           <div class="title">
42             <a href="{{ book.get_absolute_url }}">{{ book.title }}</a>
43           </div>
44           {% if book.translator %}
45               <div class="author">
46                   tłum. {{ book.translator }}
47               </div>
48           {% endif %}
49         </div>
50
51         <div class="tags">
52           <span class="category">
53           <span class="mono"> {% trans "Epoch" %}:</span>&nbsp;<span class="book-box-tag">
54             {% for tag in tags.epoch %}
55               <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
56               {% if not forloop.last %}<span>, </span>{% endif %}
57             {% endfor %}
58           </span></span>
59
60           <span class="category">
61           <span class="mono"> {% trans "Kind" %}:</span>&nbsp;<span class="book-box-tag">
62             {% for tag in tags.kind %}
63               <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
64               {% if not forloop.last %}<span>, </span>{% endif %}
65             {% endfor %}
66           </span></span>
67
68           <span class="category">
69           <span class="mono"> {% trans "Genre" %}:</span>&nbsp;<span class="book-box-tag">
70             {% for tag in tags.genre %}
71               <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
72               {% if not forloop.last %}<span>, </span>{% endif %}
73             {% endfor %}
74           </span></span>
75
76           {% if book.extra_info.location %}
77             <span class="category">
78             <span class="mono"> {% trans "Region" %}:</span>&nbsp;<span class="book-box-tag">
79                 {{ book.extra_info.location }}
80             </span></span>
81           {% endif %}
82
83           {% if book.is_foreign %}
84             <span class="category">
85               <span class="mono"> {% trans "Language" %}:</span>&nbsp;<span class="book-box-tag">
86                 <a>{{ book.language_name }}</a>
87               </span>
88             </span>
89           {% endif %}
90
91           {% with stage_note=book.stage_note %}
92           {% if stage_note.0 %}
93             <br>
94             <span class="category">
95               <a{% if stage_note.1 %} href="{{ stage_note.1 }}"{% endif %}>{{ stage_note.0 }}</a>
96             </span>
97           {% endif %}
98           {% endwith %}
99         </div>
100         {% endcache %}
101       </div>
102       {% book_shelf_tags book.pk %}
103
104       {% cache 86400 book_box_tools book.pk book|status:request.user LANGUAGE_CODE %}
105       {% if book|status:request.user != 'closed' %}
106         <ul class="book-box-tools">
107           <li class="book-box-read">
108             {% if book.html_file %}
109               <a href="{% url 'book_text' book.slug %}" class="downarrow">{% trans "Read online" %}</a>
110             {% endif %}
111             {% if book.print_on_demand %}
112               <a href="{{ book.ridero_link }}" class="downarrow print tlite-tooltip" title="{% trans "Cena książki w druku cyfrowym jest zależna od liczby stron.<br>Przed zakupem upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia.<br>Wszystkie nasze zasoby w wersji elektronicznej są zawsze dostępne bezpłatnie." %}">{% trans "Print on demand –" %}
113                   <img src="{% static 'img/ridero.png' %}" style="height: 0.8em;"/></a>
114             {% endif %}
115           </li>
116           <li class="book-box-download">
117             <a class="downarrow">{% trans "Download" %}:</a>
118             <div class="book-box-formats">
119               {% if book.pdf_file %}
120                 <span><a href="{{ book.pdf_url}}">PDF</a></span>
121               {% endif %}
122               {% if book.epub_file %}
123                 <span><a href="{{ book.epub_url}}">EPUB</a></span>
124               {% endif %}
125               {% if book.mobi_file %}
126                 <span><a href="{{ book.mobi_url}}">MOBI</a></span>
127               {% endif %}
128               {% if book.has_audio %}
129                 <span><a href="{% url 'download_zip_mp3' book.slug %}">MP3</a></span>
130               {% endif %}
131               <a class="read-more-show hide" href="#">{% trans "more" %}</a>
132               <span class="read-more-content">
133                 {% if  book.fb2_file %}
134                   <span><a href="{{ book.fb2_url}}">FB2</a></span>
135                 {% endif %}
136                 {% if  book.txt_file %}
137                   <span><a href="{{ book.txt_url}}">TXT</a></span>
138                 {% endif %}
139                 {% download_audio book mp3=False %}
140                 <br>
141                 {% custom_pdf_link_li book %}
142                 <a class="read-more-hide hide" href="#">{% trans "less" %}</a>
143               </span>
144             </div>
145           </li>
146         </ul>
147       {% else %}
148         <p class="book-box-tools">{% trans "For now this work is only available for our subscribers." %}</p>
149       {% endif %}
150       {% endcache %}
151       {% block book-box-extra-info %}{% endblock %}
152       {% block box-append %}{% endblock %}
153     </div>
154     {% endwith %}
155
156     {% block right-column %}
157       {% if audiobooks %}
158         <div class="book-right-column">
159           {% include 'catalogue/snippets/jplayer.html' %}
160         </div>
161       {% endif %}
162     {% endblock %}
163     {% if book.abstract %}
164       <div class="abstract more-expand">
165         {{ book.abstract|safe }}
166       </div>
167     {% endif %}
168
169     <div class="clearboth"></div>
170     </div>
171   </div>
172   {% endwith %}
173   {% endwith %}
174 {% endspaceless %}