Skip to content
Snippets Groups Projects
Commit e21ab933 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Ensure all elements exist before adding to the selection

parent 3563cf6e
No related branches found
No related tags found
1 merge request!685Ensure all elements exist before adding to the selection
......@@ -557,7 +557,7 @@ class ManageSelection(ListAPIView):
elements = Element.objects.filter(id__in=request.data['ids']) \
.prefetch_related('corpus', 'zone__image__server', 'type')
if not elements:
if elements.count() != len(set(request.data['ids'])):
return Response(status=status.HTTP_404_NOT_FOUND)
for corpus in Corpus.objects.filter(elements__in=elements).distinct():
if Right.Read not in corpus.get_acl_rights(request.user):
......
......@@ -42,7 +42,7 @@ class TestElementsAPI(FixtureAPITestCase):
self.client.force_login(self.user)
response = self.client.post(
reverse('api:elements-selection'),
data={'ids': ['ffffffff-ffff-ffff-ffff-ffffffffffff']},
data={'ids': [self.vol.id, 'ffffffff-ffff-ffff-ffff-ffffffffffff']},
format='json'
)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
......
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