#12 wystawione 20 najpopularniejszych książek
authorJan Szejko <j-sz@o2.pl>
Tue, 16 Feb 2016 11:16:03 +0000 (12:16 +0100)
committerJan Szejko <j-sz@o2.pl>
Tue, 16 Feb 2016 11:16:03 +0000 (12:16 +0100)
src/catalogue/templates/catalogue/tagged_object_list.html
src/catalogue/views.py

index b8eea9c..9af03f5 100644 (file)
@@ -9,11 +9,7 @@
 
 {% block body %}
 <div class="tabbed-filter">
 
 {% block body %}
 <div class="tabbed-filter">
-    <h1>{% if tags %}
-        {% html_title_from_tags tags %}
-        {% elif list_type == 'gallery' %}{% trans "Gallery" %}{% elif list_type == 'audiobooks' %}{% trans "Audiobooks" %}{% else %}{% trans "Literature" %}
-        {% endif %}
-    </h1>
+    <h1>{% if tags %}{% html_title_from_tags tags %}{% endif %}</h1>
 
     <div class="tabs">
         <a class="tab white-box" data-id="authors">{% trans "Authors" %}</a>
 
     <div class="tabs">
         <a class="tab white-box" data-id="authors">{% trans "Authors" %}</a>
 {% if list_type == 'books' and not tags %}
     <section>
         <h1>{% trans "Recent publications" %}</h1>
 {% if list_type == 'books' and not tags %}
     <section>
         <h1>{% trans "Recent publications" %}</h1>
-            {% for book in last_published %}
-                {% ssi_include 'catalogue_book_mini' pk=book.pk %}
-            {% endfor %}
+        {% for book in last_published %}
+            {% ssi_include 'catalogue_book_mini' pk=book.pk %}
+        {% endfor %}
         <a class="more" href="{% url 'recent_list' %}">{% trans "More recent publications" %}</a>
     </section>
         <a class="more" href="{% url 'recent_list' %}">{% trans "More recent publications" %}</a>
     </section>
+    <section>
+        <h1>{% trans "Most popular books" %}</h1>
+        {% for book in most_popular %}
+            {% ssi_include 'catalogue_book_mini' pk=book.pk %}
+        {% endfor %}
+    </section>
 {% endif %}
 
 {% if theme_is_set %}
 {% endif %}
 
 {% if theme_is_set %}
index b39bb87..12cfdc5 100644 (file)
@@ -236,8 +236,10 @@ def tagged_object_list(request, tags='', list_type='books'):
     # this is becoming more and more hacky
     if list_type == 'books' and not tags:
         last_published = Book.objects.exclude(cover_thumb='').filter(parent=None).order_by('-created_at')[:20]
     # this is becoming more and more hacky
     if list_type == 'books' and not tags:
         last_published = Book.objects.exclude(cover_thumb='').filter(parent=None).order_by('-created_at')[:20]
+        most_popular = Book.objects.exclude(cover_thumb='').order_by('-popularity__count')[:20]
     else:
         last_published = None
     else:
         last_published = None
+        most_popular = None
 
     return render_to_response(
         'catalogue/tagged_object_list.html',
 
     return render_to_response(
         'catalogue/tagged_object_list.html',
@@ -254,6 +256,7 @@ def tagged_object_list(request, tags='', list_type='books'):
             'list_type': list_type,
             'daisy': daisy,
             'last_published': last_published,
             'list_type': list_type,
             'daisy': daisy,
             'last_published': last_published,
+            'most_popular': most_popular,
             'active_menu_item': 'theme' if theme_is_set else list_type,
         },
         context_instance=RequestContext(request))
             'active_menu_item': 'theme' if theme_is_set else list_type,
         },
         context_instance=RequestContext(request))