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)
This commit is contained in:
Jeremy Bowman
2020-02-12 12:51:40 -05:00
committed by GitHub
parent 06d0d9f3e1
commit e1d1c29c00
8 changed files with 14 additions and 13 deletions

View File

@@ -10,5 +10,5 @@ from .views.course_runs import CourseRunViewSet
app_name = 'cms.djangoapps.api.v1'
router = DefaultRouter()
router.register(r'course_runs', CourseRunViewSet, base_name='course_run')
router.register(r'course_runs', CourseRunViewSet, basename='course_run')
urlpatterns = router.urls

View File

@@ -7,7 +7,7 @@ from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthenticat
from opaque_keys.edx.keys import CourseKey
from rest_framework import parsers, permissions, status, viewsets
from rest_framework.authentication import SessionAuthentication
from rest_framework.decorators import detail_route
from rest_framework.decorators import action
from rest_framework.response import Response
from contentstore.views.course import _accessible_courses_iter, get_course_and_check_access
@@ -74,7 +74,8 @@ class CourseRunViewSet(viewsets.GenericViewSet):
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
@detail_route(
@action(
detail=True,
methods=['post', 'put'],
parser_classes=(parsers.FormParser, parsers.MultiPartParser,),
serializer_class=CourseRunImageSerializer)
@@ -85,7 +86,7 @@ class CourseRunViewSet(viewsets.GenericViewSet):
serializer.save()
return Response(serializer.data)
@detail_route(methods=['post'])
@action(detail=True, methods=['post'])
def rerun(self, request, *args, **kwargs):
course_run = self.get_object()
serializer = CourseRunRerunSerializer(course_run, data=request.data, context=self.get_serializer_context())