Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
internewshid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aptivate
client-projects
internewshid
Commits
7157bcca
Commit
7157bcca
authored
9 years ago
by
Martin Burchell
Browse files
Options
Downloads
Patches
Plain Diff
Return 400 instead when taxonomy absent
parent
3e32cbc5
No related branches found
Branches containing commit
No related tags found
1 merge request
!31
Uncategorise
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
django/website/rest_api/tests/delete_all_terms_tests.py
+2
-2
2 additions, 2 deletions
django/website/rest_api/tests/delete_all_terms_tests.py
django/website/rest_api/views.py
+6
-2
6 additions, 2 deletions
django/website/rest_api/views.py
with
8 additions
and
4 deletions
django/website/rest_api/tests/delete_all_terms_tests.py
+
2
−
2
View file @
7157bcca
...
...
@@ -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_40
4_NOT_FOUND
assert
response
.
data
[
'
detail
'
]
==
"
Taxonomy
matching query
does not exist.
"
assert
response
.
status_code
==
status
.
HTTP_40
0_BAD_REQUEST
assert
response
.
data
[
'
detail
'
]
==
"
Taxonomy
with slug
'
provinces-of-liberia
'
does not exist.
"
This diff is collapsed.
Click to expand it.
django/website/rest_api/views.py
+
6
−
2
View file @
7157bcca
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment