Update the app API class methods, register the sources app main endpoint, add API doc strings
This commit is contained in:
@@ -6,10 +6,8 @@ from common.utils import encapsulate
|
||||
from documents.models import Document
|
||||
from navigation.api import register_links, register_model_list_columns
|
||||
from project_setup.api import register_setup
|
||||
from rest_api.classes import EndPoint
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
from .api import (APIStagingSourceListView, APIStagingSourceView,
|
||||
APIStagingSourceFileView, APIStagingSourceFileImageView)
|
||||
from .classes import StagingFile
|
||||
from .links import (document_create_multiple, document_create_siblings,
|
||||
staging_file_delete, setup_sources, setup_web_form_list,
|
||||
@@ -58,5 +56,6 @@ register_setup(setup_sources)
|
||||
register_links([Document, 'document_list_recent', 'document_list', 'document_create', 'document_create_multiple', 'upload_interactive', 'staging_file_delete'], [document_create_multiple], menu_name='secondary_menu')
|
||||
register_links(Document, [document_create_siblings])
|
||||
|
||||
endpoint = EndPoint('sources')
|
||||
endpoint = APIEndPoint('sources')
|
||||
endpoint.register_urls(api_urls)
|
||||
endpoint.add_endpoint('stagingfolder-list')
|
||||
|
||||
@@ -23,23 +23,36 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# API Views
|
||||
|
||||
class APIStagingSourceFileView(generics.GenericAPIView):
|
||||
class StagingSourceFileView(generics.GenericAPIView):
|
||||
"""
|
||||
Details of the selected staging file.
|
||||
"""
|
||||
def get(self, request, staging_folder_pk, filename):
|
||||
staging_folder = get_object_or_404(StagingFolder, pk=staging_folder_pk)
|
||||
return Response(SerializerStagingFolderFile(staging_folder.get_file(encoded_filename=filename), context={'request': request}).data)
|
||||
|
||||
|
||||
class APIStagingSourceListView(generics.ListAPIView):
|
||||
class StagingSourceListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the staging folders and the files they contain.
|
||||
"""
|
||||
|
||||
serializer_class = SerializerStagingFolder
|
||||
queryset = StagingFolder.objects.all()
|
||||
|
||||
|
||||
class APIStagingSourceView(generics.RetrieveAPIView):
|
||||
class StagingSourceView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Details of the selected staging folders and the files it contains.
|
||||
"""
|
||||
serializer_class = SerializerStagingFolder
|
||||
queryset = StagingFolder.objects.all()
|
||||
|
||||
|
||||
class APIStagingSourceFileImageView(generics.GenericAPIView):
|
||||
class StagingSourceFileImageView(generics.GenericAPIView):
|
||||
"""
|
||||
Image of the selected staging file.
|
||||
"""
|
||||
def get(self, request, staging_folder_pk, filename):
|
||||
staging_folder = get_object_or_404(StagingFolder, pk=staging_folder_pk)
|
||||
staging_file = staging_folder.get_file(encoded_filename=filename)
|
||||
|
||||
@@ -2,8 +2,8 @@ from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
from .api import (APIStagingSourceListView, APIStagingSourceView,
|
||||
APIStagingSourceFileView, APIStagingSourceFileImageView)
|
||||
from .api import (StagingSourceListView, StagingSourceView,
|
||||
StagingSourceFileView, StagingSourceFileImageView)
|
||||
from .literals import (SOURCE_CHOICE_WEB_FORM, SOURCE_CHOICE_STAGING,
|
||||
SOURCE_CHOICE_WATCH)
|
||||
from .wizards import DocumentCreateWizard
|
||||
@@ -40,8 +40,8 @@ urlpatterns = patterns('sources.views',
|
||||
)
|
||||
|
||||
api_urls = patterns('',
|
||||
url(r'^staging_folders/file/(?P<staging_folder_pk>[0-9]+)/(?P<filename>.+)/image/$', APIStagingSourceFileImageView.as_view(), name='stagingfolderfile-image-view'),
|
||||
url(r'^staging_folders/file/(?P<staging_folder_pk>[0-9]+)/(?P<filename>.+)/$', APIStagingSourceFileView.as_view(), name='stagingfolderfile-detail'),
|
||||
url(r'^staging_folders/$', APIStagingSourceListView.as_view(), name='stagingfolder-list'),
|
||||
url(r'^staging_folders/(?P<pk>[0-9]+)/$', APIStagingSourceView.as_view(), name='stagingfolder-detail')
|
||||
url(r'^staging_folders/file/(?P<staging_folder_pk>[0-9]+)/(?P<filename>.+)/image/$', StagingSourceFileImageView.as_view(), name='stagingfolderfile-image-view'),
|
||||
url(r'^staging_folders/file/(?P<staging_folder_pk>[0-9]+)/(?P<filename>.+)/$', StagingSourceFileView.as_view(), name='stagingfolderfile-detail'),
|
||||
url(r'^staging_folders/$', StagingSourceListView.as_view(), name='stagingfolder-list'),
|
||||
url(r'^staging_folders/(?P<pk>[0-9]+)/$', StagingSourceView.as_view(), name='stagingfolder-detail')
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user