Skip to content

Commit eed4b39

Browse files
committed
Use standard DRF status codes
1 parent a1b275f commit eed4b39

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

readthedocs/api/v3/views.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import django_filters.rest_framework as filters
22
from django.utils.safestring import mark_safe
33
from rest_flex_fields.views import FlexFieldsMixin
4+
from rest_framework import status
45
from rest_framework.authentication import TokenAuthentication
56
from rest_framework.decorators import action
67
from rest_framework.metadata import SimpleMetadata
@@ -170,7 +171,7 @@ def superproject(self, request, project_slug):
170171
data = self.get_serializer(superproject).data
171172
return Response(data)
172173
except Exception:
173-
return Response(status=404)
174+
return Response(status=status.HTTP_404_NOT_FOUND)
174175

175176

176177
class SubprojectRelationshipViewSet(APIv3Settings, NestedViewSetMixin,
@@ -259,7 +260,7 @@ def update(self, request, *args, **kwargs):
259260
# ``httpOnly`` on our cookies and the ``PUT/PATCH`` method are triggered
260261
# via Javascript
261262
super().update(request, *args, **kwargs)
262-
return Response(status=204)
263+
return Response(status=status.HTTP_204_NO_CONTENT)
263264

264265

265266
class BuildsViewSet(APIv3Settings, NestedViewSetMixin, ProjectQuerySetMixin,
@@ -299,8 +300,8 @@ def create(self, request, **kwargs): # pylint: disable=arguments-differ
299300

300301
if build:
301302
data.update({'triggered': True})
302-
status = 202
303+
code = status.HTTP_202_ACCEPTED
303304
else:
304305
data.update({'triggered': False})
305-
status = 400
306-
return Response(data=data, status=status)
306+
code = status.HTTP_400_BAD_REQUEST
307+
return Response(data=data, status=code)

0 commit comments

Comments
 (0)