misc: use application/javascript for menu.json served as jsonp (#14685)

This commit is contained in:
Frédéric Péters 2019-06-26 20:17:14 +02:00
parent 81e955d803
commit 57765a7916
1 changed files with 3 additions and 1 deletions

View File

@ -133,15 +133,17 @@ def health_json(request):
@admin_required
def menu_json(request):
response = HttpResponse(content_type='application/json')
label = _('System')
json_str = json.dumps([{'label': force_text(label),
'slug': 'system',
'url': request.build_absolute_uri(reverse('home'))
}])
content_type = 'application/json'
for variable in ('jsonpCallback', 'callback'):
if variable in request.GET:
json_str = '%s(%s);' % (request.GET[variable], json_str)
content_type = 'application/javascript'
break
response = HttpResponse(content_type=content_type)
response.write(json_str)
return response