From: Jan Szejko Date: Tue, 16 Feb 2016 11:16:03 +0000 (+0100) Subject: #12 wystawione 20 najpopularniejszych książek X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/1ca64302e8447c9715ab42dd1a33075f312e6059 #12 wystawione 20 najpopularniejszych książek --- diff --git a/src/catalogue/templates/catalogue/tagged_object_list.html b/src/catalogue/templates/catalogue/tagged_object_list.html index b8eea9c7f..9af03f51e 100644 --- a/src/catalogue/templates/catalogue/tagged_object_list.html +++ b/src/catalogue/templates/catalogue/tagged_object_list.html @@ -9,11 +9,7 @@ {% block body %}
-

{% if tags %} - {% html_title_from_tags tags %} - {% elif list_type == 'gallery' %}{% trans "Gallery" %}{% elif list_type == 'audiobooks' %}{% trans "Audiobooks" %}{% else %}{% trans "Literature" %} - {% endif %} -

+

{% if tags %}{% html_title_from_tags tags %}{% endif %}

{% trans "Authors" %} @@ -49,11 +45,17 @@ {% if list_type == 'books' and not tags %}

{% trans "Recent publications" %}

- {% 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 %} {% trans "More recent publications" %}
+
+

{% trans "Most popular books" %}

+ {% for book in most_popular %} + {% ssi_include 'catalogue_book_mini' pk=book.pk %} + {% endfor %} +
{% endif %} {% if theme_is_set %} diff --git a/src/catalogue/views.py b/src/catalogue/views.py index b39bb8715..12cfdc577 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -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] + most_popular = Book.objects.exclude(cover_thumb='').order_by('-popularity__count')[:20] else: last_published = None + most_popular = None 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, + 'most_popular': most_popular, 'active_menu_item': 'theme' if theme_is_set else list_type, }, context_instance=RequestContext(request))