Skip to content

Commit

Permalink
Merge pull request #2837 from mkoistinen/json_mime_type_for_2788
Browse files Browse the repository at this point in the history
Add JSON MIME types to HttpResponse in resolve() per digi604's direction
  • Loading branch information
digi604 committed Mar 7, 2014
2 parents 698fe1c + a165083 commit 20a4edc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cms/admin/pageadmin.py
Expand Up @@ -1249,14 +1249,14 @@ def add_page_type(self, request):

def resolve(self, request):
if not request.user.is_staff:
return HttpResponse('')
return HttpResponse('', content_type='application/json')
if request.session.get('cms_log_latest', False):
log = LogEntry.objects.get(pk=request.session['cms_log_latest'])
obj = log.get_edited_object()
del request.session['cms_log_latest']
if obj.__class__ in toolbar_pool.get_watch_models() and hasattr(obj, 'get_absolute_url'):
try:
return HttpResponse(force_unicode(obj.get_absolute_url()))
return HttpResponse(force_unicode(obj.get_absolute_url()), content_type='application/json')
except:
pass
pk = request.REQUEST.get('pk')
Expand All @@ -1268,9 +1268,9 @@ def resolve(self, request):
try:
instance = ctype.get_object_for_this_type(pk=pk)
except ctype.model_class().DoesNotExist:
return HttpResponse('/')
return HttpResponse(force_unicode(instance.get_absolute_url()))
return HttpResponse('')
return HttpResponse('/', content_type='application/json')
return HttpResponse(force_unicode(instance.get_absolute_url()), content_type='application/json')
return HttpResponse('', content_type='application/json')

def lookup_allowed(self, key, *args, **kwargs):
if key == 'site__exact':
Expand Down

0 comments on commit 20a4edc

Please sign in to comment.