fix 404 response
This commit is contained in:
parent
9bc36f5634
commit
8ac6779bb1
1 changed files with 6 additions and 5 deletions
|
@ -1005,10 +1005,9 @@ def item_json(request, id):
|
||||||
response = json_response(status=404, text='not found')
|
response = json_response(status=404, text='not found')
|
||||||
else:
|
else:
|
||||||
item = qs[0]
|
item = qs[0]
|
||||||
j = item.get_json()
|
response = item.get_json()
|
||||||
j['layers'] = item.get_layers(request.user)
|
response['layers'] = item.get_layers(request.user)
|
||||||
response = render_to_json_response(j)
|
return render_to_json_response(response)
|
||||||
return response
|
|
||||||
|
|
||||||
def item_xml(request, id):
|
def item_xml(request, id):
|
||||||
level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
||||||
|
@ -1017,6 +1016,7 @@ def item_xml(request, id):
|
||||||
qs = models.Item.objects.filter(itemId=id, level__lte=level)
|
qs = models.Item.objects.filter(itemId=id, level__lte=level)
|
||||||
if qs.count() == 0:
|
if qs.count() == 0:
|
||||||
response = json_response(status=404, text='not found')
|
response = json_response(status=404, text='not found')
|
||||||
|
response = render_to_json_response(response)
|
||||||
else:
|
else:
|
||||||
item = qs[0]
|
item = qs[0]
|
||||||
j = item.get_json()
|
j = item.get_json()
|
||||||
|
@ -1025,8 +1025,9 @@ def item_xml(request, id):
|
||||||
def xmltree(root, key, data):
|
def xmltree(root, key, data):
|
||||||
if isinstance(data, list) or \
|
if isinstance(data, list) or \
|
||||||
isinstance(data, tuple):
|
isinstance(data, tuple):
|
||||||
|
e = ET.SubElement(root, key)
|
||||||
for value in data:
|
for value in data:
|
||||||
xmltree(root, key, value)
|
xmltree(e, key, value)
|
||||||
elif isinstance(data, dict):
|
elif isinstance(data, dict):
|
||||||
for k in data:
|
for k in data:
|
||||||
if data[k]:
|
if data[k]:
|
||||||
|
|
Loading…
Reference in a new issue