diff --git a/openslides/agenda/static/js/agenda/agenda.js b/openslides/agenda/static/js/agenda/agenda.js index 217e3c6da..e0267da5b 100644 --- a/openslides/agenda/static/js/agenda/agenda.js +++ b/openslides/agenda/static/js/agenda/agenda.js @@ -394,7 +394,7 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) // set changed agenda tree $scope.treeOptions = { dropped: function() { - $http.put('/rest/agenda/item/tree/', {tree: $scope.tree}); + $http.put('/rest/agenda/item/tree/', {tree: $scope.items}); } }; } diff --git a/openslides/agenda/views.py b/openslides/agenda/views.py index 2d1a526da..562b8542d 100644 --- a/openslides/agenda/views.py +++ b/openslides/agenda/views.py @@ -200,12 +200,20 @@ class ItemViewSet(ModelViewSet): request.user.has_perm('agenda.can_see_orga_items')): self.permission_denied(request) try: - Item.objects.set_tree(request.data['tree']) - except ValueError as error: - return Response({'detail': str(error)}, status=400) + tree = request.data['tree'] + except KeyError as error: + response = Response({'detail': 'Agenda tree is missing.'}, status=400) else: - return Response({'detail': 'Agenda tree successfully updated.'}) - return Response(Item.objects.get_tree()) + try: + Item.objects.set_tree(tree) + except ValueError as error: + response = Response({'detail': str(error)}, status=400) + else: + response = Response({'detail': 'Agenda tree successfully updated.'}) + else: + # request.method == 'GET' + response = Response(Item.objects.get_tree()) + return response # Views to generate PDFs