Skip to content

Commit 9fd3c49

Browse files
committed
45586 refactor(queryset): Rename permission queryset method to explicitly include OWNER role
1 parent 96c2604 commit 9fd3c49

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

backend/src/processes/permissions.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def has_permission(self, request, view):
171171
pk=workflow_id,
172172
account_id=request.user.account_id,
173173
)
174-
.with_viewer_or_started_by_starter(request.user.id)
174+
.with_owner_viewer_or_started_by_starter(request.user.id)
175175
.exists()
176176
)
177177

@@ -362,7 +362,7 @@ def has_permission(self, request, view):
362362
tasks__id=task_id,
363363
account_id=request.user.account_id,
364364
)
365-
.with_viewer_or_started_by_starter(request.user.id)
365+
.with_owner_viewer_or_started_by_starter(request.user.id)
366366
.exists()
367367
)
368368

@@ -406,7 +406,11 @@ def has_permission(self, request, view):
406406
return True
407407

408408
# Check template owner, viewer or starter who started workflow
409-
return base_qst.with_viewer_or_started_by_starter(user_id).exists()
409+
return (
410+
base_qst
411+
.with_owner_viewer_or_started_by_starter(user_id)
412+
.exists()
413+
)
410414

411415

412416
class WorkflowCommentPermission(BasePermission):
@@ -445,7 +449,11 @@ def has_permission(self, request, view):
445449
return True
446450

447451
# Check template owner, viewer or starter who started workflow
448-
return base_qst.with_viewer_or_started_by_starter(user_id).exists()
452+
return (
453+
base_qst
454+
.with_owner_viewer_or_started_by_starter(user_id)
455+
.exists()
456+
)
449457

450458

451459
class GuestWorkflowPermission(BasePermission):
@@ -622,7 +630,7 @@ def has_permission(self, request, view):
622630
Workflow.objects
623631
.by_id(workflow_id)
624632
.on_account(user.account_id)
625-
.with_viewer_or_started_by_starter(user.id)
633+
.with_owner_viewer_or_started_by_starter(user.id)
626634
.exists()
627635
)
628636

backend/src/processes/querysets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def with_template_access(self, user_id: int):
448448
),
449449
).distinct()
450450

451-
def with_viewer_or_started_by_starter(self, user_id: int):
451+
def with_owner_viewer_or_started_by_starter(self, user_id: int):
452452
base_owner_q = Q(template__owners__is_deleted=False) & (
453453
Q(
454454
template__owners__type=OwnerType.USER,

0 commit comments

Comments
 (0)