59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
from rest_framework import routers
|
|
from rest_framework.routers import DefaultRouter, DynamicRoute, Route
|
|
from . import views
|
|
from django.urls import NoReverseMatch, path, re_path
|
|
|
|
|
|
app_name = 'push_notifications'
|
|
|
|
|
|
class ApplicationRouter(DefaultRouter):
|
|
|
|
routes = [
|
|
# List route.
|
|
Route(
|
|
url=r'^{prefix}/<user_uuid>{trailing_slash}$',
|
|
mapping={
|
|
'get': 'list',
|
|
'post': 'create'
|
|
},
|
|
name='{basename}-list',
|
|
detail=False,
|
|
initkwargs={'suffix': 'List'}
|
|
),
|
|
# Dynamically generated list routes. Generated using
|
|
# @action(detail=False) decorator on methods of the viewset.
|
|
DynamicRoute(
|
|
url=r'^{prefix}/<user_uuid>/{url_path}{trailing_slash}$',
|
|
name='{basename}-{url_name}',
|
|
detail=False,
|
|
initkwargs={}
|
|
),
|
|
# # Detail route.
|
|
Route(
|
|
url=r'^{prefix}/<user_uuid>/{lookup}{trailing_slash}$',
|
|
mapping={
|
|
'get': 'retrieve',
|
|
'put': 'update',
|
|
'patch': 'partial_update',
|
|
'delete': 'destroy'
|
|
},
|
|
name='{basename}-detail',
|
|
detail=True,
|
|
initkwargs={'suffix': 'Instance'}
|
|
),
|
|
# # Dynamically generated detail routes. Generated using
|
|
# # @action(detail=True) decorator on methods of the viewset.
|
|
DynamicRoute(
|
|
url=r'^{prefix}/<user_uuid>/{lookup}/{url_path}{trailing_slash}$',
|
|
name='{basename}-{url_name}',
|
|
detail=True,
|
|
initkwargs={}
|
|
),
|
|
]
|
|
|
|
|
|
application_router = DefaultRouter()
|
|
application_router.register('application', views.ApplicationPushUserViewSet, basename='application')
|
|
|
|
urlpatterns = application_router.urls
|