Skip to content

Commit

Permalink
feat: include custom relative dates flag info in outline api
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Jan 29, 2024
1 parent cb2a34e commit 15ee684
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 2 additions & 0 deletions cms/djangoapps/contentstore/rest_api/v1/views/course_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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
Expand Down Expand Up @@ -92,6 +93,7 @@ def get(self, request: Request, course_id: str):
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
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
Expand Down Expand Up @@ -46,6 +49,7 @@ def setUp(self):
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)
Expand All @@ -59,6 +63,7 @@ def test_course_index_response(self):
},
"discussions_incontext_feedback_url": "",
"discussions_incontext_learnmore_url": "",
"is_custom_relative_dates_active": True,
"initial_state": None,
"initial_user_clipboard": {
"content": None,
Expand All @@ -78,6 +83,7 @@ def test_course_index_response(self):
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)})
Expand All @@ -91,6 +97,7 @@ def test_course_index_response_with_show_locators(self):
},
"discussions_incontext_feedback_url": "",
"discussions_incontext_learnmore_url": "",
"is_custom_relative_dates_active": False,
"initial_state": {
"expanded_locators": [
str(self.unit.location),
Expand Down

0 comments on commit 15ee684

Please sign in to comment.