Skip to content

Commit 43b36a5

Browse files
adliusopaduchak
andauthored
[ENG-9556] implemented removal of contributors from all children of node (#11513)
Co-authored-by: Oleh Paduchak <opaduchak@exoft.net>
1 parent 7ebd91a commit 43b36a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/nodes/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,17 @@ def get_serializer_context(self):
545545
return context
546546

547547
def perform_destroy(self, instance):
548-
node = self.get_resource()
548+
node: Node = self.get_resource()
549549
auth = get_user_auth(self.request)
550550
if node.visible_contributors.count() == 1 and instance.visible:
551551
raise ValidationError('Must have at least one visible contributor')
552552
removed = node.remove_contributor(instance, auth)
553553
if not removed:
554554
raise ValidationError('Must have at least one registered admin contributor')
555+
propagate = self.request.query_params.get('propagate_to_children') == 'true'
556+
if propagate:
557+
for child_node in node.get_nodes(_contributors__in=[instance.user]):
558+
child_node.remove_contributor(instance, auth)
555559

556560

557561
class NodeImplicitContributorsList(JSONAPIBaseView, generics.ListAPIView, ListFilterMixin, NodeMixin):

0 commit comments

Comments
 (0)