fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minor template fixes
[wolnelektury.git]
/
apps
/
catalogue
/
views.py
diff --git
a/apps/catalogue/views.py
b/apps/catalogue/views.py
index
a6f394f
..
84cce7b
100644
(file)
--- a/
apps/catalogue/views.py
+++ b/
apps/catalogue/views.py
@@
-15,7
+15,7
@@
from datetime import datetime
from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
-from django.http import HttpResponse, HttpResponseRedirect, Http404
+from django.http import HttpResponse, HttpResponseRedirect, Http404
, HttpResponsePermanentRedirect
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.contrib.auth.decorators import login_required, user_passes_test
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.contrib.auth.decorators import login_required, user_passes_test
@@
-152,6
+152,8
@@
def tagged_object_list(request, tags=''):
raise Http404
except models.Tag.MultipleObjectsReturned, e:
return differentiate_tags(request, e.tags, e.ambiguous_slugs)
raise Http404
except models.Tag.MultipleObjectsReturned, e:
return differentiate_tags(request, e.tags, e.ambiguous_slugs)
+ except models.Tag.UrlDeprecationWarning, e:
+ return HttpResponsePermanentRedirect(reverse('tagged_object_list', args=['/'.join(tag.url_chunk for tag in e.tags)]))
try:
if len(tags) > settings.MAX_TAG_LIST:
try:
if len(tags) > settings.MAX_TAG_LIST:
@@
-491,13
+493,14
@@
def json_tags_starting_with(request, callback=None):
if len(prefix) < 2:
return HttpResponse('')
tags_list = []
if len(prefix) < 2:
return HttpResponse('')
tags_list = []
- result = ""
for tag in _tags_starting_with(prefix, request.user):
if not tag.name in tags_list:
for tag in _tags_starting_with(prefix, request.user):
if not tag.name in tags_list:
- result += "\n" + tag.name
tags_list.append(tag.name)
tags_list.append(tag.name)
- dict_result = {"matches": tags_list}
- return JSONResponse(dict_result, callback)
+ if request.GET.get('mozhint', ''):
+ result = [prefix, tags_list]
+ else:
+ result = {"matches": tags_list}
+ return JSONResponse(result, callback)
# ====================
# = Shelf management =
# ====================
# = Shelf management =