Skip to content

Commit

Permalink
allow anonymous uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Dec 2, 2024
1 parent 2f0412a commit f94ae8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 11 additions & 3 deletions application/src/tira_app/endpoints/v1/_anonymous.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json

from django.http import HttpResponseServerError
from django.urls import path
from rest_framework.decorators import api_view
from rest_framework.request import Request
Expand All @@ -17,9 +20,14 @@ def read_anonymous_submission(request: Request, submission_uuid: str) -> Respons
Returns:
Response: The information about the anonymous submission
"""
ret = modeldb.AnonymousUploads.objects.get(uuid=submission_uuid)

return Response({"uuid": ret.uuid, "dataset_id": ret.dataset.dataset_id, "created": ret.created})
try:
ret = modeldb.AnonymousUploads.objects.get(uuid=submission_uuid)

return Response({"uuid": ret.uuid, "dataset_id": ret.dataset.dataset_id, "created": ret.created})
except:
return HttpResponseServerError(
json.dumps({"status": 1, "message": f"Run with uuid {submission_uuid} does not exist."})
)


endpoints = [
Expand Down
2 changes: 1 addition & 1 deletion application/src/tira_app/endpoints/vm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def anonymous_upload(request, dataset_id):
status_code, message = check_format(result_dir / "extracted", dataset["format"][0])

if status_code != _fmt.OK:
JsonResponse({"status": 1, "message": message}, status_code=500)
HttpResponseServerError(json.dumps({"status": 1, "message": message}))
from .. import model as modeldb

(Path(settings.TIRA_ROOT) / "data" / "anonymous-uploads").mkdir(exist_ok=True, parents=True)
Expand Down
10 changes: 5 additions & 5 deletions application/test/api_access_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2085,11 +2085,11 @@
url_pattern="v1/anonymous/<str:submission_uuid>",
params={"submission_uuid": "12345"},
group_to_expected_status_code={
GUEST: 200,
PARTICIPANT: 200,
ORGANIZER_WRONG_TASK: 200,
ORGANIZER: 200,
ADMIN: 200,
GUEST: 500,
PARTICIPANT: 500,
ORGANIZER_WRONG_TASK: 500,
ORGANIZER: 500,
ADMIN: 500,
},
),
route_to_test(
Expand Down

0 comments on commit f94ae8c

Please sign in to comment.