X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/020556cb431cabc6357bf02d88ab993cfe86f16a..633c738404af70bacebd4bda52cf328803fe73ed:/apps/catalogue/templatetags/book_list.py diff --git a/apps/catalogue/templatetags/book_list.py b/apps/catalogue/templatetags/book_list.py index 46cf87a4..6e64ed61 100755 --- a/apps/catalogue/templatetags/book_list.py +++ b/apps/catalogue/templatetags/book_list.py @@ -1,21 +1,21 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import -from re import split 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() class ChunksList(object): def __init__(self, chunk_qs): - #self.chunk_qs = chunk_qs#.annotate( - #book_length=Count('book__chunk')).select_related( - #'book')#, 'stage__name', - #'user') + # self.chunk_qs = chunk_qs#.annotate( + # book_length=Count('book__chunk')).select_related( + # 'book')#, 'stage__name', + # 'user') self.chunk_qs = chunk_qs.select_related('book__hidden') self.book_qs = chunk_qs.values('book_id') @@ -111,8 +111,9 @@ def document_list_filter(request, **kwargs): chunks = chunks.filter(_states_dict[state]) 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 = foreign_filter(chunks, arg_or_GET('stage'), 'stage', Chunk.tag_model) 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