From 7ed5d2fc43740a5796716caaca83896b5f0ae958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sat, 11 Oct 2014 14:15:42 +0200 Subject: [PATCH] Setup Django REST Framework. --- openslides/global_settings.py | 1 + openslides/urls.py | 8 ++++++++ openslides/utils/rest_api.py | 3 +++ requirements_production.txt | 1 + 4 files changed, 13 insertions(+) create mode 100644 openslides/utils/rest_api.py diff --git a/openslides/global_settings.py b/openslides/global_settings.py index 1c1141e05..ff00236aa 100644 --- a/openslides/global_settings.py +++ b/openslides/global_settings.py @@ -88,6 +88,7 @@ INSTALLED_APPS = ( 'mptt', 'haystack', # full-text-search 'ckeditor', + 'rest_framework', 'openslides.poll', 'openslides.core', 'openslides.account', diff --git a/openslides/urls.py b/openslides/urls.py index 774e2ba0c..31191e2ae 100644 --- a/openslides/urls.py +++ b/openslides/urls.py @@ -3,6 +3,7 @@ from django.conf.urls import include, patterns, url from openslides.core.views import ErrorView from openslides.utils.plugins import get_urlpatterns +from openslides.utils.rest_api import router handler403 = ErrorView.as_view(status_code=403) handler404 = ErrorView.as_view(status_code=404) @@ -31,6 +32,13 @@ urlpatterns += patterns( (r'^ckeditor/', include('ckeditor.urls')), ) +urlpatterns += patterns( + '', + url(r'^api/', include(router.urls)), + # TODO: Remove the next line if you are sure. + # url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) +) + # TODO: move this patterns into core or the participant app from openslides.users.views import UserSettingsView, UserPasswordSettingsView urlpatterns += patterns( diff --git a/openslides/utils/rest_api.py b/openslides/utils/rest_api.py new file mode 100644 index 000000000..5fec051f5 --- /dev/null +++ b/openslides/utils/rest_api.py @@ -0,0 +1,3 @@ +from rest_framework import permissions, routers, viewsets + +router = routers.DefaultRouter() diff --git a/requirements_production.txt b/requirements_production.txt index d129cec6f..532cf54f8 100644 --- a/requirements_production.txt +++ b/requirements_production.txt @@ -5,6 +5,7 @@ bleach>=1.4,<1.5 django-ckeditor-updated>=4.2.3,<4.4 django-haystack>=2.1,<2.4 django-mptt>=0.6,<0.7 +djangorestframework>=3.0.1,<3.1 jsonfield>=0.9.19,<1.1 natsort>=3.2,<3.6 reportlab>=3.0,<3.2