From: Radek Czajka Date: Tue, 16 Jul 2013 10:39:03 +0000 (+0200) Subject: Allow filtering by project X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/2277b557ee1f827c664bdb3a2b426ea71760c4d0 Allow filtering by project --- diff --git a/apps/catalogue/templates/catalogue/book_list/book.html b/apps/catalogue/templates/catalogue/book_list/book.html index 658d009c..5866e6ac 100755 --- a/apps/catalogue/templates/catalogue/book_list/book.html +++ b/apps/catalogue/templates/catalogue/book_list/book.html @@ -19,6 +19,7 @@ {% if book.new_publishable %}p{% endif %} {% if chunk.changed %}+{% endif %} + {{ book.project.name }} {% endwith %} {% else %} @@ -33,5 +34,6 @@ {% if book.published %}P{% endif %} {% if book.new_publishable %}p{% endif %} + {{ book.project.name }} {% endif %} diff --git a/apps/catalogue/templates/catalogue/book_list/book_list.html b/apps/catalogue/templates/catalogue/book_list/book_list.html index 40237235..35537684 100755 --- a/apps/catalogue/templates/catalogue/book_list/book_list.html +++ b/apps/catalogue/templates/catalogue/book_list/book_list.html @@ -10,6 +10,7 @@ {% endif %} + @@ -57,6 +58,16 @@ {% endfor %} + + {% with cnt=books|length %} diff --git a/apps/catalogue/templatetags/book_list.py b/apps/catalogue/templatetags/book_list.py index 46cf87a4..14149e84 100755 --- a/apps/catalogue/templatetags/book_list.py +++ b/apps/catalogue/templatetags/book_list.py @@ -5,7 +5,7 @@ from django.db.models import Q, Count from django import template from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User -from catalogue.models import Chunk +from catalogue.models import Chunk, Project register = template.Library() @@ -113,6 +113,7 @@ def document_list_filter(request, **kwargs): chunks = foreign_filter(chunks, arg_or_GET('user'), 'user', User, 'username') chunks = foreign_filter(chunks, arg_or_GET('stage'), 'stage', Chunk.tag_model, 'slug') chunks = search_filter(chunks, arg_or_GET('title'), ['book__title', 'title']) + chunks = foreign_filter(chunks, arg_or_GET('project'), 'book__project', Project, 'pk') return chunks @@ -140,6 +141,7 @@ def book_list(context, user=None): "books": ChunksList(document_list_filter(request, **filters)), "stages": Chunk.tag_model.objects.all(), "states": _states_options, + "projects": Project.objects.all(), }) return new_context