Example #1
0
class ImageResource(FileResource):
    model = Image

    def image_url(self, instance):
        return instance.image.url

    def filename(self, instance):
        return os.path.basename(instance.image.name)

    def size(self, instance):
        return '%s x %d' % (instance.width, instance.height)

    include = ('url', 'image_url', 'filename', 'size', 'updated')


urlpatterns = patterns('',
    (r'^$', ApiRoot.as_view()),
    url(r'^pages/$', ListView.as_view(resource=PageResource), name='page-resource-root'),
    url(r'^pages/(?P<pk>[^/]+)/$', InstanceView.as_view(resource=PageResource), name='page-resource-instance'),
    url(r'^pages/(?P<pk>[^/]+)/move_page/$', MovePageView.as_view(), name='page-resource-instance-move'),
    url(r'^page_content_items/$', ListView.as_view(resource=PageContentItemResource), name='page-content-item-resource-root'),
    url(r'^page_content_items/(?P<pk>[^/]+)/$', InstanceView.as_view(resource=PageContentItemResource), name='page-content-item-resource-instance'),
    url(r'^page_content_items/(?P<pk>[^/]+)/move/$', MovePageContentItemView.as_view(), name='page-content-item-resource-instance-move'),
    url(r'^content_items/$', ListView.as_view(resource=ContentItemResource), name='content-item-resource-root'),
    url(r'^content_items/(?P<pk>[^/]+)/$', InstanceView.as_view(resource=ContentItemResource), name='content-item-resource-instance'),
    url(r'^images/$', ImageListView.as_view(resource=ImageResource), name='image-resource-root'),
    url(r'^images/(?P<pk>[^/]+)/$', InstanceView.as_view(resource=ImageResource), name='image-resource-instance'),
    url(r'^files/$', FileListView.as_view(resource=FileResource), name='file-resource-root'),
    url(r'^files/(?P<pk>[^/]+)/$', InstanceView.as_view(resource=FileResource), name='file-resource-instance'),
)
Example #2
0
from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
from views import FileView, FileListView

urlpatterns = patterns(
    '',
    url(r'^$', FileListView.as_view(), name='file-list'),
    url(r'^(?P<filename>[a-zA-Z0-9\-\._]+)/$',
        FileView.as_view(),
        name='file-handler'),
)

urlpatterns = format_suffix_patterns(urlpatterns)
Example #3
0
        MovePageView.as_view(),
        name='page-resource-instance-move'),
    url(r'^page_content_items/$',
        ListView.as_view(resource=PageContentItemResource),
        name='page-content-item-resource-root'),
    url(r'^page_content_items/(?P<pk>[^/]+)/$',
        InstanceView.as_view(resource=PageContentItemResource),
        name='page-content-item-resource-instance'),
    url(r'^page_content_items/(?P<pk>[^/]+)/move/$',
        MovePageContentItemView.as_view(),
        name='page-content-item-resource-instance-move'),
    url(r'^content_items/$',
        ListView.as_view(resource=ContentItemResource),
        name='content-item-resource-root'),
    url(r'^content_items/(?P<pk>[^/]+)/$',
        InstanceView.as_view(resource=ContentItemResource),
        name='content-item-resource-instance'),
    url(r'^images/$',
        ImageListView.as_view(resource=ImageResource),
        name='image-resource-root'),
    url(r'^images/(?P<pk>[^/]+)/$',
        InstanceView.as_view(resource=ImageResource),
        name='image-resource-instance'),
    url(r'^files/$',
        FileListView.as_view(resource=FileResource),
        name='file-resource-root'),
    url(r'^files/(?P<pk>[^/]+)/$',
        InstanceView.as_view(resource=FileResource),
        name='file-resource-instance'),
)
Example #4
0
from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
from views import FileView, FileListView


urlpatterns = patterns('',
                       url(r'^$', FileListView.as_view(), name='file-list'),
                       url(r'^(?P<filename>[a-zA-Z0-9\-\._]+)/$',
                           FileView.as_view(), name='file-handler'),
                       )


urlpatterns = format_suffix_patterns(urlpatterns)