Update to Django 1.4.13, update django rest framework to 2.3.13
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from djangorestframework.resources import ModelResource
|
||||
from rest_framework import serializers
|
||||
|
||||
from documents.models import Document
|
||||
from converter.exceptions import UnknownFileFormat, UnkownConvertError
|
||||
from documents.models import Document, DocumentType
|
||||
|
||||
|
||||
class DocumentResourceSimple(ModelResource):
|
||||
model = Document
|
||||
fields = ('url', 'pk', 'document_type', 'uuid', 'date_added', 'description', 'tags', 'comments', 'expensive_methods', 'versions')
|
||||
|
||||
class DocumentResourceSimple(serializers.HyperlinkedModelSerializer):
|
||||
def versions(self, instance):
|
||||
return [
|
||||
{
|
||||
@@ -41,5 +38,6 @@ class DocumentResourceSimple(ModelResource):
|
||||
for version in instance.versions.all()
|
||||
]
|
||||
|
||||
def expensive_methods(self, instance):
|
||||
return []
|
||||
class Meta:
|
||||
model = Document
|
||||
fields = ('url', 'uuid', 'date_added', 'description')
|
||||
|
||||
@@ -2,17 +2,13 @@ from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
from djangorestframework.views import ListModelView
|
||||
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
|
||||
|
||||
from .views import APIBase, Version_0, ReadOnlyInstanceModelView, IsZoomable
|
||||
from .resources import DocumentResourceSimple
|
||||
from .views import APIBase, Version_1, DocumentDetailView, IsZoomable
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', APIBase.as_view(), name='api-root'),
|
||||
url(r'^v0/$', Version_0.as_view(), name='api-version-0'),
|
||||
url(r'^v1/$', Version_1.as_view(), name='api-version-1'),
|
||||
|
||||
# Version 0 alpha API calls
|
||||
url(r'^v0/document/(?P<pk>[0-9]+)/$', ReadOnlyInstanceModelView.as_view(resource=DocumentResourceSimple), name='documents-simple'),
|
||||
url(r'^v0/document/(?P<pk>[0-9]+)/version/(?P<version_pk>[0-9]+)/page/(?P<page_number>[0-9]+)/expensive/is_zoomable/$', IsZoomable.as_view(), name='documents-expensive-is_zoomable'),
|
||||
# Version 1 API calls
|
||||
url(r'^v1/document/(?P<pk>[0-9]+)/$', DocumentDetailView.as_view(), name='document-detail'),
|
||||
url(r'^v1/document/(?P<pk>[0-9]+)/version/(?P<version_pk>[0-9]+)/page/(?P<page_number>[0-9]+)/expensive/is_zoomable/$', IsZoomable.as_view(), name='documents-expensive-is_zoomable'),
|
||||
)
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
'''Views file for the rest_api app'''
|
||||
"""Views file for the rest_api app"""
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import Document, DocumentVersion, DocumentPage
|
||||
from converter.exceptions import UnknownFileFormat, UnkownConvertError
|
||||
from documents.models import Document, DocumentVersion, DocumentPage
|
||||
|
||||
from djangorestframework.views import View, ModelView, ListModelView, InstanceModelView
|
||||
from djangorestframework.mixins import InstanceMixin, ReadModelMixin
|
||||
from djangorestframework.response import Response
|
||||
from djangorestframework import status
|
||||
from rest_framework import generics
|
||||
from rest_framework import permissions
|
||||
from rest_framework import serializers
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.reverse import reverse
|
||||
|
||||
from .resources import DocumentResourceSimple
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ReadOnlyInstanceModelView(InstanceModelView):
|
||||
allowed_methods = ['GET']
|
||||
|
||||
|
||||
class APIBase(View):
|
||||
"""This is the REST API for Mayan EDMS (https://github.com/rosarior/mayan/).
|
||||
class APIBase(generics.GenericAPIView):
|
||||
"""This is the REST API for Mayan EDMS (https://github.com/mayan-edms/mayan-edms).
|
||||
|
||||
All the API calls can be navigated either through the browser or from the command line...
|
||||
|
||||
@@ -31,27 +30,37 @@ class APIBase(View):
|
||||
|
||||
"""
|
||||
|
||||
def get(self, request):
|
||||
return [
|
||||
{'name': 'Version 0 Alpha', 'url': reverse('api-version-0')}
|
||||
]
|
||||
def get(self, request, format=None):
|
||||
return Response(
|
||||
{'versions': [
|
||||
{'name': 'Version 1', 'url': reverse('api-version-1', request=request, format=format), 'number': 1}
|
||||
]}
|
||||
)
|
||||
|
||||
|
||||
class Version_0(View):
|
||||
def get(self, request):
|
||||
return [
|
||||
{'name': 'Resources', 'resources': ['document/<pk>']}
|
||||
]
|
||||
class Version_1(generics.GenericAPIView):
|
||||
def get(self, request, format=None):
|
||||
return Response(
|
||||
[
|
||||
{'name': 'Resources', 'resources': ['document/<pk>']}
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class IsZoomable(View):
|
||||
class DocumentDetailView(generics.RetrieveAPIView):
|
||||
allowed_methods = ['GET']
|
||||
serializer_class = DocumentResourceSimple
|
||||
queryset = Document.objects.all()
|
||||
|
||||
|
||||
class IsZoomable(generics.GenericAPIView):
|
||||
def get(self, request, pk, page_number, version_pk):
|
||||
logger.info('received is_zoomable call from: %s' % (request.META['REMOTE_ADDR']))
|
||||
document_version = get_object_or_404(DocumentVersion, pk=version_pk)
|
||||
try:
|
||||
document_version.document.get_image_cache_name(int(page_number), version_pk)
|
||||
return {'result': True}
|
||||
return Response({'result': True})
|
||||
except (UnknownFileFormat, UnkownConvertError,
|
||||
DocumentPage.DoesNotExist, Document.DoesNotExist,
|
||||
DocumentVersion.DoesNotExist):
|
||||
return {'result': False}
|
||||
return Response({'result': False})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Django==1.3.5
|
||||
Django==1.4.13
|
||||
django-pagination==1.0.7
|
||||
wsgiref==0.1.2
|
||||
django-taggit==0.9.3
|
||||
@@ -12,7 +12,7 @@ Pillow==1.7.8
|
||||
cssmin==0.1.4
|
||||
django-compressor==1.1.1
|
||||
-e git+https://github.com/rosarior/django-sendfile.git#egg=django-sendfile
|
||||
djangorestframework==0.2.3
|
||||
djangorestframework==2.3.13
|
||||
South==0.7.6
|
||||
https://github.com/rosarior/python-gnupg/zipball/0.2.8
|
||||
python-hkp==0.1.3
|
||||
|
||||
@@ -148,7 +148,7 @@ INSTALLED_APPS = (
|
||||
'taggit',
|
||||
'mptt',
|
||||
'compressor',
|
||||
'djangorestframework',
|
||||
'rest_framework',
|
||||
# Base generic
|
||||
'permissions',
|
||||
'project_setup',
|
||||
|
||||
Reference in New Issue
Block a user