Compare commits
No commits in common. "9badf494a6ff5fc46bb474ae626d3226b0e092dc" and "a08428c90b05aa222b81b1350ca899e093dbe5e4" have entirely different histories.
9badf494a6
...
a08428c90b
15
api/views.py
15
api/views.py
|
@ -2,12 +2,15 @@ import json
|
||||||
|
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
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 _
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from django_tables2 import SingleTableView
|
from django_tables2 import SingleTableView
|
||||||
|
from django.views.generic.base import View
|
||||||
from django.views.generic.edit import (
|
from django.views.generic.edit import (
|
||||||
CreateView,
|
CreateView,
|
||||||
DeleteView,
|
DeleteView,
|
||||||
|
@ -18,6 +21,7 @@ from utils.save_snapshots import move_json, save_in_disk
|
||||||
from dashboard.mixins import DashboardView
|
from dashboard.mixins import DashboardView
|
||||||
from evidence.models import Annotation
|
from evidence.models import Annotation
|
||||||
from evidence.parse import Build
|
from evidence.parse import Build
|
||||||
|
from user.models import User
|
||||||
from api.models import Token
|
from api.models import Token
|
||||||
from api.tables import TokensTable
|
from api.tables import TokensTable
|
||||||
|
|
||||||
|
@ -75,16 +79,17 @@ def NewSnapshot(request):
|
||||||
|
|
||||||
|
|
||||||
if not annotation:
|
if not annotation:
|
||||||
return JsonResponse({'status': 'fail'}, status=500)
|
return JsonResponse({'status': 'fail'}, status=200)
|
||||||
|
|
||||||
url_args = reverse_lazy("device:details", args=(annotation.value,))
|
|
||||||
url = request.build_absolute_uri(url_args)
|
|
||||||
|
|
||||||
|
url = "{}://{}{}".format(
|
||||||
|
request.scheme,
|
||||||
|
settings.DOMAIN,
|
||||||
|
reverse_lazy("device:details", args=(annotation.value,))
|
||||||
|
)
|
||||||
response = {
|
response = {
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"dhid": annotation.value[:6].upper(),
|
"dhid": annotation.value[:6].upper(),
|
||||||
"url": url,
|
"url": url,
|
||||||
# TODO replace with public_url when available
|
|
||||||
"public_url": url
|
"public_url": url
|
||||||
}
|
}
|
||||||
move_json(path_name, tk.owner.institution.name)
|
move_json(path_name, tk.owner.institution.name)
|
||||||
|
|
Loading…
Reference in a new issue