X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/53c686bd32e1ecd66719df1a4facf5a170d9ae30..23f0993732ac597e0a4ab1330b62b970c09d476c:/apps/catalogue/views.py?ds=sidebyside diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 66036bf77..e61feb6c2 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -19,13 +19,13 @@ from django.utils.http import urlquote_plus from django.utils import translation from django.utils.translation import ugettext as _, ugettext_lazy from django.views.decorators.cache import never_cache +from django.views.decorators.vary import vary_on_headers from ajaxable.utils import JSONResponse, AjaxableFormView - from catalogue import models from catalogue import forms from catalogue.utils import split_tags, MultiQuerySet -from catalogue.templatetags.catalogue_tags import tag_list +from catalogue.templatetags.catalogue_tags import tag_list, collection_list from pdcounter import models as pdcounter_models from pdcounter import views as pdcounter_views from suggest.forms import PublishingSuggestForm @@ -35,6 +35,7 @@ staff_required = user_passes_test(lambda user: user.is_staff) permanent_cache = get_cache('permanent') +@vary_on_headers('X-Requested-With') def catalogue(request): tags = models.Tag.objects.exclude( category__in=('set', 'book')).exclude(book_count=0) @@ -43,6 +44,7 @@ def catalogue(request): tag.count = tag.book_count categories = split_tags(tags) fragment_tags = categories.get('theme', []) + collections = models.Collection.objects.all() if request.is_ajax(): render_tag_list = lambda x: render_to_string( @@ -50,6 +52,8 @@ def catalogue(request): output = {'theme': render_tag_list(fragment_tags)} for category, tags in categories.items(): output[category] = render_tag_list(tags) + output['collections'] = render_to_string( + 'catalogue/collection_list.html', collection_list(collections)) return JSONResponse(output) else: return render_to_response('catalogue/catalogue.html', locals(),