mirror of
https://github.com/himool/HimoolERP.git
synced 2024-11-14 19:35:07 +08:00
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
|
from rest_framework.routers import SimpleRouter, Route, DynamicRoute
|
||
|
|
||
|
|
||
|
class BaseRouter(SimpleRouter):
|
||
|
|
||
|
routes = [
|
||
|
# List route.
|
||
|
Route(
|
||
|
url=r'^{prefix}{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}/{url_path}{trailing_slash}$',
|
||
|
name='{basename}-{url_name}',
|
||
|
detail=False,
|
||
|
initkwargs={}
|
||
|
),
|
||
|
# Detail route.
|
||
|
Route(
|
||
|
url=r'^{prefix}/(?P<pk>\d+){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}/(?P<pk>\d+)/{url_path}{trailing_slash}$',
|
||
|
name='{basename}-{url_name}',
|
||
|
detail=True,
|
||
|
initkwargs={}
|
||
|
),
|
||
|
]
|
||
|
|
||
|
|
||
|
__all__ = [
|
||
|
'SimpleRouter', 'BaseRouter',
|
||
|
]
|