]> git.ipfire.org Git - thirdparty/patchwork.git/commit
REST: Use generic views instead of ViewSets
authorStephen Finucane <stephen@that.guru>
Thu, 24 Nov 2016 12:55:42 +0000 (12:55 +0000)
committerStephen Finucane <stephen@that.guru>
Fri, 23 Dec 2016 23:41:29 +0000 (23:41 +0000)
commit3e8048fc1aef396301083d1141d82de55e423418
tree736080c85b32d4c9d45b63d144b387bd1a5a335a
parentdc787e93a771addddf0f6ceff5d853240d217f2b
REST: Use generic views instead of ViewSets

ViewSet provide an easy way to define an API, but they don't offer much
flexibility. To get them to work as expected, a lot of hacks were
required. Generic views provide a more verbose, but ultimately easier to
understand, version. Using generic views lets us remove the dependency
of drf-nested-routers, bringing us back down to two main dependencies.
It also lets us remove the AuthenticatedReadOnly permission class, as
the DRF provides a similar permission class that can be used with
generic views.

The main user facing change is that invalid methods, such as POST on an
endpoint that doesn't allow object creation, will now return a HTTP 405
(Method Not Allowed) error code rather than the HTTP 403 (Forbidden)
error code previously returned. This is the semantically correct option
and should have been used all along.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
13 files changed:
patchwork/api/base.py
patchwork/api/check.py
patchwork/api/index.py [new file with mode: 0644]
patchwork/api/patch.py
patchwork/api/person.py
patchwork/api/project.py
patchwork/api/user.py
patchwork/settings/base.py
patchwork/tests/test_rest_api.py
patchwork/urls.py
requirements-dev.txt
requirements-prod.txt
tox.ini