Skip to content
Snippets Groups Projects
Commit 5d7eb340 authored by Eva Bardou's avatar Eva Bardou
Browse files

Add tests

parent 4ecd0229
No related branches found
No related tags found
No related merge requests found
......@@ -1174,6 +1174,24 @@ class CorpusDeleteSelection(ElementsListMixin, SelectionMixin, DestroyAPIView):
"""
Delete selected elements on a corpus
"""
serializer_class = CorpusSerializer
openapi_overrides = {
'operationId': 'DeleteCorpusSelection',
'tags': ['elements']
}
def delete(self, request, *args, **kwargs):
rights = Corpus.objects.get(id=self.kwargs['pk']).get_acl_rights(request.user)
if Right.Admin not in rights:
self.permission_denied(request, message='You do not have admin access to delete elements on this corpus.')
selected_elements = self.get_selection(corpus_id=self.kwargs['pk'])
if not selected_elements.exists():
raise NotFound
for batch in range(0, selected_elements.count(), 50):
queryset = Element.objects.filter(id__in=list(selected_elements[batch:batch + 50].values_list('id', flat=True)))
element_trash(queryset, user_id=self.request.user.id)
def get_queryset(self):
# Should not be possible due to the URL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment