From fd4d59c4e19796f9f3229c10c5000c6188be5116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 9 Jun 2020 18:51:42 +0300 Subject: [PATCH] API, optimization: avoid retrieving project twice from the database --- hc/api/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hc/api/views.py b/hc/api/views.py index d18b8aff..f174f989 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -186,7 +186,7 @@ def channels(request): @authorize_read def get_check(request, code): check = get_object_or_404(Check, code=code) - if check.project != request.project: + if check.project_id != request.project.id: return HttpResponseForbidden() return JsonResponse(check.to_dict(readonly=request.readonly)) @@ -196,7 +196,7 @@ def get_check(request, code): @authorize def update_check(request, code): check = get_object_or_404(Check, code=code) - if check.project != request.project: + if check.project_id != request.project.id: return HttpResponseForbidden() try: @@ -211,7 +211,7 @@ def update_check(request, code): @authorize def delete_check(request, code): check = get_object_or_404(Check, code=code) - if check.project != request.project: + if check.project_id != request.project.id: return HttpResponseForbidden() response = check.to_dict() @@ -237,7 +237,7 @@ def single(request, code): @authorize def pause(request, code): check = get_object_or_404(Check, code=code) - if check.project != request.project: + if check.project_id != request.project.id: return HttpResponseForbidden() check.status = "paused"