api snapshot public_url bugfix

with the following code the URL is more appropriate (it basically
mirrors the user's request)

before:

    http://localhost/device/{shortid}

after

    http://localhost:8000/device/{shortid}
This commit is contained in:
pedro 2024-10-15 13:09:34 +02:00
parent b4c4ed2689
commit 5e6546169b

View file

@ -82,15 +82,14 @@ def NewSnapshot(request):
if not annotation:
return JsonResponse({'status': 'fail'}, status=200)
url = "{}://{}{}".format(
request.scheme,
settings.DOMAIN,
reverse_lazy("device:details", args=(annotation.value,))
)
url_args = reverse_lazy("device:details", args=(annotation.value,))
url = request.build_absolute_uri(url_args)
response = {
"status": "success",
"dhid": annotation.value[:6].upper(),
"url": url,
# TODO replace with public_url when available
"public_url": url
}
return JsonResponse(response, status=200)