- result = _tags_starting_with(prefix, request.user)
- if len(result) > 0:
- tag = result[0]
- if isinstance(tag, models.Book) or isinstance(tag, models.BookStub):
- return HttpResponseRedirect(tag.get_absolute_url())
- else:
- tag_list.append(tag)
-
- return HttpResponseRedirect(reverse('catalogue.views.tagged_object_list',
- kwargs={'tags': '/'.join(tag.slug for tag in tag_list)}
- ))
+ result = _tags_exact_matches(prefix, request.user)
+
+ if len(result) > 1:
+ # multiple exact matches
+ return render_to_response('catalogue/search_multiple_hits.html',
+ {'tags':tag_list, 'prefix':prefix, 'results':((x, _get_result_link(x, tag_list), _get_result_type(x)) for x in result)},
+ context_instance=RequestContext(request))
+
+ if not result:
+ # no exact matches
+ result = _tags_starting_with(prefix, request.user)
+
+ if result:
+ return HttpResponseRedirect(_get_result_link(result[0], tag_list))