feat: include custom relative dates flag info in outline api (#34058)
This commit is contained in:
@@ -29,3 +29,4 @@ class CourseIndexSerializer(serializers.Serializer):
|
||||
proctoring_errors = ProctoringErrorListSerializer(many=True)
|
||||
reindex_link = serializers.CharField()
|
||||
rerun_notification_id = serializers.IntegerField()
|
||||
is_custom_relative_dates_active = serializers.BooleanField()
|
||||
|
||||
@@ -7,6 +7,7 @@ from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from cms.djangoapps.contentstore.config.waffle import CUSTOM_RELATIVE_DATES
|
||||
from cms.djangoapps.contentstore.rest_api.v1.serializers import CourseIndexSerializer
|
||||
from cms.djangoapps.contentstore.utils import get_course_index_context
|
||||
from common.djangoapps.student.auth import has_studio_read_access
|
||||
@@ -92,6 +93,7 @@ class CourseIndexView(DeveloperErrorViewMixin, APIView):
|
||||
course_index_context.update({
|
||||
"discussions_incontext_learnmore_url": settings.DISCUSSIONS_INCONTEXT_LEARNMORE_URL,
|
||||
"discussions_incontext_feedback_url": settings.DISCUSSIONS_INCONTEXT_FEEDBACK_URL,
|
||||
"is_custom_relative_dates_active": CUSTOM_RELATIVE_DATES.is_enabled(course_key),
|
||||
})
|
||||
|
||||
serializer = CourseIndexSerializer(course_index_context)
|
||||
|
||||
@@ -5,6 +5,9 @@ from django.test import RequestFactory
|
||||
from django.urls import reverse
|
||||
from rest_framework import status
|
||||
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
|
||||
from cms.djangoapps.contentstore.config.waffle import CUSTOM_RELATIVE_DATES
|
||||
from cms.djangoapps.contentstore.rest_api.v1.mixins import PermissionAccessMixin
|
||||
from cms.djangoapps.contentstore.tests.utils import CourseTestCase
|
||||
from cms.djangoapps.contentstore.utils import get_lms_link_for_item
|
||||
@@ -46,6 +49,7 @@ class CourseIndexViewTest(CourseTestCase, PermissionAccessMixin):
|
||||
kwargs={"course_id": self.course.id},
|
||||
)
|
||||
|
||||
@override_waffle_flag(CUSTOM_RELATIVE_DATES, active=True)
|
||||
def test_course_index_response(self):
|
||||
"""Check successful response content"""
|
||||
response = self.client.get(self.url)
|
||||
@@ -59,6 +63,7 @@ class CourseIndexViewTest(CourseTestCase, PermissionAccessMixin):
|
||||
},
|
||||
"discussions_incontext_feedback_url": "",
|
||||
"discussions_incontext_learnmore_url": "",
|
||||
"is_custom_relative_dates_active": True,
|
||||
"initial_state": None,
|
||||
"initial_user_clipboard": {
|
||||
"content": None,
|
||||
@@ -78,6 +83,7 @@ class CourseIndexViewTest(CourseTestCase, PermissionAccessMixin):
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertDictEqual(expected_response, response.data)
|
||||
|
||||
@override_waffle_flag(CUSTOM_RELATIVE_DATES, active=False)
|
||||
def test_course_index_response_with_show_locators(self):
|
||||
"""Check successful response content with show query param"""
|
||||
response = self.client.get(self.url, {"show": str(self.unit.location)})
|
||||
@@ -91,6 +97,7 @@ class CourseIndexViewTest(CourseTestCase, PermissionAccessMixin):
|
||||
},
|
||||
"discussions_incontext_feedback_url": "",
|
||||
"discussions_incontext_learnmore_url": "",
|
||||
"is_custom_relative_dates_active": False,
|
||||
"initial_state": {
|
||||
"expanded_locators": [
|
||||
str(self.unit.location),
|
||||
|
||||
Reference in New Issue
Block a user