Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions cms/djangoapps/contentstore/rest_api/v0/tests/test_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,8 @@ def send_request(self, _url, _data):
}
),
)
@patch(
f"cms.djangoapps.contentstore.rest_api.{VERSION}.views.xblock.toggles.use_studio_content_api",
return_value=True,
)
def make_request(
self,
mock_use_studio_content_api,
mock_handle_assets,
run_assertions=None,
course_id=None,
Expand Down Expand Up @@ -125,13 +120,6 @@ def assert_assets_handler_called(self, *, mock_handle_assets, response):
def send_request(self, url, data):
return self.client.get(url)

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_assets_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down Expand Up @@ -182,13 +170,6 @@ def assert_assets_handler_called(self, *, mock_handle_assets, response):
def send_request(self, url, data):
return self.client.post(url, data=data, format="multipart")

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.post(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_assets_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down Expand Up @@ -232,13 +213,6 @@ def assert_assets_handler_called(self, *, mock_handle_assets, response):
def send_request(self, url, data):
return self.client.put(url, data=data, format="json")

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.put(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_assets_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down Expand Up @@ -277,13 +251,6 @@ def assert_assets_handler_called(self, *, mock_handle_assets, response):
def send_request(self, url, data):
return self.client.delete(url)

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_assets_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down
40 changes: 0 additions & 40 deletions cms/djangoapps/contentstore/rest_api/v0/tests/test_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,8 @@ def send_request(self, _url, _data):
}
),
)
@patch(
f"cms.djangoapps.contentstore.rest_api.{VERSION}.views.xblock.toggles.use_studio_content_api",
return_value=True,
)
def make_request(
self,
mock_use_studio_content_api,
mock_handle_xblock,
run_assertions=None,
course_id=None,
Expand Down Expand Up @@ -111,13 +106,6 @@ def assert_xblock_handler_called(self, *, mock_handle_xblock, response):
def send_request(self, url, data):
return self.client.get(url)

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_xblock_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down Expand Up @@ -167,13 +155,6 @@ def assert_xblock_handler_called(self, *, mock_handle_xblock, response):
def send_request(self, url, data):
return self.client.post(url, data=data, format="json")

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.post(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_xblock_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down Expand Up @@ -218,13 +199,6 @@ def assert_xblock_handler_called(self, *, mock_handle_xblock, response):
def send_request(self, url, data):
return self.client.put(url, data=data, format="json")

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.put(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_xblock_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down Expand Up @@ -269,13 +243,6 @@ def assert_xblock_handler_called(self, *, mock_handle_xblock, response):
def send_request(self, url, data):
return self.client.patch(url, data=data, format="json")

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.patch(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_xblock_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down Expand Up @@ -310,13 +277,6 @@ def assert_xblock_handler_called(self, *, mock_handle_xblock, response):
def send_request(self, url, data):
return self.client.delete(url)

def test_api_behind_feature_flag(self):
# should return 404 if the feature flag is not enabled
url = self.get_url()

response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_xblock_handler_called_with_correct_arguments(self):
self.client.login(
username=self.course_instructor.username, password=self.password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from rest_framework.response import Response
from rest_framework import status
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes
import cms.djangoapps.contentstore.toggles as toggles


class APIHeartBeatView(DeveloperErrorViewMixin, APIView):
Expand Down Expand Up @@ -43,6 +42,4 @@ def get(self, request: Request):
}
```
"""
if toggles.use_studio_content_api():
return Response({'status': 'heartbeat successful'}, status=status.HTTP_200_OK)
return Response(status=status.HTTP_403_FORBIDDEN)
return Response({'status': 'heartbeat successful'}, status=status.HTTP_200_OK)
25 changes: 0 additions & 25 deletions cms/djangoapps/contentstore/rest_api/v0/views/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
import logging
from rest_framework.generics import CreateAPIView, RetrieveAPIView, UpdateAPIView, DestroyAPIView
from django.views.decorators.csrf import csrf_exempt
from django.http import Http404

from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes
from common.djangoapps.util.json_request import expect_json_in_class_view

from cms.djangoapps.contentstore.api import course_author_access_required

from cms.djangoapps.contentstore.asset_storage_handlers import handle_assets
import cms.djangoapps.contentstore.toggles as contentstore_toggles

from ..serializers.assets import AssetSerializer
from .utils import validate_request_with_serializer
from rest_framework.parsers import (MultiPartParser, FormParser, JSONParser)
from openedx.core.lib.api.parsers import TypedFileUploadParser

log = logging.getLogger(__name__)
toggles = contentstore_toggles


@view_auth_classes()
Expand All @@ -33,17 +30,6 @@ class AssetsCreateRetrieveView(DeveloperErrorViewMixin, CreateAPIView, RetrieveA
serializer_class = AssetSerializer
parser_classes = (JSONParser, MultiPartParser, FormParser, TypedFileUploadParser)

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
The dispatch method of a View class handles HTTP requests in general
and calls other methods to handle specific HTTP methods.
We use this to raise a 404 if the content api is disabled.
"""
if not toggles.use_studio_content_api():
raise Http404
return super().dispatch(request, *args, **kwargs)

@csrf_exempt
@course_author_access_required
@validate_request_with_serializer
Expand All @@ -66,17 +52,6 @@ class AssetsUpdateDestroyView(DeveloperErrorViewMixin, UpdateAPIView, DestroyAPI
serializer_class = AssetSerializer
parser_classes = (JSONParser, MultiPartParser, FormParser, TypedFileUploadParser)

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
The dispatch method of a View class handles HTTP requests in general
and calls other methods to handle specific HTTP methods.
We use this to raise a 404 if the content api is disabled.
"""
if not toggles.use_studio_content_api():
raise Http404
return super().dispatch(request, *args, **kwargs)

@course_author_access_required
@expect_json_in_class_view
@validate_request_with_serializer
Expand Down
58 changes: 0 additions & 58 deletions cms/djangoapps/contentstore/rest_api/v0/views/authoring_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
)
from rest_framework.parsers import (MultiPartParser, FormParser)
from django.views.decorators.csrf import csrf_exempt
from django.http import Http404

from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes
from openedx.core.lib.api.parsers import TypedFileUploadParser
Expand All @@ -27,12 +26,10 @@
VideoUploadSerializer,
VideoImageSerializer,
)
import cms.djangoapps.contentstore.toggles as contentstore_toggles
from .utils import validate_request_with_serializer


log = logging.getLogger(__name__)
toggles = contentstore_toggles


@view_auth_classes()
Expand All @@ -44,17 +41,6 @@ class VideosUploadsView(DeveloperErrorViewMixin, RetrieveAPIView, DestroyAPIView
"""
serializer_class = VideoUploadSerializer

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
The dispatch method of a View class handles HTTP requests in general
and calls other methods to handle specific HTTP methods.
We use this to raise a 404 if the content api is disabled.
"""
if not toggles.use_studio_content_api():
raise Http404
return super().dispatch(request, *args, **kwargs)

@course_author_access_required
def retrieve(self, request, course_key, edx_video_id=None): # pylint: disable=arguments-differ
return handle_videos(request, course_key.html_id(), edx_video_id)
Expand All @@ -73,17 +59,6 @@ class VideosCreateUploadView(DeveloperErrorViewMixin, CreateAPIView):
"""
serializer_class = VideoUploadSerializer

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
The dispatch method of a View class handles HTTP requests in general
and calls other methods to handle specific HTTP methods.
We use this to raise a 404 if the content api is disabled.
"""
if not toggles.use_studio_content_api():
raise Http404
return super().dispatch(request, *args, **kwargs)

@csrf_exempt
@course_author_access_required
@expect_json_in_class_view
Expand All @@ -102,17 +77,6 @@ class VideoImagesView(DeveloperErrorViewMixin, CreateAPIView):
serializer_class = VideoImageSerializer
parser_classes = (MultiPartParser, FormParser, TypedFileUploadParser)

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
The dispatch method of a View class handles HTTP requests in general
and calls other methods to handle specific HTTP methods.
We use this to raise a 404 if the content api is disabled.
"""
if not toggles.use_studio_content_api():
raise Http404
return super().dispatch(request, *args, **kwargs)

@csrf_exempt
@course_author_access_required
@expect_json_in_class_view
Expand All @@ -133,17 +97,6 @@ class VideoEncodingsDownloadView(DeveloperErrorViewMixin, RetrieveAPIView):
# does not specify a serializer class.
swagger_schema = None

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
The dispatch method of a View class handles HTTP requests in general
and calls other methods to handle specific HTTP methods.
We use this to raise a 404 if the content api is disabled.
"""
if not toggles.use_studio_content_api():
raise Http404
return super().dispatch(request, *args, **kwargs)

@csrf_exempt
@course_author_access_required
def retrieve(self, request, course_key): # pylint: disable=arguments-differ
Expand All @@ -161,17 +114,6 @@ class VideoFeaturesView(DeveloperErrorViewMixin, RetrieveAPIView):
# does not specify a serializer class.
swagger_schema = None

def dispatch(self, request, *args, **kwargs):
# TODO: probably want to refactor this to a decorator.
"""
The dispatch method of a View class handles HTTP requests in general
and calls other methods to handle specific HTTP methods.
We use this to raise a 404 if the content api is disabled.
"""
if not toggles.use_studio_content_api():
raise Http404
return super().dispatch(request, *args, **kwargs)

@csrf_exempt
def retrieve(self, request): # pylint: disable=arguments-differ
return enabled_video_features(request)
Loading
Loading