allow WFJT admins to cancel scheduled jobs

This commit is contained in:
AlanCoding 2017-10-02 10:25:49 -04:00
parent ca4a1f37cd
commit 681770e25a
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B
2 changed files with 8 additions and 1 deletions

View File

@ -1841,7 +1841,9 @@ class WorkflowJobAccess(BaseAccess):
def can_cancel(self, obj):
if not obj.can_cancel:
return False
return self.can_delete(obj) or self.user == obj.created_by
if self.user == obj.created_by or self.can_delete(obj):
return True
return obj.workflow_job_template is not None and self.user in obj.workflow_job_template.admin_role
class AdHocCommandAccess(BaseAccess):

View File

@ -104,6 +104,11 @@ class TestWorkflowJobAccess:
access = WorkflowJobAccess(rando)
assert access.can_cancel(workflow_job)
def test_admin_cancel_access(self, wfjt, workflow_job, rando):
wfjt.admin_role.members.add(rando)
access = WorkflowJobAccess(rando)
assert access.can_cancel(workflow_job)
@pytest.mark.django_db
class TestWFJTCopyAccess: