Skip to content

Commit

Permalink
Fix patch for user->user change status v1
Browse files Browse the repository at this point in the history
  • Loading branch information
greenpandorik committed Feb 5, 2024
1 parent e424b2e commit 45aa0da
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions api/v1/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from django.shortcuts import get_object_or_404
from rest_framework import permissions

from tasks.models import Task

User = get_user_model()


Expand All @@ -23,10 +25,11 @@ def has_permission(self, request, view):
def has_object_permission(self, request, view, obj):
if request.user == obj.creator:
return True
if (
request.method == "PATCH"
and "status" in request.data
and request.data["status"] == "complete"
):
return request.user == obj.executor
if isinstance(obj, Task):
if (
request.method == "PATCH"
and "status" in request.data
and request.data["status"] == "complete"
):
return request.user == obj.executor
return False

0 comments on commit 45aa0da

Please sign in to comment.