change response from api/snapshots
This commit is contained in:
parent
1bf2c1558d
commit
2b40104180
23
api/views.py
23
api/views.py
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
@ -69,9 +70,29 @@ def NewSnapshot(request):
|
||||||
except Exception:
|
except Exception:
|
||||||
return JsonResponse({'status': 'fail'}, status=200)
|
return JsonResponse({'status': 'fail'}, status=200)
|
||||||
|
|
||||||
return JsonResponse({'status': 'success'}, status=200)
|
annotation = Annotation.objects.filter(
|
||||||
|
uuid=data['uuid'],
|
||||||
|
type=Annotation.Type.SYSTEM,
|
||||||
|
key="hidalgo1",
|
||||||
|
owner=tk.owner.institution
|
||||||
|
).first()
|
||||||
|
|
||||||
|
|
||||||
|
if not annotation:
|
||||||
|
return JsonResponse({'status': 'fail'}, status=200)
|
||||||
|
|
||||||
|
url = "{}://{}{}".format(
|
||||||
|
request.scheme,
|
||||||
|
settings.DOMAIN,
|
||||||
|
reverse_lazy("device:details", args=(annotation.value,))
|
||||||
|
)
|
||||||
|
response = {
|
||||||
|
"status": "success",
|
||||||
|
"dhid": annotation.value[:5].upper(),
|
||||||
|
"url": url,
|
||||||
|
"public_url": url
|
||||||
|
}
|
||||||
|
return JsonResponse(response, status=200)
|
||||||
|
|
||||||
|
|
||||||
class TokenView(DashboardView, SingleTableView):
|
class TokenView(DashboardView, SingleTableView):
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Device:
|
||||||
# the id is the chid of the device
|
# the id is the chid of the device
|
||||||
self.id = kwargs["id"]
|
self.id = kwargs["id"]
|
||||||
self.pk = self.id
|
self.pk = self.id
|
||||||
self.shortid = self.pk[:6]
|
self.shortid = self.pk[:6].upper()
|
||||||
self.algorithm = None
|
self.algorithm = None
|
||||||
self.owner = None
|
self.owner = None
|
||||||
self.annotations = []
|
self.annotations = []
|
||||||
|
|
Loading…
Reference in New Issue