Permalink
Browse files

Ported the root api view.

  • Loading branch information...
1 parent 2c1dce3 commit aedb89543d598bb55fff88b069538f35606b8868 @markotibold markotibold committed Nov 12, 2012
Showing with 17 additions and 24 deletions.
  1. +3 −9 fiber/rest_api/urls.py
  2. +14 −15 fiber/rest_api/views.py
View
@@ -5,19 +5,13 @@
from django.conf.urls.defaults import patterns, url
-from fiber.app_settings import PERMISSION_CLASS
-from fiber.utils import class_loader
+from .views import MovePageView, MovePageContentItemView, TreeListView
-
-from .views import ApiRoot, MovePageView, MovePageContentItemView, TreeListView
-
-PERMISSIONS = class_loader.load_class(PERMISSION_CLASS)
-
-from .views import PageList, PageDetail, PageContentItemList, PageContentItemDetail, ContentItemList, ContentItemDetail, ImageList, ImageDetail, FileList, FileDetail
+from .views import api_root, PageList, PageDetail, PageContentItemList, PageContentItemDetail, ContentItemList, ContentItemDetail, ImageList, ImageDetail, FileList, FileDetail
urlpatterns = patterns('',
- (r'^$', ApiRoot.as_view()),
+ (r'^$', api_root),
url(r'^pages/$', PageList.as_view(), name='page-list'),
url(r'^pages/(?P<pk>[^/]+)/$', PageDetail.as_view(), name='page-detail'),
url(r'^pages/(?P<pk>[^/]+)/move_page/$', MovePageView.as_view(), name='page-resource-instance-move'),
View
@@ -1,5 +1,4 @@
from django.db.models import Q
-from django.core.urlresolvers import reverse
from djangorestframework.views import View
from djangorestframework.permissions import IsAdminUser
@@ -27,6 +26,10 @@
from rest_framework import generics, renderers
+from rest_framework.decorators import api_view
+from rest_framework.response import Response
+from rest_framework.reverse import reverse
+
from .serializers import PageSerializer, PageContentItemSerializer, ContentItemSerializer, FileSerializer, ImageSerializer
@@ -90,22 +93,18 @@ class ImageDetail(generics.RetrieveUpdateDestroyAPIView):
renderer_classes = (renderers.JSONRenderer, )
-class ApiRoot(View):
+@api_view(('GET',))
+def api_root(request, format='None'):
"""
- The root view for the rest api.
+ This is the entry point for the API.
"""
-
- permissions = (IsAdminUser, )
- renderers = API_RENDERERS
-
- def get(self, request):
- return [
- {'name': 'pages', 'url': reverse('page-resource-root')},
- {'name': 'page content items', 'url': reverse('page-content-item-resource-root')},
- {'name': 'content items', 'url': reverse('content-item-resource-root')},
- {'name': 'images', 'url': reverse('image-resource-root')},
- {'name': 'files', 'url': reverse('file-resource-root')},
- ]
+ return Response({
+ 'pages': reverse('page-list', request=request),
+ 'page content items': reverse('pagecontentitem-list', request=request),
+ 'content items': reverse('contentitem-list', request=request),
+ 'images': reverse('image-list', request=request),
+ 'files': reverse('file-list', request=request),
+ })
class ListView(ListOrCreateModelView):

0 comments on commit aedb895

Please sign in to comment.