diff --git a/CHANGELOG b/CHANGELOG index 94e049409..4a5f3fabb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ Agenda: - New DOCX export of agenda [#3569]. - Hide closed agenda items in the item slide [#3567]. - Agenda is now collapsable for a better overview [#3567]. +- Autoupdates for all children if the item type has changed [#3659]. Motions: - New export dialog [#3185]. diff --git a/openslides/agenda/views.py b/openslides/agenda/views.py index 3f4fb9a24..b9159f678 100644 --- a/openslides/agenda/views.py +++ b/openslides/agenda/views.py @@ -58,6 +58,30 @@ class ItemViewSet(ListModelMixin, RetrieveModelMixin, UpdateModelMixin, GenericV result = False return result + def update(self, *args, **kwargs): + """ + Customized view endpoint to update all children if, the item type has changed. + """ + hidden = self.get_object().type == Item.HIDDEN_ITEM + + result = super().update(*args, **kwargs) + + # update all children, if the item type has changed + item = self.get_object() + if hidden != (item.type == Item.HIDDEN_ITEM): + items_to_update = [] + + # rekursively add children to items_to_update + def add_item(item): + items_to_update.append(item) + for child in item.children.all(): + add_item(child) + + add_item(item) + inform_changed_data(items_to_update) + + return result + @detail_route(methods=['POST', 'PATCH', 'DELETE']) def manage_speaker(self, request, pk=None): """