Files
edx-platform/lms/djangoapps/experiments/routers.py
Jeremy Bowman e1d1c29c00 Fix DRF deprecation warnings (#23082)
Fix all deprecation warnings generated by Django REST Framework during the unit tests:

* ``The `base_name` argument is pending deprecation in favor of `basename`.`` (86 occurrences)
* `` `detail_route` is deprecated and will be removed in 3.10 in favor of `action`, which accepts a `detail` bool. Use `@action(detail=True)` instead.`` (18 occurrences)
2020-02-12 12:51:40 -05:00

56 lines
1.6 KiB
Python

"""
Experimentation routers
"""
from rest_framework import routers
from rest_framework.routers import DynamicRoute, Route
class DefaultRouter(routers.DefaultRouter):
routes = [
# List route.
Route(
url=r'^{prefix}{trailing_slash}$',
mapping={
'get': 'list',
'post': 'create',
# Allow PUT as create
'put': 'create_or_update',
},
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}/{lookup}{trailing_slash}$',
name='{basename}-list',
detail=False,
initkwargs={}
),
# Detail route.
Route(
url=r'^{prefix}/{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}/{lookup}{trailing_slash}$',
name='{basename}-detail',
detail=True,
initkwargs={}
),
]