Update the app API class methods, register the sources app main endpoint, add API doc strings

This commit is contained in:
Roberto Rosario
2014-07-08 18:51:39 -04:00
parent c4174f8020
commit 909dd582df
6 changed files with 56 additions and 43 deletions

View File

@@ -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)