Skip to content

Commit 26f44c6

Browse files
committed
add a per-project rule to change CI checks
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 57033b1 commit 26f44c6

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎patchwork/api/check.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class CheckListCreate(CheckMixin, ListCreateAPIView):
108108
lookup_url_kwarg = 'patch_id'
109109
ordering = 'id'
110110

111-
def is_editable(self, user):
111+
def is_editable(self, user, patch):
112112
if not user.is_authenticated:
113113
return False
114114

@@ -119,12 +119,16 @@ def is_editable(self, user):
119119
patch._edited_by = user
120120
return True
121121

122+
if user.has_perm('patchwork.add_check', patch.project):
123+
patch._edited_by = user
124+
return True
125+
122126
# Being maintainer doesn't grant rights to create checks.
123127
return False
124128

125129
def create(self, request, patch_id, *args, **kwargs):
126130
p = get_object_or_404(Patch, id=patch_id)
127-
if not self.is_editable(request.user):
131+
if not self.is_editable(request.user, p):
128132
raise PermissionDenied()
129133
request.patch = p
130134
return super(CheckListCreate, self).create(request, *args, **kwargs)

‎patchwork/models.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ class Meta:
121121
default_permissions = ()
122122
unique_together = (('listid', 'subject_match'),)
123123
ordering = ['linkname']
124+
permissions = [
125+
# Per-project permission to add checks
126+
("add_check", "Can add checks"),
127+
]
124128

125129

126130
class DelegationRule(models.Model):

0 commit comments

Comments
 (0)