summaryrefslogtreecommitdiff
path: root/patchwork/urls.py
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2016-06-16 16:13:17 -0500
committerStephen Finucane <stephen.finucane@intel.com>2016-06-27 18:19:08 +0100
commit92b6e6a39595841782b967e34e9b3bdebefbf1ec (patch)
tree3846790c3aea7cf5f8c7e093cfd6c1942fa353af /patchwork/urls.py
parent6f283ef361bd58120a527b917a18d4207053f348 (diff)
downloadpatchwork-92b6e6a39595841782b967e34e9b3bdebefbf1ec.tar
patchwork-92b6e6a39595841782b967e34e9b3bdebefbf1ec.tar.gz
REST: Add base configuration hooks for a REST API
This adds the ability to expose a REST API based on the Django REST framework project. Since this project isn't packaged in most current distributions, we ensure that its both installed and enabled before trying to use it. Signed-off-by: Andy Doan <andy.doan@linaro.org> Inspired-by: Damien Lespiau <damien.lespiau@intel.com> Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
Diffstat (limited to 'patchwork/urls.py')
-rw-r--r--patchwork/urls.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/patchwork/urls.py b/patchwork/urls.py
index f664501..2318ab9 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -143,6 +143,15 @@ if settings.ENABLE_XMLRPC:
name='pwclientrc'),
]
+if settings.ENABLE_REST_API:
+ if 'rest_framework' not in settings.INSTALLED_APPS:
+ raise RuntimeError(
+ 'djangorestframework must be installed to enable the REST API.')
+ import patchwork.views.rest_api
+ urlpatterns += [
+ url(r'^api/1.0/', include(patchwork.views.rest_api.router.urls)),
+ ]
+
# redirect from old urls
if settings.COMPAT_REDIR:
urlpatterns += [