X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/739f27c960d11c123e8ba20a282b1755b9fcd358..640e6f5c1e85d05d728cd29a129df9ea8aa8f31f:/apps/catalogue/views.py diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index cc5601593..6dd3d7ec1 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -21,10 +21,10 @@ from django.utils.translation import ugettext as _, ugettext_lazy from django.views.decorators.cache import never_cache 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, collection_list from pdcounter import models as pdcounter_models from pdcounter import views as pdcounter_views from suggest.forms import PublishingSuggestForm @@ -42,9 +42,20 @@ def catalogue(request): tag.count = tag.book_count categories = split_tags(tags) fragment_tags = categories.get('theme', []) - - return render_to_response('catalogue/catalogue.html', locals(), - context_instance=RequestContext(request)) + collections = models.Collection.objects.all() + + if request.is_ajax(): + render_tag_list = lambda x: render_to_string( + 'catalogue/tag_list.html', tag_list(x)) + 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(), + context_instance=RequestContext(request)) def book_list(request, filter=None, template_name='catalogue/book_list.html',