Autoupdates for all children if the item type has changed (fixes #3636).
This commit is contained in:
parent
09e74481cb
commit
05d740b190
@ -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].
|
||||
|
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user