fc4930a49e
Event-based urls - Add viewset mixin 'EventUrlViewSetMixin' to get the event from the 'event_pk' url kwarg of a view. - Add url serializer fields for object which can be accessed with a root-level and/or event-specific url ('EventHyperlinked*Field). Update viewsets and serializers to use these + clean inheritance viewsets.
26 lines
825 B
Python
26 lines
825 B
Python
from django.conf.urls import url, include
|
|
|
|
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
|
|
|
|
from api.event import views
|
|
|
|
|
|
router = SimpleRouter()
|
|
router.register(r'event', views.EventViewSet)
|
|
router.register(r'place', views.PlaceViewSet)
|
|
router.register(r'tag', views.ActivityTagViewSet)
|
|
|
|
|
|
# Views behind /event/<event_pk>/...
|
|
event_router = NestedSimpleRouter(router, r'event', lookup='event')
|
|
event_router.register(r'place', views.PlaceViewSet)
|
|
event_router.register(r'tag', views.ActivityTagViewSet)
|
|
event_router.register(r'template', views.ActivityTemplateViewSet)
|
|
|
|
|
|
# API URLconf: routers + auth for browsable API.
|
|
urlpatterns = [
|
|
url(r'^', include(router.urls)),
|
|
url(r'^', include(event_router.urls)),
|
|
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
|
|
]
|