poulpe/api/urls.py

28 lines
1.2 KiB
Python
Raw Normal View History

2017-07-18 17:48:59 +02:00
from django.conf.urls import url, include
2017-07-21 17:03:33 +02:00
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
2017-07-20 15:08:19 +02:00
from api.event.views import EventViewSet, PlaceViewSet, ActivityTagViewSet,\
ActivityTemplateViewSet
2017-07-18 17:48:59 +02:00
# Create a router and register our viewsets with it.
2017-07-21 17:03:33 +02:00
router = SimpleRouter()
2017-07-23 16:06:52 +02:00
router.register(r'event', EventViewSet, 'event')
2017-07-23 18:23:02 +02:00
router.register(r'place', PlaceViewSet, 'place')
router.register(r'activitytag', ActivityTagViewSet, 'activitytag')
2017-07-18 17:48:59 +02:00
2017-07-21 17:03:33 +02:00
# Register nested router and register someviewsets vith it
event_router = NestedSimpleRouter(router, r'event', lookup='event')
2017-07-23 18:23:02 +02:00
event_router.register(r'place', PlaceViewSet, base_name='event-place')
event_router.register(r'tag', ActivityTagViewSet, base_name='event-activitytag')
2017-07-22 03:12:50 +02:00
event_router.register(r'activitytemplate', ActivityTemplateViewSet,
2017-07-23 18:23:02 +02:00
base_name='event-activitytemplate')
2017-07-21 17:03:33 +02:00
2017-07-18 17:48:59 +02:00
# The API URLs are now determined automatically by the router.
# Additionally, we include the login URLs for the browsable API.
urlpatterns = [
url(r'^', include(router.urls)),
2017-07-21 17:03:33 +02:00
url(r'^', include(event_router.urls)),
2017-07-18 17:48:59 +02:00
url(r'^api-auth/', include('rest_framework.urls',
namespace='rest_framework'))
]