0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Allow users to modify contentpath of other user's comments when moving between blocks

This commit is contained in:
jacobtoppm 2022-04-08 17:05:47 +01:00 committed by Matt Westcott
parent 7787abad2f
commit 646203a516

View File

@ -49,12 +49,16 @@ class CommentForm(WagtailAdminModelForm):
self.instance.user = user
elif self.instance.user != user:
# trying to edit someone else's comment
if any(
field
for field in self.changed_data
if field not in ["resolved", "position"]
if (
any(
field
for field in self.changed_data
if field not in ["resolved", "position", "contentpath"]
)
or cleaned_data["contentpath"].split(".")[0]
!= self.instance.contentpath.split(".")[0]
):
# users can resolve each other's base comments and change their positions within a field
# users can resolve each other's base comments and change their positions within a field, or move a comment between blocks in a StreamField
self.add_error(
None, ValidationError(_("You cannot edit another user's comment."))
)