Skip to content

Commit c85f977

Browse files
annehaleybrianhelba
andcommitted
fix: Use get_object_or_404
Co-authored-by: Brian Helba <brian.helba@kitware.com>
1 parent 7fd34ce commit c85f977

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

uvdat/core/rest/analytics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44

55
from django.db.models import QuerySet
6+
from django.shortcuts import get_object_or_404
67
from rest_framework.decorators import action
78
from rest_framework.response import Response
89
from rest_framework.serializers import ModelSerializer
@@ -117,7 +118,7 @@ def run(self, request, project_id: int, task_type: str, **kwargs):
117118
url_path=r"(?P<result_id>[\d*]+)/subscribe",
118119
)
119120
def subscribe(self, request, result_id, **kwargs):
120-
task_result = TaskResult.objects.get(id=result_id)
121+
task_result = get_object_or_404(TaskResult, id=result_id)
121122
if task_result.completed:
122123
return Response("Task already completed. Subscription not applied.", status=410)
123124
task_result.subscribers.add(request.user)

0 commit comments

Comments
 (0)