Exemplo n.º 1
0
 def test_fifo_behaviour(self):
     '''It's fine that the Blogposts are capped off at MAX_POSTS. But we want to make sure we see FIFO behaviour.'''
     for post in range(15):
         form_data = {'title': '%s' % post, 'content': 'This is the content of post #%s' % post}
         request = self.factory.post('/blog-post', data=form_data)
         view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
         view(request)
     request = self.factory.get('/blog-post')
     view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
     response = view(request)
     response_posts = json.loads(response.content)
     response_titles = [d['title'] for d in response_posts]
     response_titles.reverse()
     self.assertEquals(response_titles, ['%s' % i for i in range(models.MAX_POSTS - 5, models.MAX_POSTS + 5)])
Exemplo n.º 2
0
 def test_fifo_behaviour(self):
     '''It's fine that the Blogposts are capped off at MAX_POSTS. But we want to make sure we see FIFO behaviour.'''
     for post in range(15):
         form_data = {'title': '%s' % post, 'content': 'This is the content of post #%s' % post}
         request = self.factory.post('/blog-post', data=form_data)
         view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
         view(request)
     request = self.factory.get('/blog-post')
     view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
     response = view(request)
     response_posts = json.loads(response.content)
     response_titles = [d['title'] for d in response_posts]
     response_titles.reverse()
     self.assertEquals(response_titles, ['%s' % i for i in range(models.MAX_POSTS - 5, models.MAX_POSTS + 5)])
Exemplo n.º 3
0
def get_colors_json():
    """
    This is a surprising kludge to get the json from a
    DRF resource, outside of a true request/response context

    for a simple resource - most easily mocked by doing list(queryset.values(fields))
    """
    resource_view = ListOrCreateModelView(resource=ColorResource)
    dummy_request = HttpRequest()
    response_obj = resource_view.get(dummy_request)
    response = Response(status.HTTP_200_OK, response_obj)
    jsonr =  JSONRenderer(resource_view)
    filtered_content = resource_view.filter_response(response_obj)
    # json_string = jsonr.render(filtered_content)
    return filtered_content
Exemplo n.º 4
0
def get_colors_json():
    """
    This is a surprising kludge to get the json from a
    DRF resource, outside of a true request/response context

    for a simple resource - most easily mocked by doing list(queryset.values(fields))
    """
    resource_view = ListOrCreateModelView(resource=ColorResource)
    dummy_request = HttpRequest()
    response_obj = resource_view.get(dummy_request)
    response = Response(status.HTTP_200_OK, response_obj)
    jsonr = JSONRenderer(resource_view)
    filtered_content = resource_view.filter_response(response_obj)
    # json_string = jsonr.render(filtered_content)
    return filtered_content
Exemplo n.º 5
0
 def test_blogposts_not_exceed_MAX_POSTS(self):
     '''Posting blog-posts should not result in more than MAX_POSTS items stored.'''
     for post in range(models.MAX_POSTS + 5):
         form_data = {'title': 'This is post #%s' % post, 'content': 'This is the content of post #%s' % post}
         request = self.factory.post('/blog-post', data=form_data)
         view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
         view(request)
     self.assertEquals(len(models.BlogPost.objects.all()),models.MAX_POSTS)
Exemplo n.º 6
0
 def test_blogposts_not_exceed_MAX_POSTS(self):
     '''Posting blog-posts should not result in more than MAX_POSTS items stored.'''
     for post in range(models.MAX_POSTS + 5):
         form_data = {'title': 'This is post #%s' % post, 'content': 'This is the content of post #%s' % post}
         request = self.factory.post('/blog-post', data=form_data)
         view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
         view(request)
     self.assertEquals(len(models.BlogPost.objects.all()),models.MAX_POSTS)
Exemplo n.º 7
0
 def post(self, request):
   try:
     obj = self.resource.model.objects.filter(
             filename=request.POST.__getitem__('filename'),
             revision=request.POST.__getitem__('revision'))
     if obj.count() != 0:
       return Response(status.HTTP_406_NOT_ACCEPTABLE,
                       headers={'Reason': 'Duplicate entry'})
   except:
     pass
   return ListOrCreateModelView.post(self, request)
Exemplo n.º 8
0
def add_narcissus_urls(urls):
    urls += patterns('',
        url(r'^dashboard/', include('narcissus.dashboard.urls')),
        url(r'^api/user/(?P<pk>[^/]+)/$', InstanceModelView.as_view(
            resource=UserResource, permissions=(SameUserOrReadOnly,),
        ), name='narcissus-user-detail'),
    )
    for name, posttype in posttypes.items():
        urls += patterns('',
            url(r'^api/%s/$' % name,
                ListOrCreateModelView.as_view(
                    resource=posttype.resource,
                    permissions=(permissions.IsUserOrIsAnonReadOnly,),
                ),
                name='narcissus-api-%s' % name),
            url(r'^api/%s/(?P<pk>[^/]+)/$' % name,
                InstanceModelView.as_view(
                    resource=posttype.resource,
                    permissions=(SameUserOrReadOnly,),
                ),
                name='narcissus-api-%s-detail' % name),
        )
    return urls
Exemplo n.º 9
0
# Uncomment the next two lines to enable the admin:
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'web.views.home', name='home'),
    # url(r'^web/', include('web.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    
    url(r'^rest/participants/$',                 ListOrCreateModelView.as_view(resource=ParticipantResource), name='model-resource-root'),
    url(r'^rest/participant/(?P<pk>[0-9]+)/$',   InstanceModelView.as_view(resource=ParticipantResource)),
    url(r'^rest/events/$',                       ListOrCreateModelView.as_view(resource=EventResource), name='model-resource-root'),
    url(r'^rest/event/(?P<pk>[0-9]+)/$',         InstanceModelView.as_view(resource=EventResource)),
    url(r'^rest/groups/$',                       ListOrCreateModelView.as_view(resource=GroupResource), name='model-resource-root'),
    url(r'^rest/group/(?P<pk>[0-9]+)/$',         InstanceModelView.as_view(resource=GroupResource)),
    url(r'^rest/types/$',                        ListOrCreateModelView.as_view(resource=ExpenseTypeResource), name='model-resource-root'),
    url(r'^rest/type/(?P<pk>[0-9]+)/$',          InstanceModelView.as_view(resource=ExpenseTypeResource)),
    url(r'^rest/weights/$',                      ListOrCreateModelView.as_view(resource=WeightResource), name='model-resource-root'),
    url(r'^rest/weight/(?P<pk>[0-9]+)/$',        InstanceModelView.as_view(resource=WeightResource)),
    url(r'^rest/expenses/$',                     ListOrCreateModelView.as_view(resource=ExpenseResource)),
    url(r'^rest/expense/(?P<pk>[0-9]+)/$',       InstanceModelView.as_view(resource=ExpenseResource)),
    url(r'^rest/authenticate$',                  AuthenticationView.as_view()),
    url(r'^rest/add_expense$',                   ExpenseAddView.as_view()),
    url(r'^rest/calculator$',                    CalculatorView.as_view()),
    url(r'^rest/event/(?P<pk>[0-9+])/participants$', EventParticipantsView.as_view()),
Exemplo n.º 10
0
    class MockResourceModel(models.Model):
        foo = models.BooleanField(default=False)
        bar = models.IntegerField(help_text='Must be an integer.')
        baz = models.CharField(max_length=32,
                               help_text='Free text.  Max length 32 chars.')

    model = MockResourceModel
    fields = ('foo', 'bar', 'baz')


urlpatterns = patterns(
    '',
    url(r'^mock/$', MockView.as_view()),
    url(r'^mock/final/$', MockViewFinal.as_view()),
    url(r'^resourcemock/$', ResourceMockView.as_view()),
    url(r'^model/$', ListOrCreateModelView.as_view(resource=MockResource)),
    url(r'^model/(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=MockResource)),
    url(r'^restframework/',
        include('djangorestframework.urls', namespace='djangorestframework')),
)


class BaseViewTests(TestCase):
    """Test the base view class of djangorestframework"""
    urls = 'djangorestframework.tests.views'

    def test_view_call_final(self):
        response = self.client.options('/mock/final/')
        self.assertEqual(response['Content-Type'].split(';')[0],
                         "application/json")
Exemplo n.º 11
0
from django.conf.urls import patterns, include, url
from django.views.generic.base import View
from testapp import views
from django.views import generic
from djangorestframework.views import ListOrCreateModelView
from testapp.api import PersonResource

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',

    url(r'^$', generic.RedirectView.as_view(url='people'), name='home' ),
    url(r'^person/add$', views.PersonCreate.as_view(), name='person_add'),
    url(r'^people$', views.PersonList.as_view(), name='person_list'),

    # RESTful Api
    url(r'^restframework', include('djangorestframework.urls', namespace='djangorestframework')),
    url(r'api/person/', ListOrCreateModelView.as_view(resource=PersonResource))
    
)
Exemplo n.º 12
0
    model = Group

class UserForm(ModelForm):
    class Meta:
        model = User
        exclude = ('last_login', 'date_joined')

class UserResource(ModelResource):
    model = User
    form = UserForm
    
class CustomUserResource(ModelResource):
    model = CustomUser    

urlpatterns = patterns('',
    url(r'^users/$', ListOrCreateModelView.as_view(resource=UserResource), name='users'),
    url(r'^users/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=UserResource)),
    url(r'^customusers/$', ListOrCreateModelView.as_view(resource=CustomUserResource), name='customusers'),
    url(r'^customusers/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=CustomUserResource)),
    url(r'^groups/$', ListOrCreateModelView.as_view(resource=GroupResource), name='groups'),
    url(r'^groups/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=GroupResource)),
)


class ModelViewTests(TestModelsTestCase):
    """Test the model views djangorestframework provides"""
    urls = 'djangorestframework.tests.modelviews'  

    def test_creation(self):
        """Ensure that a model object can be created"""
        self.assertEqual(0, Group.objects.count())
Exemplo n.º 13
0
from django.conf.urls.defaults import *

from djangorestframework.views import ListOrCreateModelView, InstanceModelView

from django.conf.urls.defaults import patterns

from apps.serverinfo.api import RootResource, ServerResource, ServerResourceQuery, \
    ServerInlineFormResource, AttributeResource, ServerGetInfoResource, ServerNewResource, \
    AttributesResource, getIpHelperFormsResource, getNextIpResource, IpResource, NoteResource

urlpatterns = patterns('',
                       url(r'^$', RootResource.as_view()),

                       url(r'^server/$', ListOrCreateModelView.as_view(resource=ServerResource), name='server-resource'),
                       url(r'^server/get/', ServerGetInfoResource.as_view()),
                       url(r'^server/new/', ServerNewResource.as_view()),
                       url(r'^server/datatables/', ServerResourceQuery.as_view()),
                       url(r'^server/inlineForm/', ServerInlineFormResource.as_view()),
                       url(r'^server/attribute/', AttributeResource.as_view()),
                       url(r'^server/ip/', IpResource.as_view()),
                       url(r'^server/note/', NoteResource.as_view()),
                       url(r'^server/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=ServerResource)),

                       url(r'^attributes/$', ListOrCreateModelView.as_view(resource=AttributesResource), name='attributes-resource'),
                       url(r'^attributes/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=AttributesResource)),
                       url(r'^getIpHelperForms/$', getIpHelperFormsResource.as_view()),
                       url(r'^getIpHelperNext/$', getNextIpResource.as_view()),
                       )

# Static views served by the rest framework itself
urlpatterns += patterns('djangorestframework.utils.staticviews',
Exemplo n.º 14
0
from django.conf.urls.defaults import *
from models import *
from views import *

from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from resources import *

urlpatterns = patterns('',

    (r'product/create/$', create_product),
    (r'product/list/$', list_product ),
    (r'product/edit/(?P<id>[^/]+)/$', edit_product),
    (r'product/view/(?P<id>[^/]+)/$', view_product),
    (r'product/search$', search_product),
    (r'API/product/items', ListOrCreateModelView.as_view(resource=ProductItemResource )),

)
Exemplo n.º 15
0
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from modelresourceexample.resources import MyModelResource

my_model_list = ListOrCreateModelView.as_view(resource=MyModelResource)
my_model_instance = InstanceModelView.as_view(resource=MyModelResource)

urlpatterns = patterns(
    '',
    url(r'^$', my_model_list, name='model-resource-root'),
    url(r'^(?P<id>[0-9]+)/$',
        my_model_instance,
        name='model-resource-instance'),
)
Exemplo n.º 16
0
from django.conf.urls.defaults import patterns
from djangorestframework.views import ListOrCreateModelView, InstanceModelView

from .resources import *
from .views import *

urlpatterns = patterns(
    "api1.views",
    (r"^$", "api"),
    (r"^setting/$", SettingRootView.as_view()),
    (r"^setting/(?P<key>[\w\d]+)$", SettingView.as_view()),
    (r"^feed/$", FeedRootView.as_view()),
    (r"^feed/(?P<key>[\d]+)$", FeedView.as_view()),
    (r"^hidden/$", HideRootView.as_view()),
    (r"^hidden/(?P<key>[\d]+)?$", HideView.as_view()),
    (r"^thread/$", ListOrCreateModelView.as_view(resource=ThreadResource)),
    (r"^thread/(?P<section__slug>\w+)/$",
     ListOrCreateModelView.as_view(resource=ThreadResource)),
    (r"^thread/(?P<id>\d+)$",
     ThreadInstanceView.as_view(resource=ThreadResource)),
    (r"^thread/(?P<section__slug>\w+)/(?P<id>\d+)$",
     ThreadInstanceView.as_view(resource=ThreadResource)),
    (r"^post/$", PostListOrCreateView.as_view(resource=PostResource)),
    (r"^post/(?P<thread__section__slug>\w+)/$",
     PostListOrCreateView.as_view(resource=PostResource)),
    (r"^post/(?P<thread__section__slug>\w+)/first/$",
     PostListOrCreateView.as_view(resource=PostResource), {
         "is_op_post": True
     }),
    (r"^post/(?P<id>\d+)$", PostInstanceView.as_view(resource=PostResource)),
    (r"^post/(?P<thread__section__slug>\w+)/(?P<pid>\d+)$",
Exemplo n.º 17
0
from lizard_fewsnorm.api.views import ParameterView
from lizard_fewsnorm.api.views import RootView
from lizard_fewsnorm.api.views import TimeserieSelectionView


admin.autodiscover()

NAME_PREFIX = 'lizard_fewsnorm_api_'

urlpatterns = patterns(
    '',
    url(r'^$',
        RootView.as_view(),
        name=NAME_PREFIX + 'root'),
    url(r'^source/$',
        ListOrCreateModelView.as_view(resource=FewsNormSourceResource),
        name=NAME_PREFIX + 'source_list'),
    url(r'^source/(?P<slug>.*)/$',
        InstanceModelView.as_view(resource=FewsNormSourceResource),
        name=NAME_PREFIX + 'source_detail'),
    url(r'^location/$',
        LocationView.as_view(),
        name=NAME_PREFIX + 'location'),
    url(r'^identifier/$',
        IdentifierView.as_view(),
        name=NAME_PREFIX + 'identifier'),
    url(r'^location/(?P<ident>.*)/$',
        InstanceModelView.as_view(resource=LocationResource),
        name=NAME_PREFIX + 'location_detail'),
    url(r'^parameter/$',
        ParameterView.as_view(),
Exemplo n.º 18
0
}

########NEW FILE########
__FILENAME__ = urls
from django.conf.urls import patterns, include, url
from djangorestframework.views import InstanceModelView, ListOrCreateModelView
from basicapi import resources as rs
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns(
    '',
    # Examples:
    url(r'^horses/?$',
        ListOrCreateModelView.as_view(resource=rs.HorseResource),
        name='horse_instance'),
    url(r'^horses/(?P<id>\d+)/?$',
        InstanceModelView.as_view(resource=rs.HorseResource),
        name='horse_instance'),
    url(r'^restframework',
        include('djangorestframework.urls', namespace='djangorestframework'))
    # url(r'^simpleapi/', include('simpleapi.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
)
Exemplo n.º 19
0
from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView

from djangorestframework.resources import ModelResource
from djangorestframework.views import ListOrCreateModelView, InstanceModelView

from environment.models import Estatistica


class EstatisticaResource(ModelResource):
    model = Estatistica


urlpatterns = patterns(
    '',
    url(r'^rest/environment/$',
        ListOrCreateModelView.as_view(resource=EstatisticaResource)),
    url(r'^rest/environment/(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=EstatisticaResource)),
)
Exemplo n.º 20
0
try:
    from django.conf.urls import patterns, url
except ImportError:
    # Django < 1.4
    from django.conf.urls.defaults import patterns, url

from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from blogpost.resources import BlogPostResource, CommentResource


urlpatterns = patterns('',
    url(r'^$', ListOrCreateModelView.as_view(resource=BlogPostResource), name='blog-posts-root'),
    url(r'^(?P<key>[^/]+)/$', InstanceModelView.as_view(resource=BlogPostResource), name='blog-post'),
    url(r'^(?P<blogpost>[^/]+)/comments/$', ListOrCreateModelView.as_view(resource=CommentResource), name='comments'),
    url(r'^(?P<blogpost>[^/]+)/comments/(?P<id>[^/]+)/$', InstanceModelView.as_view(resource=CommentResource)),
)
Exemplo n.º 21
0
from django.conf.urls.defaults import patterns, include, url
from djangorestframework.resources import ModelResource
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from bluuserver.clients.models import Client

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

class ClientResource(ModelResource):
	model = Client

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'bluuserver.views.home', name='home'),
    # url(r'^bluuserver/', include('bluuserver.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    url(r'^api-auth/', include('djangorestframework.urls', namespace='djangorestframework')),
    url(r'^$', ListOrCreateModelView.as_view(resource=ClientResource)),
    #url(r'^Client/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=ClientResource)),
    url(r'^Client/(?P<client_id>[^/]+)/$', 'clients.views.showClient'),
)
Exemplo n.º 22
0
urlpatterns = patterns(
    'chronicle.views',
    url(r'^$', 'index', name='chronicle-index'),
    url(r'^(?P<item_type>\w+)/(?P<item_id>\d+)/$',
        'item',
        name='chronicle-item'),
    url(r'^add/(?P<item_type>\w+)/$', 'add_item', name='chronicle-item-add'),
    url(r'^edit/(?P<item_type>\w+)/(?P<item_id>\d+)/$',
        'edit_item',
        name='chronicle-item-edit'),
)

# REST Framework, urls, generate and add
rest_urls = []
import sys
module = sys.modules[__name__]
for string, model in models.iteritems():
    rest_urls.append(
        url(r'^rest/' + string + '/$',
            ListOrCreateModelView.as_view(
                resource=getattr(module, model.__name__ + 'Resource')),
            name='chronicle-rest-' + string))
    rest_urls.append(
        url(r'^rest/' + string + '/(?P<pk>\d+)/$',
            HTMLInstanceModelView.as_view(
                resource=getattr(module, model.__name__ + 'Resource')),
            name='chronicle-rest-' + string + '-instance'))

urlpatterns += patterns('', *rest_urls)
Exemplo n.º 23
0
        foo = models.BooleanField()
        bar = models.IntegerField(help_text='Must be an integer.')
        baz = models.CharField(max_length=32, help_text='Free text.  Max length 32 chars.')

    model = MockResourceModel
    fields = ('foo', 'bar', 'baz')

urlpatterns = patterns('djangorestframework.utils.staticviews',
    url(r'^robots.txt$', 'deny_robots'),
    url(r'^favicon.ico$', 'favicon'),
    url(r'^accounts/login$', 'api_login'),
    url(r'^accounts/logout$', 'api_logout'),
    url(r'^mock/$', MockView.as_view()),
    url(r'^mock/final/$', MockViewFinal.as_view()),
    url(r'^resourcemock/$', ResourceMockView.as_view()),
    url(r'^model/$', ListOrCreateModelView.as_view(resource=MockResource)),
    url(r'^model/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=MockResource)),
)

class BaseViewTests(TestCase):
    """Test the base view class of djangorestframework"""
    urls = 'djangorestframework.tests.views'

    def test_view_call_final(self):
        response = self.client.options('/mock/final/')
        self.assertEqual(response['Content-Type'].split(';')[0], "application/json")
        parser = JSONParser(None)
        (data, files) = parser.parse(StringIO(response.content))
        self.assertEqual(data['test'], 'passed')

    def test_options_method_simple_view(self):
Exemplo n.º 24
0
try:
    from django.conf.urls import patterns, url
except ImportError:
    # Django < 1.4
    from django.conf.urls.defaults import patterns, url

from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from blogpost.resources import BlogPostResource, CommentResource

urlpatterns = patterns(
    '',
    url(r'^$',
        ListOrCreateModelView.as_view(resource=BlogPostResource),
        name='blog-posts-root'),
    url(r'^(?P<key>[^/]+)/$',
        InstanceModelView.as_view(resource=BlogPostResource),
        name='blog-post'),
    url(r'^(?P<blogpost>[^/]+)/comments/$',
        ListOrCreateModelView.as_view(resource=CommentResource),
        name='comments'),
    url(r'^(?P<blogpost>[^/]+)/comments/(?P<id>[^/]+)/$',
        InstanceModelView.as_view(resource=CommentResource)),
)
Exemplo n.º 25
0
        exclude = ('last_login', 'date_joined')


class UserResource(ModelResource):
    model = User
    form = UserForm


class CustomUserResource(ModelResource):
    model = CustomUser


urlpatterns = patterns(
    '',
    url(r'^users/$',
        ListOrCreateModelView.as_view(resource=UserResource),
        name='users'),
    url(r'^users/(?P<id>[0-9]+)/$',
        InstanceModelView.as_view(resource=UserResource)),
    url(r'^customusers/$',
        ListOrCreateModelView.as_view(resource=CustomUserResource),
        name='customusers'),
    url(r'^customusers/(?P<id>[0-9]+)/$',
        InstanceModelView.as_view(resource=CustomUserResource)),
    url(r'^groups/$',
        ListOrCreateModelView.as_view(resource=GroupResource),
        name='groups'),
    url(r'^groups/(?P<id>[0-9]+)/$',
        InstanceModelView.as_view(resource=GroupResource)),
)
Exemplo n.º 26
0
from django.conf.urls.defaults import *

from djangorestframework.views import ListOrCreateModelView, InstanceModelView

from django.conf.urls.defaults import patterns

from apps.serverinfo.api import RootResource, ServerResource, ServerResourceQuery, \
    ServerInlineFormResource, AttributeResource, ServerGetInfoResource, ServerNewResource, \
    AttributesResource, getIpHelperFormsResource, getNextIpResource, IpResource, NoteResource

urlpatterns = patterns(
    '',
    url(r'^$', RootResource.as_view()),
    url(r'^server/$',
        ListOrCreateModelView.as_view(resource=ServerResource),
        name='server-resource'),
    url(r'^server/get/', ServerGetInfoResource.as_view()),
    url(r'^server/new/', ServerNewResource.as_view()),
    url(r'^server/datatables/', ServerResourceQuery.as_view()),
    url(r'^server/inlineForm/', ServerInlineFormResource.as_view()),
    url(r'^server/attribute/', AttributeResource.as_view()),
    url(r'^server/ip/', IpResource.as_view()),
    url(r'^server/note/', NoteResource.as_view()),
    url(r'^server/(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=ServerResource)),
    url(r'^attributes/$',
        ListOrCreateModelView.as_view(resource=AttributesResource),
        name='attributes-resource'),
    url(r'^attributes/(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=AttributesResource)),
    url(r'^getIpHelperForms/$', getIpHelperFormsResource.as_view()),
Exemplo n.º 27
0
    url(r'^dump/$', DumpRoot.as_view(
            permissions=(permissions.IsUserOrIsAnonReadOnly,)),
        name='dump-rule'),

    url(r'^apply/$', ApplyRoot.as_view(
            permissions=(permissions.IsUserOrIsAnonReadOnly,)),
        name='apply-rule'),

    url(r'^description/(?P<pk>[0-9]+)/$', \
            InstanceModelView.as_view(
                resource=DescriptionResource,
                permissions=(permissions.IsUserOrIsAnonReadOnly,)),
        ),
    url(r'^description/$', \
            ListOrCreateModelView.as_view(
                resource=DescriptionResource,
                permissions=(permissions.IsUserOrIsAnonReadOnly,)),
        ),

    url(r'^token/(?P<pk>[0-9]+)/$', \
            InstanceModelView.as_view(
                resource=TokenResource,
                permissions=(permissions.IsUserOrIsAnonReadOnly,)),
        ),
    url(r'^token/$', \
            ListOrCreateModelView.as_view(
                resource=TokenResource,
                permissions=(permissions.IsUserOrIsAnonReadOnly,)),
        ),

    url(r'^regularisationtype/(?P<pk>[0-9]+)/$', \
Exemplo n.º 28
0
Arquivo: urls.py Projeto: Luka1002/we
from django.conf.urls.defaults import patterns, url

from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from apps.todos.resources import TodoResource

my_model_list = ListOrCreateModelView.as_view(resource=TodoResource)
my_model_instance = InstanceModelView.as_view(resource=TodoResource)

urlpatterns = patterns('',
    url(r'^todos/$', my_model_list, name='todos_api_root'),
    url(r'^todos/(?P<id>[0-9]+)$', my_model_instance, name='todos_api_instance'),
)
Exemplo n.º 29
0
from django.conf.urls.defaults import patterns, url, include
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from groupes.api import EleveResource, ImportationResource, ImpGroupeResource, \
    ImpGroupeDetailResource







urlpatterns = patterns( '',
    # Administration
    url( r'^admin/', include( 'uiadmin.urls' ) ),
    url( r'^groupes/', include( 'groupes.urls' ) ),
    url( r'^periodes/', include( 'periode.urls' ) ),
    url( r'^evaluations/', include( 'evaluations.urls' ) ),
                       
    # API
    url( r'^api/v4/eleves/$', ListOrCreateModelView.as_view( resource=EleveResource ) ),
    url( r'^api/v4/eleves/(?P<pk>[^/]+)/$', InstanceModelView.as_view( resource=EleveResource ) ),
    url( r'^api/v4/importations/$', ListOrCreateModelView.as_view( resource=ImportationResource ) ),
    url( r'^api/v4/importations/(?P<pk>[^/]+)/$', InstanceModelView.as_view( resource=ImportationResource ) ),
    url( r'^api/v4/importations/(?P<importation>[^/]+)/groupes/$', ListOrCreateModelView.as_view( resource=ImpGroupeResource ) ),
    url( r'^api/v4/importations/(?P<importation>[^/]+)/groupes/(?P<pk>[^/]+)/$', InstanceModelView.as_view( resource=ImpGroupeResource ) ),
    url( r'^api/v4/importations/(?P<importation>[^/]+)/groupes/(?P<pk>[^/]+)/eleves/$', InstanceModelView.as_view( resource=ImpGroupeDetailResource ), name='importation-groupes-details' ),

    
 )
Exemplo n.º 30
0
from django.conf.urls import patterns, include, url
from djangorestframework.permissions import IsUserOrIsAnonReadOnly
from djangorestframework.views import InstanceModelView, ListOrCreateModelView, \
    ListModelView
from events.resources import ConventionResource, GameResource, PublisherResource, \
    DemandResource, UserResource
from events.views import ApiRoot, EventRoot, EventModelView, EventJoinView, \
    EventLeaveView, DemandRoot, DemandModelView, UserModelView

urlpatterns = patterns('events',
    url(r'^$', ApiRoot.as_view()),

    url(r'^publishers/$', ListOrCreateModelView.as_view(
        resource=PublisherResource, permissions=(IsUserOrIsAnonReadOnly, )),
        name='publisher-list'),
    url(r'^publishers/(?P<pk>[^/]+)/$', InstanceModelView.as_view(
        resource=PublisherResource, permissions=(IsUserOrIsAnonReadOnly, )),
        name='publisher-instance'),
    
    url(r'^games/$', ListOrCreateModelView.as_view(resource=GameResource,
        permissions=(IsUserOrIsAnonReadOnly, )), name='game-list'),
    url(r'^games/(?P<pk>[^/]+)/$', InstanceModelView.as_view(
        resource=GameResource, permissions=(IsUserOrIsAnonReadOnly, )),
        name='game-instance'),

    url(r'^conventions/$', ListOrCreateModelView.as_view(
        resource=ConventionResource, permissions=(IsUserOrIsAnonReadOnly, )),
        name='convention-list'),
    url(r'^conventions/(?P<pk>[^/]+)$', InstanceModelView.as_view(
        resource=ConventionResource, permissions=(IsUserOrIsAnonReadOnly, )),
        name='convention-instance'),
Exemplo n.º 31
0
from django.shortcuts import redirect
from bounty.board import models
from djangorestframework.resources import ModelResource
from djangorestframework.views import ListOrCreateModelView, InstanceModelView

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

# REST resources
class HackResource(ModelResource):
	model = models.Hack


urlpatterns = patterns('bounty.board.views',
    url(r'^$', 'home.home'),
    #url(r'^$', redirect('home')),
    
    # RESTful API
    url(r'^api/hacks$', ListOrCreateModelView.as_view(resource=HackResource)),

    # for Meetup API 
    url(r'', include('social_auth.urls')),

    # standard django admin
    url(r'^admin/', include(admin.site.urls)),

    # debugging - remove me
    url(r'^accounts/profile', 'debug.dump_user_info'),
)
Exemplo n.º 32
0
from django.conf.urls.defaults import patterns, url

from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from .resources import ColorResource

urlpatterns = patterns('',
    url(r'^colors/$',
        ListOrCreateModelView.as_view(resource=ColorResource),
        name='todo-resources'),
    url(r'^colors/(?P<pk>[0-9]+)$',
        InstanceModelView.as_view(resource=ColorResource)),
)

Exemplo n.º 33
0
    #
    #    return instance
    
#class MockView(View):
#            permissions = ()
#            form = FileForm
#            def post(self, request, *args, **kwargs):
#                return {'FILE_NAME': self.CONTENT['file'].name,
#                        'FILE_CONTENT': self.CONTENT['file'].read()}

from django.core.urlresolvers import reverse

from djangorestframework.views import View
from djangorestframework.response import Response
from djangorestframework import status

from cloudport.job_manager.views import *

class ExampleView(View):
    #A basic read-only view that points to 3 other views.
    def get(self, request):
        #Handle GET requests, returning a list of URLs pointing to 3 other views.
        return repr(request.user)

urlpatterns = patterns('',
    url(r'^test/$', ExampleView.as_view(resource=Jobs, permissions=(permissions.IsAuthenticated,))),
    url(r'^job/$', ListOrCreateModelView.as_view(resource=Jobs, permissions=(permissions.IsAuthenticated,))),
    url(r'^job/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=Jobs, permissions=(permissions.IsAuthenticated,))),
    #url(r'^files/$', ListOrCreateModelView.as_view(resource=DataFiles, permissions=(permissions.IsAuthenticated,))),    
    #url(r'^files/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=DataFiles, permissions=(permissions.IsAuthenticated,))),
)
Exemplo n.º 34
0
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from modelresourceexample.resources import MyModelResource

urlpatterns = patterns('',
    url(r'^$',          ListOrCreateModelView.as_view(resource=MyModelResource), name='model-resource-root'),
    url(r'^(?P<pk>[0-9]+)/$', InstanceModelView.as_view(resource=MyModelResource)),
)
Exemplo n.º 35
0
from django.conf.urls import patterns, include, url
from djangorestframework.views import InstanceModelView, ListOrCreateModelView
from basicapi import resources as rs
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    url(r'^horses/?$', ListOrCreateModelView.as_view(resource=rs.HorseResource), name='horse_instance'),
    url(r'^horses/(?P<id>\d+)/?$', InstanceModelView.as_view(resource=rs.HorseResource), name='horse_instance'),
    url(r'^restframework', include('djangorestframework.urls', namespace='djangorestframework'))
    # url(r'^simpleapi/', include('simpleapi.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
)
Exemplo n.º 36
0
class BackupsTodo(Todo):
    queryset = BackupTask.objects.all()


class TSMBackupsTodo(BackupsTodo):
    queryset = TSMBackupTask.objects.all()


class R1BackupsTodo(BackupsTodo):
    queryset = R1BackupTask.objects.all()


urlpatterns = patterns(
    '',
    url(r'^$', ListOrCreateModelView.as_view(resource=BackupTaskResource)),
    url(r'^tsm/todo/$', TSMBackupsTodo.as_view(), name='tsm-backups-todo'),
    url(r'^r1/todo/$', R1BackupsTodo.as_view(), name='r1-backups-todo'),
    url(r'^todo/$', BackupsTodo.as_view(), name='backups-todo'),
    url(r'^backupfilechecker/$',
        BackupFileCheckerView.as_view(),
        name='backup-file-checker'),
    url(r'^filesToCompress$',
        FilesToCompressView.as_view(),
        name='backup-files-to-compress'),
    url(r'^filesToDelete$',
        FilesToDeleteView.as_view(),
        name='backup-files-to-delete'),
    url(r'^addBackupFile$', add_backup_file, name="addBackupFile"),
    url(r'^BackupFileInfo$',
        GetBackupFileInfo.as_view(),
Exemplo n.º 37
0
 def test_get_to_root(self):
     '''Simple get to the *root* url of blogposts'''
     request = self.factory.get('/blog-post')
     view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
     response = view(request)
     self.assertEqual(response.status_code, 200)
Exemplo n.º 38
0
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from djangorestframework.permissions import IsUserOrIsAnonReadOnly
from api.resources import AllPetitionsResource, PetitionResource, SignatureResource

from api.views import HomeView

urlpatterns = patterns('',
    # Examples:
    url(r'^$', HomeView.as_view(), name='home'),
    # url(r'^WeThePeopleApi/', include('WeThePeopleApi.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    
    # Example for API app
    # url(r'^objects/$', ListOrCreateModelView.as_view(resource=ObjectResource), name='object-root'),
    # url(r'^objects/(?P<id>[^/]+)/$', InstanceModelView.as_view(resource=ObjectResource), name='object'),

    # Make read-only unless admin
    #class permissions.IsUserOrIsAnonReadOnly(VIEW??)
    # Petitions and Signatures API urls
    url(r'^petitions/$', ListOrCreateModelView.as_view(resource=AllPetitionsResource), name='petitions'),
    url(r'^petitions/(?P<pid>[^/]+)/$', InstanceModelView.as_view(resource=PetitionResource), name='petition'),
    url(r'^petitions/(?P<petition>[^/]+)/signatures/$', ListOrCreateModelView.as_view(resource=SignatureResource), name='signatures'),
    url(r'^petitions/(?P<petition>[^/]+)/signatures/(?P<sig_num>[^/]+)/$', InstanceModelView.as_view(resource=SignatureResource), name='signature'),
)
Exemplo n.º 39
0
from scheduler.views import Todo
from views import *

class BackupTaskResource(ModelResource):
    model = BackupTask

class BackupsTodo(Todo):
    queryset = BackupTask.objects.all()

class TSMBackupsTodo(BackupsTodo):
    queryset = TSMBackupTask.objects.all()

class R1BackupsTodo(BackupsTodo):
    queryset = R1BackupTask.objects.all()

urlpatterns = patterns('',
    url(r'^$', ListOrCreateModelView.as_view(resource=BackupTaskResource)),
    url(r'^tsm/hosts/$', TSMHostsView.as_view(), name='tsm-hosts'), 
    url(r'^r1/todo/$', R1BackupsTodo.as_view(), name='r1-backups-todo'), 
    url(r'^todo/$', BackupsTodo.as_view(), name='backups-todo'), 
    url(r'^backupfilechecker/$', BackupFileCheckerView.as_view(), name='backup-file-checker'),
    url(r'^filesToCompress$', FilesToCompressView.as_view(), name='backup-files-to-compress'),
    url(r'^filesToDelete$', FilesToDeleteView.as_view(), name='backup-files-to-delete'),
    url(r'^addBackupFile$', add_backup_file, name="addBackupFile"),
    url(r'^BackupFileInfo$', GetBackupFileInfo.as_view(), name="BackupFileInfo"),
    url(r'^addWindowsBackupFile$', add_backup_file, { 'windows':True }, name="addWindowsBackupFile"),
    url(r'^registerFileFromChecker$', register_file_from_checker, name="register_file_from_checker"),
    url(r'^addCompressedBackupFile$', add_compressed_backup_file, name="addCompressedBackupFile"),
    url(r'^(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=BackupTaskResource)),
)
Exemplo n.º 40
0
from django.conf.urls.defaults import patterns, include, url
from djangorestframework.views import InstanceModelView, ListOrCreateModelView
from resources import CardResource

urlpatterns = patterns('',
    url(r'^cards/?$', ListOrCreateModelView.as_view(resource=CardResource), name='card_list_or_create_model_view'),
    url(r'^cards/(?P<id>\d+)/?$', InstanceModelView.as_view(resource=CardResource), name='card_instance_model_view'),
)
Exemplo n.º 41
0
from django.conf.urls.defaults import patterns, include, url
from django.conf import settings
from django.contrib import admin
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from restapi.resources import *

from views import ListOrCreateUserView

handler500 = 'mainsite.views.error500'
handler404 = 'mainsite.views.error404'


urlpatterns = patterns('',

    url(r'^player/$', ListOrCreateModelView.as_view(resource=PlayerResource), name='player_list'),
    url(r'^player/(?P<player_id>[0-9]+)/$', InstanceModelView.as_view(resource=PlayerResource)),

    url(r'^user/$', ListOrCreateUserView.as_view(), name='user_list'),
    url(r'^user/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=UserResource), name='user_detail'),

    url(r'^pieceColor/$', ListOrCreateModelView.as_view(resource=PieceColorResource), name='pieceColor_list'),
    url(r'^pieceColor/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=PieceColorResource), name='pieceColor_detail'),

    url(r'^boardSetup/$', ListOrCreateModelView.as_view(resource=BoardSetupResource), name='boardSetup_list'),
    url(r'^boardSetup/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=BoardSetupResource), name='boardSetup_detail'),

    url(r'^boardSetupColor/$', ListOrCreateModelView.as_view(resource=BoardSetupColorResource), name='boardSetupColor_list'),
    url(r'^boardSetupColor/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=BoardSetupColorResource), name='boardSetupColor_detail'),

    url(r'^game/$', ListOrCreateModelView.as_view(resource=GameResource), name='game_list'),
    url(r'^game/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=GameResource), name='game_detail'),
Exemplo n.º 42
0
from djangorestframework.resources import ModelResource
from djangorestframework.views import ListOrCreateModelView, InstanceModelView

from models import Task, TaskCheck
from views import Todo, TaskStatusView


class TaskResource(ModelResource):
    model = Task


class TaskCheckResource(ModelResource):
    model = TaskCheck


urlpatterns = patterns(
    '',
    url(r'^$', ListOrCreateModelView.as_view(resource=TaskResource)),
    url(r'^taskchecks/$',
        ListOrCreateModelView.as_view(resource=TaskCheckResource)),
    url(r'^taskstatus/$',
        TaskStatusView.as_view(), {'task': None},
        name='taskstatus'),
    url(r'^taskstatus/(?P<task>[^/]+)/$',
        TaskStatusView.as_view(),
        name='taskstatus'),
    url(r'^todo/$', Todo.as_view(), name='tasks-todo'),
    url(r'^(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=TaskCheckResource)),
)
Exemplo n.º 43
0
    model = Group

class UserForm(ModelForm):
    class Meta:
        model = User
        exclude = ('last_login', 'date_joined')

class UserResource(ModelResource):
    model = User
    form = UserForm
    
class CustomUserResource(ModelResource):
    model = CustomUser    

urlpatterns = patterns('',
    url(r'^users/$', ListOrCreateModelView.as_view(resource=UserResource), name='users'),
    url(r'^users/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=UserResource)),
    url(r'^customusers/$', ListOrCreateModelView.as_view(resource=CustomUserResource), name='customusers'),
    url(r'^customusers/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=CustomUserResource)),
    url(r'^groups/$', ListOrCreateModelView.as_view(resource=GroupResource), name='groups'),
    url(r'^groups/(?P<id>[0-9]+)/$', InstanceModelView.as_view(resource=GroupResource)),
)


class ModelViewTests(TestCase):
    """Test the model views djangorestframework provides"""
    urls = 'djangorestframework.tests.modelviews'  

    def test_creation(self):
        """Ensure that a model object can be created"""
        self.assertEqual(0, Group.objects.count())
Exemplo n.º 44
0
 def test_get_to_root(self):
     '''Simple get to the *root* url of blogposts'''
     request = self.factory.get('/blog-post')
     view = ListOrCreateModelView.as_view(resource=urls.BlogPostResource)
     response = view(request)
     self.assertEqual(response.status_code, 200)
Exemplo n.º 45
0
from django.conf.urls.defaults import *
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from convoyapp.resources import UserModelResource

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

#~ urlpatterns = patterns('',
    #~ # Example:
    #~ # (r'^convoy/', include('convoy.foo.urls')),

    #~ # Uncomment the admin/doc line below to enable admin documentation:
    #~ # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    #~ # Uncomment the next line to enable the admin:
    #~ # (r'^admin/', include(admin.site.urls)),
#~ )

urlpatterns = patterns('',
    url(r'^$',          ListOrCreateModelView.as_view(resource=UserModelResource), name='User'),
    url(r'^(?P<pk>[0-9]+)/$', InstanceModelView.as_view(resource=UserModelResource)),
)
Exemplo n.º 46
0
from django.conf.urls import patterns, include, url
from chronicle import rest # rest framework class-based views
from chronicle.views import models
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from chronicle.rest import *

urlpatterns = patterns('chronicle.views',
    url(r'^$', 'index', name='chronicle-index'),
    url(r'^(?P<item_type>\w+)/(?P<item_id>\d+)/$', 'item', name='chronicle-item'),
    url(r'^add/(?P<item_type>\w+)/$', 'add_item', name='chronicle-item-add'),
    url(r'^edit/(?P<item_type>\w+)/(?P<item_id>\d+)/$', 'edit_item', name='chronicle-item-edit'),
)

# REST Framework, urls, generate and add
rest_urls = []
import sys
module = sys.modules[__name__]
for string,model in models.iteritems():
    rest_urls.append(url(r'^rest/'+string+'/$', ListOrCreateModelView.as_view(resource=getattr(module, model.__name__ + 'Resource')),name='chronicle-rest-'+string))
    rest_urls.append(url(r'^rest/'+string+'/(?P<pk>\d+)/$', HTMLInstanceModelView.as_view(resource=getattr(module, model.__name__ + 'Resource')),name='chronicle-rest-'+string+'-instance'))

urlpatterns += patterns('', *rest_urls)

Exemplo n.º 47
0
    url(r'^admin/send_unpaid_reports$',
        'husky.views.send_unpaid_reports',
        name='send_unpaid_reports'),
    url(r'^admin/send_unpaid_reminders/*(?P<type>[\w]*)/*(?P<donation_id>[\d]*)$',
        'husky.views.send_unpaid_reminders',
        name='send_unpaid_reminders'),

    # admin
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),

    # REST API
    url(r'^REST/api-auth/',
        include('djangorestframework.urls', namespace='djangorestframework')),
    url(r'^REST/teacher/$',
        ListOrCreateModelView.as_view(resource=TeacherResource)),
    url(r'^REST/teacher/(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=TeacherResource)),
    url(r'^REST/grade/$',
        ListOrCreateModelView.as_view(resource=GradeResource)),
    url(r'^REST/grade/(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=GradeResource)),
    url(r'^REST/parent/$',
        ListOrCreateModelView.as_view(resource=ParentResource)),
    url(r'^REST/parent/(?P<pk>[^/]+)/$',
        InstanceModelView.as_view(resource=ParentResource)),
    url(r'^REST/children/$',
        ListOrCreateModelView.as_view(resource=ChildrenResource)),
    url(r'^REST/children/(?P<identifier>[^/]+)/$',
        InstanceModelView.as_view(resource=ChildrenResource)),
    url(r'^REST/donation/$',
Exemplo n.º 48
0
#from django.conf.urls.defaults import *
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView, ModelView, ListModelView
from contacts.resources import TestResource, AddressResource

from views import *
from django.conf import settings
import django.contrib.auth.views


urlpatterns = patterns('djangoextension.contacts.views',
    url(r'address/create/$', "root_view", name='root'),
    url(r'address/$', "list_view", name='list'),
    #url(r'address/query/(?P<query>[^/]+/$)', "query_view", name='query'),
    #url(r'address/.*$)', "query_view", name='query'),
    )

urlpatterns += patterns('',
    url(r'test/$', ListOrCreateModelView.as_view(resource=TestResource), name='test-root'),
    url(r'test/(?P<id>[^/]+)/$', InstanceModelView.as_view(resource=TestResource), name='test-post'),
    url(r'address/api/$', ListModelView.as_view(resource=AddressResource), name='address-root'),
    url(r'address/api/(?P<id>[^/]+)/$', InstanceModelView.as_view(resource=AddressResource), name='address-post'),

)

Exemplo n.º 49
0
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from modelresourceexample.resources import MyModelResource

urlpatterns = patterns(
    '',
    url(r'^$',
        ListOrCreateModelView.as_view(resource=MyModelResource),
        name='model-resource-root'),
    url(r'^(?P<pk>[0-9]+)/$',
        InstanceModelView.as_view(resource=MyModelResource)),
)