コード例 #1
0
class TestNestedSimpleRouter(TestCase):
    def setUp(self):
        self.router = SimpleRouter()
        self.router.register(r'a', AViewSet)
        self.a_router = NestedSimpleRouter(self.router, r'a', lookup='a')
        self.a_router.register(r'b', BViewSet)
        self.b_router = NestedSimpleRouter(self.a_router, r'b', lookup='b')
        self.b_router.register(r'c', CViewSet)

    def test_recursive_nested_simple_routers(self):
        self.assertFalse(hasattr(self.router, 'parent_regex'))
        urls = self.router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(urls[0].regex.pattern, u'^a/$')
        self.assertEquals(urls[1].regex.pattern, u'^a/(?P<pk>[0-9a-f]{32})/$')

        self.assertEqual(self.a_router.parent_regex, u'a/(?P<a_pk>[0-9a-f]{32})/')
        urls = self.a_router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(urls[0].regex.pattern, u'^a/(?P<a_pk>[0-9a-f]{32})/b/$')
        self.assertEquals(urls[1].regex.pattern, u'^a/(?P<a_pk>[0-9a-f]{32})/b/(?P<pk>[^/.]+)/$')

        self.assertEqual(self.b_router.parent_regex, u'a/(?P<a_pk>[0-9a-f]{32})/b/(?P<b_pk>[^/.]+)/')
        urls = self.b_router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(urls[0].regex.pattern, u'^a/(?P<a_pk>[0-9a-f]{32})/b/(?P<b_pk>[^/.]+)/c/$')
        self.assertEquals(urls[1].regex.pattern, u'^a/(?P<a_pk>[0-9a-f]{32})/b/(?P<b_pk>[^/.]+)/c/(?P<pk>[^/.]+)/$')
コード例 #2
0
ファイル: test_routers.py プロジェクト: vinay13/geo_django
class TestNestedSimpleRouter(TestCase):
    def setUp(self):
        self.router = SimpleRouter()
        self.router.register(r'a', AViewSet)
        self.a_router = NestedSimpleRouter(self.router, r'a', lookup='a')
        self.a_router.register(r'b', BViewSet)
        self.b_router = NestedSimpleRouter(self.a_router, r'b', lookup='b')
        self.b_router.register(r'c', CViewSet)

    def test_recursive_nested_simple_routers(self):
        self.assertFalse(hasattr(self.router, 'parent_regex'))
        urls = self.router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(urls[0].regex.pattern, u'^a/$')
        self.assertEquals(urls[1].regex.pattern, u'^a/(?P<pk>[0-9a-f]{32})/$')

        self.assertEqual(self.a_router.parent_regex,
                         u'a/(?P<a_pk>[0-9a-f]{32})/')
        urls = self.a_router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(urls[0].regex.pattern,
                          u'^a/(?P<a_pk>[0-9a-f]{32})/b/$')
        self.assertEquals(urls[1].regex.pattern,
                          u'^a/(?P<a_pk>[0-9a-f]{32})/b/(?P<pk>[^/.]+)/$')

        self.assertEqual(self.b_router.parent_regex,
                         u'a/(?P<a_pk>[0-9a-f]{32})/b/(?P<b_pk>[^/.]+)/')
        urls = self.b_router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(urls[0].regex.pattern,
                          u'^a/(?P<a_pk>[0-9a-f]{32})/b/(?P<b_pk>[^/.]+)/c/$')
        self.assertEquals(
            urls[1].regex.pattern,
            u'^a/(?P<a_pk>[0-9a-f]{32})/b/(?P<b_pk>[^/.]+)/c/(?P<pk>[^/.]+)/$')
コード例 #3
0
    def test_explicit_no_trailing_slash(self):
        router = SimpleRouter(trailing_slash=True)
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router, 'a', lookup='a', trailing_slash=False)
        a_router.register('b', BViewSet)

        self._assertDoesNotHaveTrailingSlash(a_router)
コード例 #4
0
    class TestNestedSimpleRouter(TestCase):
        def setUp(self):
            self.router = SimpleRouter()
            self.router.register(r'detail', DetailRouteViewSet)
            self.detail_router = NestedSimpleRouter(
                self.router,
                r'detail',
                lookup='detail'
            )
            self.detail_router.register(r'list', ListRouteViewSet)
            self.list_router = NestedSimpleRouter(
                self.detail_router,
                r'list',
                lookup='list'
            )

        def test_dynamic_routes(self):
            self.assertFalse(hasattr(self.router, 'parent_regex'))
            urls = map_by_name(self.router.urls)
            self.assertEquals(
                get_regex_pattern(urls['basicmodel-list']), u'^detail/$'
            )
            self.assertEquals(
                get_regex_pattern(urls['basicmodel-detail']),
                u'^detail/(?P<pk>[^/.]+)/$'
            )
            self.assertEquals(
                get_regex_pattern(urls['basicmodel-set-password']),
                u'^detail/(?P<pk>[^/.]+)/set_password/$'
            )

        def test_nested_parent(self):
            self.assertEqual(
                self.detail_router.parent_regex,
                u'detail/(?P<detail_pk>[^/.]+)/'
            )
            urls = map_by_name(self.detail_router.urls)

            self.assertEquals(
                get_regex_pattern(urls['basicmodel-list']),
                u'^detail/(?P<detail_pk>[^/.]+)/list/$'
            )

            self.assertEquals(
                get_regex_pattern(urls['basicmodel-recent-users']),
                u'^detail/(?P<detail_pk>[^/.]+)/list/recent_users/$'
            )

            self.assertEquals(
                get_regex_pattern(urls['basicmodel-detail']),
                u'^detail/(?P<detail_pk>[^/.]+)/list/(?P<pk>[^/.]+)/$'
            )

        def test_nested_child(self):
            self.assertEqual(
                self.list_router.parent_regex,
                u'detail/(?P<detail_pk>[^/.]+)/list/(?P<list_pk>[^/.]+)/'
            )
コード例 #5
0
    class TestNestedSimpleRouter(TestCase):
        def setUp(self):
            self.router = SimpleRouter()
            self.router.register(r'detail', DetailRouteViewSet)
            self.detail_router = NestedSimpleRouter(
                self.router,
                r'detail',
                lookup='detail'
            )
            self.detail_router.register(r'list', ListRouteViewSet)
            self.list_router = NestedSimpleRouter(
                self.detail_router,
                r'list',
                lookup='list'
            )

        def test_dynamic_routes(self):
            self.assertFalse(hasattr(self.router, 'parent_regex'))
            urls = map_by_name(self.router.urls)
            self.assertEquals(
                get_regex_pattern(urls['basicmodel-list']), u'^detail/$'
            )
            self.assertEquals(
                get_regex_pattern(urls['basicmodel-detail']),
                u'^detail/(?P<pk>[^/.]+)/$'
            )
            self.assertEquals(
                get_regex_pattern(urls['basicmodel-set-password']),
                u'^detail/(?P<pk>[^/.]+)/set_password/$'
            )

        def test_nested_parent(self):
            self.assertEqual(
                self.detail_router.parent_regex,
                u'detail/(?P<detail_pk>[^/.]+)/'
            )
            urls = map_by_name(self.detail_router.urls)

            self.assertEquals(
                get_regex_pattern(urls['basicmodel-list']),
                u'^detail/(?P<detail_pk>[^/.]+)/list/$'
            )

            self.assertEquals(
                get_regex_pattern(urls['basicmodel-recent-users']),
                u'^detail/(?P<detail_pk>[^/.]+)/list/recent_users/$'
            )

            self.assertEquals(
                get_regex_pattern(urls['basicmodel-detail']),
                u'^detail/(?P<detail_pk>[^/.]+)/list/(?P<pk>[^/.]+)/$'
            )

        def test_nested_child(self):
            self.assertEqual(
                self.list_router.parent_regex,
                u'detail/(?P<detail_pk>[^/.]+)/list/(?P<list_pk>[^/.]+)/'
            )
コード例 #6
0
class TestBadLookupValue(TestCase):
    def setUp(self):
        self.router = SimpleRouter()
        self.router.register(r'parents', AViewSet, base_name='ui-parent_1')

    def test_bad_lookup(self):
        with self.assertRaises(ValueError):
            self.a_router = NestedSimpleRouter(self.router, r'parents', lookup='ui-parent_2')
            self.a_router.register(r'child', BViewSet, base_name='ui-parent-child')
コード例 #7
0
class TestBadLookupValue(TestCase):
    def setUp(self):
        self.router = SimpleRouter()
        self.router.register(r'parents', AViewSet, base_name='ui-parent_1')

    def test_bad_lookup(self):
        with self.assertRaises(ValueError):
            self.a_router = NestedSimpleRouter(self.router, r'parents', lookup='ui-parent_2')
            self.a_router.register(r'child', BViewSet, base_name='ui-parent-child')
コード例 #8
0
    def test_explicit_no_trailing_slash(self):
        router = SimpleRouter(trailing_slash=True)
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router,
                                      'a',
                                      lookup='a',
                                      trailing_slash=False)
        a_router.register('b', BViewSet)

        self._assertDoesNotHaveTrailingSlash(a_router)
コード例 #9
0
    def test_explicit_trailing_slash(self):
        """
        Test whether the trailing_slash=False value is properly overridden when setting
        trailing_slash=True on the nested router.
        """
        router = SimpleRouter(trailing_slash=False)
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router, 'a', lookup='a', trailing_slash=True)
        a_router.register('b', BViewSet)

        self._assertHasTrailingSlash(a_router)
コード例 #10
0
    def test_inherits_trailing_slash(self):
        """
        Test whether the trailing_slash=False value is inherited when it
        is unspecified on the nested router.
        """
        router = SimpleRouter(trailing_slash=True)
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router, 'a', lookup='a')
        a_router.register('b', BViewSet)

        self._assertHasTrailingSlash(a_router)
コード例 #11
0
    def test_inherits_trailing_slash(self):
        """
        Test whether the trailing_slash=False value is inherited when it
        is unspecified on the nested router.
        """
        router = SimpleRouter(trailing_slash=True)
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router, 'a', lookup='a')
        a_router.register('b', BViewSet)

        self._assertHasTrailingSlash(a_router)
コード例 #12
0
class TestEmptyPrefix(TestCase):
    def setUp(self):
        self.router = SimpleRouter()
        self.router.register(r'', AViewSet)
        self.a_router = NestedSimpleRouter(self.router, r'', lookup='a')
        self.a_router.register(r'b', BViewSet)

    def test_empty_prefix(self):
        urls = self.router.urls
        urls = self.a_router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(get_regex_pattern(urls[0]), u'^(?P<a_pk>[0-9a-f]{32})/b/$')
        self.assertEquals(get_regex_pattern(urls[1]), u'^(?P<a_pk>[0-9a-f]{32})/b/(?P<pk>[^/.]+)/$')
コード例 #13
0
class TestEmptyPrefix(TestCase):
    def setUp(self):
        self.router = SimpleRouter()
        self.router.register(r'', AViewSet)
        self.a_router = NestedSimpleRouter(self.router, r'', lookup='a')
        self.a_router.register(r'b', BViewSet)

    def test_empty_prefix(self):
        urls = self.router.urls
        urls = self.a_router.urls
        self.assertEquals(len(urls), 2)
        self.assertEquals(get_regex_pattern(urls[0]), u'^(?P<a_pk>[0-9a-f]{32})/b/$')
        self.assertEquals(get_regex_pattern(urls[1]), u'^(?P<a_pk>[0-9a-f]{32})/b/(?P<pk>[^/.]+)/$')
コード例 #14
0
    def test_explicit_trailing_slash(self):
        """
        Test whether the trailing_slash=False value is properly overridden when setting
        trailing_slash=True on the nested router.
        """
        router = SimpleRouter(trailing_slash=False)
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router,
                                      'a',
                                      lookup='a',
                                      trailing_slash=True)
        a_router.register('b', BViewSet)

        self._assertHasTrailingSlash(a_router)
コード例 #15
0
    def test_inherits_nonstandard_trailing_slash(self):
        """
        Test whether the trailing_slash attribute, when set with a custom value,
        is inherited by the nested routed.
        """
        router = SimpleRouter()
        router.trailing_slash = '/?'
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router, 'a', lookup='a')
        a_router.register('b', BViewSet)

        self.assertEqual(a_router.trailing_slash, u'/?', "router does not have trailing slash when it should")
        self.assertTrue(pattern_from_url(a_router.urls[0]).endswith('/?$'),
                        "router created url without trailing slash when it should have")
コード例 #16
0
    def test_inherits_nonstandard_trailing_slash(self):
        """
        Test whether the trailing_slash attribute, when set with a custom value,
        is inherited by the nested routed.
        """
        router = SimpleRouter()
        router.trailing_slash = '/?'
        router.register('a', AViewSet)
        a_router = NestedSimpleRouter(router, 'a', lookup='a')
        a_router.register('b', BViewSet)

        self.assertEqual(a_router.trailing_slash, u'/?',
                         "router does not have trailing slash when it should")
        self.assertTrue(
            pattern_from_url(a_router.urls[0]).endswith('/?$'),
            "router created url without trailing slash when it should have")
コード例 #17
0
ファイル: urls.py プロジェクト: fossabot/one-manager
from django.conf.urls import url, include
from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter
from school.views import SchoolViewSet
from classes.views import ClassesViewSet, SemesterViewSet
from school.views import SchoolViewSet, SchoolClassesViewSet, SchoolClassesSemesterViewSet
from student.views import StudentViewSet

root_router = DefaultRouter()
root_router.register('school', SchoolViewSet, 'school')

school_router = SimpleRouter()
school_router.register('school', SchoolViewSet, base_name='list-school')
school_classes_router = NestedSimpleRouter(school_router,
                                           'school',
                                           lookup='school')
school_classes_router.register('classes',
                               SchoolClassesViewSet,
                               base_name='list-school-classes')
school_classes_semester_router = NestedSimpleRouter(school_classes_router,
                                                    'classes',
                                                    lookup='classes')
school_classes_semester_router.register(
    'semester',
    SchoolClassesSemesterViewSet,
    base_name='list-school-classes-semester')
school_classes_student_router = NestedSimpleRouter(school_classes_router,
                                                   'classes',
                                                   lookup='classes')
school_classes_student_router.register('student',
                                       StudentViewSet,
                                       base_name='list-school-classes-student')
コード例 #18
0
ファイル: urls.py プロジェクト: MirabbosMirzakhmedov/mroom
        'viewset': AppointmentViewSet,
        'basename': 'appointment'
    },
    {
        'prefix': r'api/barber',
        'viewset': BarberViewSet,
        'basename': 'barber'
    }
]

router = SimpleRouter()

for viewset in viewsets:
    router.register(
        prefix=viewset['prefix'],
        viewset=viewset['viewset'],
        basename=viewset['basename']
    )

urlpatterns = [
    path('api/signup/', signup),
    path('api/signin/', signin),
    path('api/signout/', signout),
]

if settings.DEBUG:
    urlpatterns.append(
        path('__debug__/', include(debug_toolbar.urls))
    )

urlpatterns = urlpatterns + router.urls
コード例 #19
0
ファイル: api.py プロジェクト: MatMoore/practice-app
from rest_framework.response import Response
from django.conf.urls import patterns, include, url

class ActivityViewSet(viewsets.ModelViewSet):
    queryset = Activity.objects.all()
    serializer_class = ActivitySerializer

class UserActivityViewSet(viewsets.ReadOnlyModelViewSet):
    lookup_field = 'activity_id'
    queryset = UserActivity.objects.all()
    serializer_class = UserActivitySerializer

class CheckinViewSet(viewsets.ViewSet):
    def create(self, request, activity_activity_id):
        ua, created = UserActivity.objects.get_or_create(activity_id=activity_activity_id)
        ua.checkin()
        serializer = UserActivitySerializer(ua)
        return Response(serializer.data)

router = SimpleRouter()
router.register(r'activities', ActivityViewSet)
router.register(r'users/123/activities', UserActivityViewSet)

activity_router = NestedSimpleRouter(router, r'users/123/activities', lookup='activity')
activity_router.register(r'checkins', CheckinViewSet, 'checkin')

urlpatterns = patterns('',
    url(r'^', include(router.urls)),
    url(r'^', include(activity_router.urls)),
)
コード例 #20
0
ファイル: urls.py プロジェクト: Pillin/tot_test
# -*- coding: utf-8 -*-
from rest_framework_nested.routers import SimpleRouter

# Custom
from .views import TaskViewSet


router = SimpleRouter()
router.register(r'tasks', TaskViewSet, 'task')
コード例 #21
0
from django.conf.urls import url, include
from django.contrib.staticfiles.views import serve

from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter

from maps.views import MapViewSet, MapFeaturesViewSet

router = SimpleRouter()
router.register('maps', MapViewSet, 'maps')
router.register('features', MapFeaturesViewSet, 'features')



urlpatterns = [
    url(r'^api/', include(router.urls)),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^static/(?P<path>.*)$', serve)
]
コード例 #22
0
ファイル: urls.py プロジェクト: kucuny/one-manager
from django.conf.urls import url, include
from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter
from school.views import SchoolViewSet
from classes.views import ClassesViewSet, SemesterViewSet
from school.views import SchoolViewSet, SchoolClassesViewSet, SchoolClassesSemesterViewSet
from student.views import StudentViewSet

root_router = DefaultRouter()
root_router.register('school', SchoolViewSet, 'school')

school_router = SimpleRouter()
school_router.register('school', SchoolViewSet, base_name='list-school')
school_classes_router = NestedSimpleRouter(school_router, 'school', lookup='school')
school_classes_router.register('classes', SchoolClassesViewSet, base_name='list-school-classes')
school_classes_semester_router = NestedSimpleRouter(school_classes_router, 'classes', lookup='classes')
school_classes_semester_router.register('semester', SchoolClassesSemesterViewSet,
                                        base_name='list-school-classes-semester')
school_classes_student_router = NestedSimpleRouter(school_classes_router, 'classes', lookup='classes')
school_classes_student_router.register('student', StudentViewSet, base_name='list-school-classes-student')

urlpatterns = [
    url(r'', include(root_router.urls)),
    url(r'list/', include(school_router.urls)),
    url(r'list/', include(school_classes_router.urls)),
    url(r'list/', include(school_classes_semester_router.urls)),
    url(r'list/', include(school_classes_student_router.urls)),
]
コード例 #23
0
ファイル: urls.py プロジェクト: Pillin/tot_test
# -*- coding: utf-8 -*-
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter

# Custom
from .views import TaskListViewSet
from tasks.views import TaskViewSet


router = SimpleRouter()
router.register(r'list-tasks', TaskListViewSet, 'tasklist')


# For nested url
task_router = NestedSimpleRouter(router, r'list-tasks', lookup='tasklist')
task_router.register(r'tasks', TaskViewSet, 'task')
コード例 #24
0
ファイル: api.py プロジェクト: MatMoore/practice-app
class UserActivityViewSet(viewsets.ReadOnlyModelViewSet):
    lookup_field = 'activity_id'
    queryset = UserActivity.objects.all()
    serializer_class = UserActivitySerializer


class CheckinViewSet(viewsets.ViewSet):
    def create(self, request, activity_activity_id):
        ua, created = UserActivity.objects.get_or_create(
            activity_id=activity_activity_id)
        ua.checkin()
        serializer = UserActivitySerializer(ua)
        return Response(serializer.data)


router = SimpleRouter()
router.register(r'activities', ActivityViewSet)
router.register(r'users/123/activities', UserActivityViewSet)

activity_router = NestedSimpleRouter(router,
                                     r'users/123/activities',
                                     lookup='activity')
activity_router.register(r'checkins', CheckinViewSet, 'checkin')

urlpatterns = patterns(
    '',
    url(r'^', include(router.urls)),
    url(r'^', include(activity_router.urls)),
)
コード例 #25
0
from django.urls import path
from rest_framework_nested.routers import SimpleRouter
from rest_framework_nested.routers import NestedSimpleRouter

from discussion_board.views import UserViewSet
from discussion_board.views import EntityViewSet
from discussion_board.views import ThreadViewSet
from discussion_board.views import MessageViewSet
from discussion_board.views import EntityThreadViewSet
from discussion_board.views import UserThreadViewSet
from discussion_board.views import UserOwnedThreadViewSet
from discussion_board.views import UserMessageViewSet
from discussion_board.views import ThreadMessageViewSet

drf_api = SimpleRouter()
drf_api.register('users', UserViewSet)
drf_api.register('entities', EntityViewSet)
drf_api.register('threads', ThreadViewSet)
drf_api.register('messages', MessageViewSet)

entity_router = NestedSimpleRouter(drf_api, 'entities', lookup='entity')
entity_router.register('threads',
                       EntityThreadViewSet,
                       base_name='entity-threads')

user_router = NestedSimpleRouter(drf_api, 'users', lookup='user')
user_router.register('threads', UserThreadViewSet, base_name='user-threads')
user_router.register('owned_threads',
                     UserOwnedThreadViewSet,
                     base_name='user-owned-threads')
user_router.register('messages', UserMessageViewSet, base_name='user-messages')
コード例 #26
0
ファイル: urls.py プロジェクト: hungdng/djang_skeleton
from django.conf.urls import url
from django.urls import include, path
from rest_framework_nested.routers import (DefaultRouter, SimpleRouter)

from .views import UserViewSet

router = SimpleRouter(trailing_slash=False)
router.register(r'', UserViewSet)

urlpatterns = [
    path('', include(router.urls)),
    # path('registration', RegistrationViewSet.as_view(
    #     {'post': 'create_user'}), name='registration'),
    # path('login', LoginViewSet.as_view({'post': 'login'}), name='login'),
]
コード例 #27
0
from django.urls import include, path, re_path
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
from django.views.generic.base import TemplateView

from .views import (
    CheckAuthenticatedView,
    GetCSRFToken,
    index,
    LoginView,
    # mealQueries,
    MealViewSet,
    MenuViewSet,
)

router = SimpleRouter()
router.register(r'menus', MenuViewSet, basename="menus")

menu_router = NestedSimpleRouter(router, r'menus', lookup='menu')
menu_router.register(r'meals', MealViewSet, basename='menu-meals')

urlpatterns = [
    path('api/', include(router.urls)),
    path('api/', include(menu_router.urls)),
    path('api/login/', LoginView.as_view(), name='login'),
    path('api/authenticated/',
         CheckAuthenticatedView.as_view(),
         name='authenticated'),
    path("", index, name='index'),
    path('csrf_cookie/', GetCSRFToken.as_view()),
    # path('matches/', mealQueries.as_view()),
]
コード例 #28
0
from django.conf.urls import url, include
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
from accounts.views import UserViewSet, UserProfileViewSet, UserContactViewSet


user_router = SimpleRouter()
user_router.register('user', UserViewSet, base_name='user')
user_profile_router = NestedSimpleRouter(user_router, 'user', lookup='user')
user_profile_router.register('profile', UserProfileViewSet, base_name='user-profile')
user_contact_router = NestedSimpleRouter(user_router, 'user', lookup='user')
user_contact_router.register('contact', UserContactViewSet, base_name='user-contact')

urlpatterns = [
    url(r'', include(user_router.urls)),
    url(r'', include(user_profile_router.urls)),
    url(r'', include(user_contact_router.urls)),
]
コード例 #29
0
from django.conf.urls import url, include
from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter
from score.views import ScoreViewSet, ScoreDataViewSet

root_router = DefaultRouter()
root_router.register('score', ScoreViewSet, 'score')
root_router.register('score-data', ScoreDataViewSet, 'score-data')

score_router = SimpleRouter()
score_router.register('score', ScoreViewSet, base_name='list-score')
score_data_router = NestedSimpleRouter(score_router, 'score', lookup='score')
score_data_router.register('data',
                           ScoreDataViewSet,
                           base_name='list-score-data')

urlpatterns = [
    url(r'', include(root_router.urls)),
    url(r'list/', include(score_router.urls)),
    url(r'list/', include(score_data_router.urls)),
]
コード例 #30
0
from django.urls import path, include
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
from collector import views

performance_router = SimpleRouter()
performance_router.register(r'performance', views.ServerInfoViewSet)

blackdb_router = SimpleRouter()
blackdb_router.register(r'blackdb', views.BlackDBPayloadViewSet)

info_router = NestedSimpleRouter(performance_router,
                                 r'performance',
                                 lookup='performance')
info_router.register(r'cpu', views.CpuPerformanceViewSet)
info_router.register(r'memory', views.MemoryPerformanceViewSet)
info_router.register(r'disk', views.DiskPerformanceViewSet)

# The API URLs are now determined automatically by the router.
urlpatterns = [
    path('', include(performance_router.urls)),
    path('', include(blackdb_router.urls)),
    path('', include(info_router.urls))
]
コード例 #31
0
ファイル: urls.py プロジェクト: Pillin/tot_test
# -*- coding: utf-8 -*-
from django.conf.urls import url
from rest_framework_nested.routers import SimpleRouter

# Custom
from .views import UserViewSet, SignUpView


router = SimpleRouter()
router.register(r'users', UserViewSet)


urls = [
    url(r'^users/sign_up/$', SignUpView.as_view(), name="sign-up"),
]

urls += router.urls
コード例 #32
0
ファイル: urls.py プロジェクト: iDrDex/hitcharide-api
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter

from apps.accounts.viewsets import UserDetailViewSet
from apps.cars.viewsets import CarViewSet, CarImageViewSet
from apps.places.viewsets import StateViewSet, CityViewSet, PlaceViewSet
from apps.accounts.views import MyView, SendPhoneValidationCodeView,\
    ValidatePhoneView, complete
from apps.rides.viewsets import RideViewSet, \
    RideBookingViewSet, RideRequestViewSet, RideComplaintViewSet
from apps.reviews.viewsets import ReviewViewSet
from apps.flatpages.viewsets import FlatPageViewSet

from .routers import Router

nested_router = SimpleRouter()
nested_router.register('rides/car', CarViewSet, base_name='cars')

car_router = NestedSimpleRouter(nested_router, r'rides/car', lookup='car')
car_router.register('images', CarImageViewSet)

router = Router()
router.register('places/state', StateViewSet)
router.register('places/city', CityViewSet)
router.register('places/place', PlaceViewSet)

router.register('rides/ride', RideViewSet)
router.register('rides/booking', RideBookingViewSet)
router.register('rides/request', RideRequestViewSet)
router.register('rides/complaint', RideComplaintViewSet)
router.register('accounts', UserDetailViewSet)
router.register('reviews', ReviewViewSet)
コード例 #33
0
ファイル: urls.py プロジェクト: ziaurjoy/Basic-API
from django.contrib import admin
from django.urls import path, include
from rest_framework.authtoken.views import obtain_auth_token
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
from restaurent.views import RestaurantViewSet, FoodItemViewSet

api_router = SimpleRouter(trailing_slash=False)
api_router.register('restaurant', RestaurantViewSet, basename='restaurant')

restaurant_router = NestedSimpleRouter(api_router,
                                       'restaurant',
                                       lookup='restaurant')
restaurant_router.register('food_items', FoodItemViewSet, basename='food_item')

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/', include(api_router.urls)),
    path('api/v1/', include(restaurant_router.urls)),
    path('api/v1/token', obtain_auth_token),
]
コード例 #34
0
ファイル: urls.py プロジェクト: FengcunLi/Lutan-backend
from django.urls import path
from rest_framework_nested.routers import SimpleRouter

from categories.views import CategoryTreeView, CategoryViewSet

router = SimpleRouter()
router.register('categories', CategoryViewSet)

urlpatterns = router.urls + [
    path('categories/tree/<int:pk>', CategoryTreeView.as_view())
]
コード例 #35
0
ファイル: urls.py プロジェクト: kucuny/one-manager
from django.conf.urls import url, include
from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter
from score.views import ScoreViewSet, ScoreDataViewSet

root_router = DefaultRouter()
root_router.register('score', ScoreViewSet, 'score')
root_router.register('score-data', ScoreDataViewSet, 'score-data')

score_router = SimpleRouter()
score_router.register('score', ScoreViewSet, base_name='list-score')
score_data_router = NestedSimpleRouter(score_router, 'score', lookup='score')
score_data_router.register('data', ScoreDataViewSet, base_name='list-score-data')

urlpatterns = [
    url(r'', include(root_router.urls)),
    url(r'list/', include(score_router.urls)),
    url(r'list/', include(score_data_router.urls)),
]
コード例 #36
0
from django.urls import path, include
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
from .views import *

router = SimpleRouter()
router.register('users', UserViewSet)
router.register('contacts', ContactViewSet, basename='contacts')
router.register('chats', ChatViewSet, basename='chats')

message_router = NestedSimpleRouter(router, 'chats', lookup='chat')
message_router.register('messages', MessageViewSet, basename='messages')


urlpatterns = [
	path('', include(router.urls)),
	path('', include(message_router.urls)),
]
コード例 #37
0
ファイル: urls.py プロジェクト: jtmitchell/mymovie
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter

from .views import MovieViewSet, WatchlistViewSet, NotificationViewSet

router = SimpleRouter(trailing_slash=False)
router.include_format_suffixes = False
router.register(r'v1/movies', MovieViewSet, base_name='movie')
router.register(r'v1/watchlists', WatchlistViewSet, base_name='watchlist')

# register the nested urls for movie routes
wl_router = NestedSimpleRouter(router, r'v1/watchlists',
                               lookup='watchlist', trailing_slash=False)
wl_router.register(r'notifications', NotificationViewSet,
                   base_name='notification')

urlpatterns = patterns('',
                       url(r'', include(router.urls, namespace='movie')),
                       url(r'', include(wl_router.urls, namespace='movie')),
                       )
コード例 #38
0
from django.urls import include, path
from rest_framework_nested.routers import NestedSimpleRouter, SimpleRouter

from . import viewsets

tests_router = SimpleRouter()
tests_router.register('tests', viewsets.TestsViewSet, base_name='tests')

questions_router = NestedSimpleRouter(tests_router, 'tests', lookup='test')
questions_router.register('questions',
                          viewsets.QuestionsViewSet,
                          base_name='questions')

answers_router = NestedSimpleRouter(questions_router,
                                    'questions',
                                    lookup='question')
answers_router.register('answers',
                        viewsets.AnswersViewSet,
                        base_name='answers')

urlpatterns = [
    path('', include(tests_router.get_urls())),
    path('', include(questions_router.get_urls())),
    path('', include(answers_router.get_urls())),
]
コード例 #39
0
ファイル: urls.py プロジェクト: sanpj2292/project-task-app
from .views import ProjectViewset, TasksViewset, UserViewset, get_image_data
from rest_framework_nested.routers import NestedSimpleRouter, SimpleRouter
from django.urls import path, include

parent_router = SimpleRouter()
user_router = SimpleRouter()

parent_router.register('project', ProjectViewset)
user_router.register('user', UserViewset)

prj_router = NestedSimpleRouter(parent_router, r'project', lookup='project')
prj_router.register('task', TasksViewset, basename='project-tasks')

urlpatterns = [
    path('', include(parent_router.urls)),
    path('', include(prj_router.urls)),
    path('', include(user_router.urls)),
    path('image/', get_image_data),
]
コード例 #40
0
ファイル: urls.py プロジェクト: sdob/dsapi
"""
from django.conf.urls import include, url
from django.contrib import admin

from rest_framework.authtoken import views as authtoken_views
#from rest_framework.routers import DefaultRouter
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
import comments.views
import divesites.views
import images.views
import profiles.views
import sitestatistics.views
from authviews.views import FacebookLogin, GoogleLogin

router = SimpleRouter()
router.register(r'comments/compressors', comments.views.CompressorCommentViewSet)
router.register(r'comments/divesites', comments.views.DivesiteCommentViewSet)
router.register(r'comments/slipways', comments.views.SlipwayCommentViewSet)

router.register(r'compressors', divesites.views.CompressorViewSet, base_name='compressor')
router.register(r'divesites', divesites.views.DivesiteViewSet, base_name='divesite')
router.register(r'dives', divesites.views.DiveViewSet)
router.register(r'slipways', divesites.views.SlipwayViewSet, base_name='slipway')
router.register(r'users', profiles.views.ProfileViewSet, base_name='profile')

compressors_router = NestedSimpleRouter(router, r'compressors', lookup='compressor')
compressors_router.register(r'images', images.views.ImageViewSet, base_name='compressor-image')

divesites_router = NestedSimpleRouter(router, r'divesites', lookup='divesite')
divesites_router.register(r'images', images.views.ImageViewSet, base_name='divesite-image')
コード例 #41
0
from django.conf.urls import url, include
from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter
from classes.views import ClassesViewSet, SemesterViewSet
from classes.views import ClassesSemesterViewSet
from student.views import ClassesStudentViewSet

root_router = DefaultRouter()
root_router.register('classes', ClassesViewSet, 'classes')
root_router.register('semester', SemesterViewSet, 'semester')

classes_router = SimpleRouter()
classes_router.register('classes', ClassesViewSet, base_name='list-classes')
classes_semester_router = NestedSimpleRouter(classes_router, 'classes', lookup='classes')
classes_semester_router.register('semester', ClassesSemesterViewSet, base_name='list-classes-semester')
classes_student_router = NestedSimpleRouter(classes_router, 'classes', lookup='classes')
classes_student_router.register('student', ClassesStudentViewSet, base_name='list-classes-student')

urlpatterns = [
    url(r'', include(root_router.urls)),
    url(r'list/', include(classes_router.urls)),
    url(r'list/', include(classes_semester_router.urls)),
    url(r'list/', include(classes_student_router.urls)),
]