Skip to content
Snippets Groups Projects
Commit 7157bcca authored by Martin Burchell's avatar Martin Burchell
Browse files

Return 400 instead when taxonomy absent

parent 3e32cbc5
No related branches found
No related tags found
1 merge request!31Uncategorise
......@@ -60,5 +60,5 @@ def test_error_when_taxonomy_does_not_exist(item, term):
categorize_item(item, term)
response = remove_categories_from_item(item, 'provinces-of-liberia')
assert response.status_code == status.HTTP_404_NOT_FOUND
assert response.data['detail'] == "Taxonomy matching query does not exist."
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.data['detail'] == "Taxonomy with slug 'provinces-of-liberia' does not exist."
......@@ -104,8 +104,12 @@ class ItemViewSet(viewsets.ModelViewSet, BulkDestroyModelMixin):
try:
taxonomy = Taxonomy.objects.get(slug=taxonomy_slug)
except Taxonomy.DoesNotExist as e:
data = {'detail': e.message}
return Response(data, status=status.HTTP_404_NOT_FOUND)
message = _("Taxonomy with slug '%s' does not exist.") % (
taxonomy_slug,
)
data = {'detail': message}
return Response(data, status=status.HTTP_400_BAD_REQUEST)
item.delete_all_terms(taxonomy)
......
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