X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/608e6d8048124bd547efca2ce65ea0b7907ff697..3e276f49505e607b72892b40d18ac2cef194497e:/apps/catalogue/templatetags/book_list.py diff --git a/apps/catalogue/templatetags/book_list.py b/apps/catalogue/templatetags/book_list.py index f5b7e647..46cf87a4 100755 --- a/apps/catalogue/templatetags/book_list.py +++ b/apps/catalogue/templatetags/book_list.py @@ -103,6 +103,9 @@ def document_list_filter(request, **kwargs): chunks = chunks.order_by('book__title', 'book', 'number') + if not request.user.is_authenticated(): + chunks = chunks.filter(book__public=True) + state = arg_or_GET('status') if state in _states_dict: chunks = chunks.filter(_states_dict[state]) @@ -122,11 +125,17 @@ def book_list(context, user=None): new_context = {"viewed_user": user} else: filters = {} - new_context = {"users": User.objects.annotate( + new_context = { + "users": User.objects.annotate( count=Count('chunk')).filter(count__gt=0).order_by( - '-count', 'last_name', 'first_name')} + '-count', 'last_name', 'first_name'), + "other_users": User.objects.annotate( + count=Count('chunk')).filter(count=0).order_by( + 'last_name', 'first_name'), + } new_context.update({ + "filters": True, "request": request, "books": ChunksList(document_list_filter(request, **filters)), "stages": Chunk.tag_model.objects.all(), @@ -134,4 +143,3 @@ def book_list(context, user=None): }) return new_context -