Added server side sort view for agenda items. See #2452.
This commit is contained in:
parent
bcff33330c
commit
8c53b53a9d
@ -581,9 +581,7 @@ angular.module('OpenSlidesApp.agenda.site', [
|
|||||||
if (event.dest.nodesScope.item) {
|
if (event.dest.nodesScope.item) {
|
||||||
parentID = event.dest.nodesScope.item.id;
|
parentID = event.dest.nodesScope.item.id;
|
||||||
}
|
}
|
||||||
angular.forEach(event.dest.nodesScope.$modelValue, function(item, index) {
|
$http.post('/rest/agenda/item/sort/', {nodes: event.dest.nodesScope.$modelValue, parent_id: parentID});
|
||||||
$http.patch('/rest/agenda/item/' + item.id + '/', {parent_id: parentID, weight: index});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class ItemViewSet(ListModelMixin, RetrieveModelMixin, UpdateModelMixin, GenericV
|
|||||||
result = (has_perm(self.request.user, 'agenda.can_see') and
|
result = (has_perm(self.request.user, 'agenda.can_see') and
|
||||||
has_perm(self.request.user, 'agenda.can_see_hidden_items') and
|
has_perm(self.request.user, 'agenda.can_see_hidden_items') and
|
||||||
has_perm(self.request.user, 'agenda.can_manage'))
|
has_perm(self.request.user, 'agenda.can_manage'))
|
||||||
elif self.action in ('speak', 'sort_speakers', 'numbering'):
|
elif self.action in ('speak', 'sort_speakers', 'numbering', 'sort'):
|
||||||
result = (has_perm(self.request.user, 'agenda.can_see') and
|
result = (has_perm(self.request.user, 'agenda.can_see') and
|
||||||
has_perm(self.request.user, 'agenda.can_manage'))
|
has_perm(self.request.user, 'agenda.can_manage'))
|
||||||
else:
|
else:
|
||||||
@ -237,3 +237,21 @@ class ItemViewSet(ListModelMixin, RetrieveModelMixin, UpdateModelMixin, GenericV
|
|||||||
"""
|
"""
|
||||||
Item.objects.number_all(numeral_system=config['agenda_numeral_system'])
|
Item.objects.number_all(numeral_system=config['agenda_numeral_system'])
|
||||||
return Response({'detail': _('The agenda has been numbered.')})
|
return Response({'detail': _('The agenda has been numbered.')})
|
||||||
|
|
||||||
|
@list_route(methods=['post'])
|
||||||
|
def sort(self, request):
|
||||||
|
"""
|
||||||
|
Sort agenda items.
|
||||||
|
"""
|
||||||
|
nodes = request.data.get('nodes', [])
|
||||||
|
parent_id = request.data.get('parent_id')
|
||||||
|
items = []
|
||||||
|
with transaction.atomic():
|
||||||
|
for index, node in enumerate(nodes):
|
||||||
|
item = Item.objects.get(pk=node['id'])
|
||||||
|
item.parent_id = parent_id
|
||||||
|
item.weight = index
|
||||||
|
item.save(skip_autoupdate=True)
|
||||||
|
items.append(item)
|
||||||
|
inform_changed_data(items)
|
||||||
|
return Response({'detail': _('The agenda has been sorted.')})
|
||||||
|
Loading…
Reference in New Issue
Block a user