X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/d95d8a5fe401479b8adaa10cb77012c130525efd..fa0414cf62aaa1e72c02b1b12567dddfcfcd12d2:/apps/catalogue/views.py?ds=inline diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 745ff10e2..0adce195a 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -73,11 +73,27 @@ def book_list(request): context_instance=RequestContext(request)) +def differentiate_tags(request, tags, ambiguous_slugs): + beginning = '/'.join(tag.url_chunk for tag in tags) + unparsed = '/'.join(ambiguous_slugs[1:]) + options = [] + for tag in models.Tag.objects.exclude(category='book').filter(slug=ambiguous_slugs[0]): + options.append({ + 'url_args': '/'.join((beginning, tag.url_chunk, unparsed)).strip('/'), + 'tags': [tag] + }) + return render_to_response('catalogue/differentiate_tags.html', + {'tags': tags, 'options': options, 'unparsed': ambiguous_slugs[1:]}, + context_instance=RequestContext(request)) + + def tagged_object_list(request, tags=''): try: tags = models.Tag.get_tag_list(tags) except models.Tag.DoesNotExist: raise Http404 + except models.Tag.MultipleObjectsReturned, e: + return differentiate_tags(request, e.tags, e.ambiguous_slugs) try: if len(tags) > settings.MAX_TAG_LIST: