{% work_list book_children %}
+{% spaceless %}
+{% if book.other_versions %}
+<section class="see-also" style="display: inline-block;">
+<h1>{% trans "Other versions" %}:</h1>
+{% for rel in book.other_versions %}
+ {% book_mini rel %}
+{% endfor %}
+</section>
+{% endif %}
-<section class="see-also">
+<section class="see-also" style="display: inline-block;">
<h1>{% trans "See also" %}:</h1>
-{% related_books book %}
+{% related_books book taken=book.other_versions|length %}
</section>
+{% endspaceless %}
{% endblock %}
@register.inclusion_tag('catalogue/related_books.html')
-def related_books(book, limit=6, random=1):
+def related_books(book, limit=6, random=1, taken=0):
+ limit = limit - taken
cache_key = "catalogue.related_books.%d.%d" % (book.id, limit - random)
related = cache.get(cache_key)
if related is None:
- related = list(Book.objects.filter(
- common_slug=book.common_slug).exclude(pk=book.pk)[:limit])
- limit -= len(related)
- if limit > random:
- related += Book.tagged.related_to(book,
- Book.objects.exclude(common_slug=book.common_slug),
- ignore_by_tag=book.book_tag())[:limit-random]
+ related = Book.tagged.related_to(book,
+ Book.objects.exclude(common_slug=book.common_slug),
+ ignore_by_tag=book.book_tag())[:limit-random]
cache.set(cache_key, related, 1800)
if random:
random_books = Book.objects.exclude(
related_info = book.related_info()
related_themes = book.related_themes()
- self.assertEqual(related_info['tags']['author'],
- [{'name_pl': 'Common Man', 'slug': 'common-man'}])
- self.assertEqual(related_info['tags']['kind'],
- [{'name_pl': 'Kind', 'slug': 'kind'}])
+ self.assertEqual([t['slug'] for t in related_info['tags']['author']],
+ ['common-man'])
+ self.assertEqual([t['slug'] for t in related_info['tags']['kind']],
+ ['kind'])
self.assertEqual([(tag.name, tag.count) for tag in related_themes],
[('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)])
@include white-box;
}
-.book-mini-box img.cover {
- @include size(height, 193px);
- @include size(width, 139px);
-}
-
.cover-area {
float: left;
}
.book-mini-box {
- @include size(width, 161.5px);
+ /* Original design fits 6 boxes horizontally in 975px (162.5px each),
+ * but we really want to fit 2 boxes on a 320px mobile screen. */
+
+ @include size(width, 160px);
display: inline-block;
vertical-align: top;
+ @include min-screen(350px) {
+ @include size(width, 162.5px);
+ }
+
.book-mini-box-inner {
@include inner-box;
@include size(height, 271px);
@include size(margin, 1px);
+ @include size(padding, 8px 9px);
overflow: hidden;
+
+ @include min-screen(350px) {
+ @include size(padding, 8px 10px);
+ }
+
a {
display: block;
}
}
img.cover {
+ @include size(height, 193px);
+ @include size(width, 139px);
@include size(margin-bottom, 18px);
}
.language {