Other versions on book detail page.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Mon, 27 Jan 2014 10:07:50 +0000 (11:07 +0100)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Mon, 27 Jan 2014 10:07:50 +0000 (11:07 +0100)
apps/catalogue/templates/catalogue/book_detail.html
apps/catalogue/templatetags/catalogue_tags.py
apps/catalogue/tests/tags.py
apps/wolnelektury_core/static/scss/main/book_box.scss

index bb5abeb..454bce1 100644 (file)
 
 {% work_list book_children %}
 
 
 {% 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>
 <h1>{% trans "See also" %}:</h1>
-{% related_books book %}
+{% related_books book taken=book.other_versions|length %}
 </section>
 </section>
+{% endspaceless %}
 
 {% endblock %}
 
 {% endblock %}
index e80a5ff..0800865 100644 (file)
@@ -388,17 +388,14 @@ def fragment_promo(arg=None):
 
 
 @register.inclusion_tag('catalogue/related_books.html')
 
 
 @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:
     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(
         cache.set(cache_key, related, 1800)
     if random:
         random_books = Book.objects.exclude(
index 99edebb..c3d50e2 100644 (file)
@@ -270,10 +270,10 @@ class BookTagsTests(WLTestCase):
         related_info = book.related_info()
         related_themes = book.related_themes()
 
         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)])
 
         self.assertEqual([(tag.name, tag.count) for tag in related_themes],
                          [('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)])
 
index e72bca8..c9b3656 100755 (executable)
@@ -6,11 +6,6 @@
     @include white-box;
 }
 
     @include white-box;
 }
 
-.book-mini-box img.cover {
-    @include size(height, 193px);
-    @include size(width, 139px);
-}
-
 
 .cover-area {
     float: left;
 
 .cover-area {
     float: left;
 }
 
 .book-mini-box {
 }
 
 .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;
 
     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);
     .book-mini-box-inner {
         @include inner-box;
         @include size(height, 271px);
         @include size(margin, 1px);
+        @include size(padding, 8px 9px);
         overflow: hidden;
         overflow: hidden;
+
+        @include min-screen(350px) {
+            @include size(padding, 8px 10px);
+        }
+
         a {
             display: block;
         }
     }
     img.cover {
         a {
             display: block;
         }
     }
     img.cover {
+        @include size(height, 193px);
+        @include size(width, 139px);
         @include size(margin-bottom, 18px);
     }
     .language {
         @include size(margin-bottom, 18px);
     }
     .language {