Skip to content

Commit 9c89061

Browse files
Raxel Gutierrezdaxtens
authored andcommitted
models: change edit permissions for comments
Change patch comments' edit permissions to match that of the patch associated with the comment (i.e. patch author, project maintainers, and delegate) and add permissions for both patch and cover comment authors to be able to change the `addressed` status of comments as well. For cover comments, add permissions to edit for cover submitter and project maintainers. Signed-off-by: Raxel Gutierrez <raxel@google.com> Signed-off-by: Daniel Axtens <dja@axtens.net>
1 parent eade9c5 commit 9c89061

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

patchwork/models.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,20 @@ def get_absolute_url(self):
675675
return reverse('comment-redirect', kwargs={'comment_id': self.id})
676676

677677
def is_editable(self, user):
678+
if not user.is_authenticated:
679+
return False
680+
681+
# user submitted comment
682+
if user == self.submitter.user:
683+
return True
684+
685+
# user submitted cover letter
686+
if user == self.cover.submitter.user:
687+
return True
688+
689+
# user is project maintainer
690+
if self.cover.project.is_editable(user):
691+
return True
678692
return False
679693

680694
class Meta:
@@ -720,7 +734,9 @@ def delete(self, *args, **kwargs):
720734
self.patch.refresh_tag_counts()
721735

722736
def is_editable(self, user):
723-
return False
737+
if user == self.submitter.user:
738+
return True
739+
return self.patch.is_editable(user)
724740

725741
class Meta:
726742
ordering = ['date']

0 commit comments

Comments
 (0)