Permalink
Browse files

Port PageTree.

  • Loading branch information...
1 parent aedb895 commit 63fb5d0cf4b91ac1eeeaa616d9e9bf4857cfe0a6 @markotibold markotibold committed Nov 12, 2012
Showing with 20 additions and 35 deletions.
  1. +15 −18 fiber/rest_api/urls.py
  2. +5 −17 fiber/rest_api/views.py
View
33 fiber/rest_api/urls.py
@@ -5,24 +5,21 @@
from django.conf.urls.defaults import patterns, url
-from .views import MovePageView, MovePageContentItemView, TreeListView
-
-from .views import api_root, PageList, PageDetail, PageContentItemList, PageContentItemDetail, ContentItemList, ContentItemDetail, ImageList, ImageDetail, FileList, FileDetail
-
+from . import views
urlpatterns = patterns('',
- (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'),
- url(r'^pagetree/$', TreeListView.as_view(), name='pagetree-resource'),
- url(r'^page_content_items/$', PageContentItemList.as_view(), name='pagecontentitem-list'),
- url(r'^page_content_items/(?P<pk>[^/]+)/$', PageContentItemDetail.as_view(), name='pagecontentitem-detail'),
- url(r'^page_content_items/(?P<pk>[^/]+)/move/$', MovePageContentItemView.as_view(), name='page-content-item-resource-instance-move'),
- url(r'^content_items/$', ContentItemList.as_view(), name='contentitem-list'),
- url(r'^content_items/(?P<pk>[^/]+)/$', ContentItemDetail.as_view(), name='contentitem-detail'),
- url(r'^images/$', ImageList.as_view(), name='image-list'),
- url(r'^images/(?P<pk>[^/]+)/$', ImageDetail.as_view(), name='image-detail'),
- url(r'^files/$', FileList.as_view(), name='file-list'),
- url(r'^files/(?P<pk>[^/]+)/$', FileDetail.as_view(), name='file-detail'),
+ (r'^$', views.api_root),
+ url(r'^pages/$', views.PageList.as_view(), name='page-list'),
+ url(r'^pages/(?P<pk>[^/]+)/$', views.PageDetail.as_view(), name='page-detail'),
+ url(r'^pages/(?P<pk>[^/]+)/move_page/$', views.MovePageView.as_view(), name='page-resource-instance-move'),
+ url(r'^pagetree/$', views.PageTree.as_view(), name='pagetree'),
+ url(r'^page_content_items/$', views.PageContentItemList.as_view(), name='pagecontentitem-list'),
+ url(r'^page_content_items/(?P<pk>[^/]+)/$', views.PageContentItemDetail.as_view(), name='pagecontentitem-detail'),
+ url(r'^page_content_items/(?P<pk>[^/]+)/move/$', views.MovePageContentItemView.as_view(), name='page-content-item-resource-instance-move'),
+ url(r'^content_items/$', views.ContentItemList.as_view(), name='contentitem-list'),
+ url(r'^content_items/(?P<pk>[^/]+)/$', views.ContentItemDetail.as_view(), name='contentitem-detail'),
+ url(r'^images/$', views.ImageList.as_view(), name='image-list'),
+ url(r'^images/(?P<pk>[^/]+)/$', views.ImageDetail.as_view(), name='image-detail'),
+ url(r'^files/$', views.FileList.as_view(), name='file-list'),
+ url(r'^files/(?P<pk>[^/]+)/$', views.FileDetail.as_view(), name='file-detail'),
)
View
22 fiber/rest_api/views.py
@@ -29,6 +29,7 @@
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework.reverse import reverse
+from rest_framework import views
from .serializers import PageSerializer, PageContentItemSerializer, ContentItemSerializer, FileSerializer, ImageSerializer
@@ -100,6 +101,7 @@ def api_root(request, format='None'):
"""
return Response({
'pages': reverse('page-list', request=request),
+ 'pagetree': reverse('pagetree', request=request),
'page content items': reverse('pagecontentitem-list', request=request),
'content items': reverse('contentitem-list', request=request),
'images': reverse('image-list', request=request),
@@ -121,16 +123,13 @@ def post(self, request, *args, **kwargs):
return response
-class TreeListView(View):
+class PageTree(views.APIView):
- permissions = (IsAdminUser, )
- renderers = API_RENDERERS
-
- def get(self, request):
+ def get(self, request, format=None):
"""
Provide jqTree data for the PageSelect dialog.
"""
- return Page.objects.create_jqtree_data(request.user)
+ return Response(Page.objects.create_jqtree_data(request.user))
class PaginatedListView(PaginatorMixin, ListView):
@@ -211,17 +210,6 @@ def get_queryset(self, *args, **kwargs):
return qs
-class InstanceView(InstanceModelView):
-
- permissions = (IsAdminUser, )
- renderers = API_RENDERERS
-
- def delete(self, request, pk):
- if not PERMISSIONS.can_edit(self.request.user, self.resource.model.objects.get(id=pk)):
- raise _403_FORBIDDEN_RESPONSE
- super(InstanceView, self).delete(request, id=pk)
-
-
class MovePageView(View):
permissions = (IsAdminUser, )

0 comments on commit 63fb5d0

Please sign in to comment.