Merge pull request #3659 from FinnStutzenstein/agenda-autoupdates

Autoupdates for all children if the item type has changed (fixes #3636).
This commit is contained in:
Emanuel Schütze 2018-03-19 16:07:41 +01:00 committed by GitHub
commit 1dc4e5ef05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -17,6 +17,7 @@ Agenda:
- New DOCX export of agenda [#3569]. - New DOCX export of agenda [#3569].
- Hide closed agenda items in the item slide [#3567]. - Hide closed agenda items in the item slide [#3567].
- Agenda is now collapsable for a better overview [#3567]. - Agenda is now collapsable for a better overview [#3567].
- Autoupdates for all children if the item type has changed [#3659].
Motions: Motions:
- New export dialog [#3185]. - New export dialog [#3185].

View File

@ -58,6 +58,30 @@ class ItemViewSet(ListModelMixin, RetrieveModelMixin, UpdateModelMixin, GenericV
result = False result = False
return result 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']) @detail_route(methods=['POST', 'PATCH', 'DELETE'])
def manage_speaker(self, request, pk=None): def manage_speaker(self, request, pk=None):
""" """