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
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,15 @@ def get_use_new_certificates_page(self, obj):

def get_use_new_textbooks_page(self, obj):
"""
Method to get the use_new_textbooks_page switch
Method to indicate whether we should use_new_textbooks_page or not.

This used to be based on a waffle flag but the flag is being removed so we
default it to true for now until we can remove the need for it from the consumers
of this serializer and the related APIs.

See https://github.com/openedx/edx-platform/issues/37497
"""
course_key = self.get_course_key()
return toggles.use_new_textbooks_page(course_key)
return True

def get_use_new_group_configurations_page(self, obj):
"""
Expand Down
12 changes: 10 additions & 2 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,15 @@ def test_get_html(handler):
)
self.assertEqual(resp.status_code, 200)

def test_get_json(handler):
# Helper function for getting HTML for a page in Studio and
# checking that it does not error.
resp = self.client.get(
get_url(handler, course_key, 'course_key_string'),
HTTP_ACCEPT="application/json",
)
self.assertEqual(resp.status_code, 200)

course_items = import_course_from_xml(
self.store, self.user.id, TEST_DATA_DIR, ['simple'], create_if_not_present=True
)
Expand Down Expand Up @@ -1499,8 +1508,7 @@ def test_get_html(handler):
test_get_html('grading_handler')
with override_waffle_flag(toggles.LEGACY_STUDIO_ADVANCED_SETTINGS, True):
test_get_html('advanced_settings_handler')
with override_waffle_flag(toggles.LEGACY_STUDIO_TEXTBOOKS, True):
test_get_html('textbooks_list_handler')
test_get_json('textbooks_list_handler')

# go look at the Edit page
unit_key = course_key.make_usage_key('vertical', 'test_vertical')
Expand Down
2 changes: 0 additions & 2 deletions cms/djangoapps/contentstore/tests/test_course_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def test_discussion_fields_available(self, is_pages_and_resources_enabled,
@override_waffle_flag(toggles.LEGACY_STUDIO_CUSTOM_PAGES, True)
@override_waffle_flag(toggles.LEGACY_STUDIO_SCHEDULE_DETAILS, True)
@override_waffle_flag(toggles.LEGACY_STUDIO_GRADING, True)
@override_waffle_flag(toggles.LEGACY_STUDIO_TEXTBOOKS, True)
def test_disable_advanced_settings_feature(self, disable_advanced_settings):
"""
If this feature is enabled, only Django Staff/Superuser should be able to access the "Advanced Settings" page.
Expand All @@ -190,7 +189,6 @@ def test_disable_advanced_settings_feature(self, disable_advanced_settings):
'tabs_handler',
'settings_handler',
'grading_handler',
'textbooks_list_handler',
):
# Test that non-staff users don't see the "Advanced Settings" tab link.
response = self.non_staff_client.get_html(
Expand Down
19 changes: 0 additions & 19 deletions cms/djangoapps/contentstore/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,25 +402,6 @@ def use_new_certificates_page(course_key):
return not LEGACY_STUDIO_CERTIFICATES.is_enabled(course_key)


# .. toggle_name: legacy_studio.textbooks
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Temporarily fall back to the old Studio Textbooks page.
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2025-03-14
# .. toggle_target_removal_date: 2025-09-14
# .. toggle_tickets: https://github.com/openedx/edx-platform/issues/36275
# .. toggle_warning: In Ulmo, this toggle will be removed. Only the new (React-based) experience will be available.
LEGACY_STUDIO_TEXTBOOKS = CourseWaffleFlag('legacy_studio.textbooks', __name__)


def use_new_textbooks_page(course_key):
"""
Returns a boolean if new studio textbooks mfe is enabled
"""
return not LEGACY_STUDIO_TEXTBOOKS.is_enabled(course_key)


# .. toggle_name: legacy_studio.configurations
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
Expand Down
10 changes: 4 additions & 6 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
use_new_group_configurations_page,
use_new_import_page,
use_new_schedule_details_page,
use_new_textbooks_page,
use_new_unit_page,
use_new_updates_page,
use_new_video_uploads_page,
Expand Down Expand Up @@ -492,11 +491,10 @@ def get_textbooks_url(course_locator) -> str:
Gets course authoring microfrontend URL for textbooks page view.
"""
textbooks_url = None
if use_new_textbooks_page(course_locator):
mfe_base_url = get_course_authoring_url(course_locator)
course_mfe_url = f'{mfe_base_url}/course/{course_locator}/textbooks'
if mfe_base_url:
textbooks_url = course_mfe_url
mfe_base_url = get_course_authoring_url(course_locator)
course_mfe_url = f'{mfe_base_url}/course/{course_locator}/textbooks'
if mfe_base_url:
textbooks_url = course_mfe_url
return textbooks_url


Expand Down
17 changes: 8 additions & 9 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
use_new_updates_page,
use_new_advanced_settings_page,
use_new_grading_page,
use_new_textbooks_page,
use_new_group_configurations_page,
use_new_schedule_details_page
)
Expand All @@ -112,7 +111,6 @@
get_schedule_details_url,
get_studio_home_url,
get_updates_url,
get_textbooks_context,
get_textbooks_url,
initialize_permissions,
remove_all_instructors,
Expand Down Expand Up @@ -1457,17 +1455,18 @@ def textbooks_list_handler(request, course_key_string):
json: overwrite all textbooks in the course with the given list
"""
course_key = CourseKey.from_string(course_key_string)
if "application/json" not in request.META.get('HTTP_ACCEPT', 'text/html'):
# return HTML page
# We don't need to do an access check here because
# that is done when the endpoint for the actual content of the page.
# This is just to handle redirecting anyone that has bookmarked the old
# textbooks page.
return redirect(get_textbooks_url(course_key))

store = modulestore()
with store.bulk_operations(course_key):
course = get_course_and_check_access(course_key, request.user)

if "application/json" not in request.META.get('HTTP_ACCEPT', 'text/html'):
# return HTML page
if use_new_textbooks_page(course_key):
return redirect(get_textbooks_url(course_key))
textbooks_context = get_textbooks_context(course)
return render_to_response('textbooks.html', textbooks_context)

# from here on down, we know the client has requested JSON
if request.method == 'GET':
return JsonResponse(course.pdf_textbooks)
Expand Down
9 changes: 1 addition & 8 deletions cms/djangoapps/contentstore/views/tests/test_textbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import json
from unittest import TestCase

from edx_toggles.toggles.testutils import override_waffle_flag

from cms.djangoapps.contentstore import toggles
from cms.djangoapps.contentstore.tests.utils import CourseTestCase
from cms.djangoapps.contentstore.utils import reverse_course_url

Expand All @@ -20,15 +18,10 @@ def setUp(self):
super().setUp()
self.url = reverse_course_url('textbooks_list_handler', self.course.id)

@override_waffle_flag(toggles.LEGACY_STUDIO_TEXTBOOKS, True)
def test_view_index(self):
"Basic check that the textbook index page responds correctly"
resp = self.client.get(self.url)
self.assertEqual(resp.status_code, 200)
# we don't have resp.context right now,
# due to bugs in our testing harness :(
if resp.context and resp.context.get('course'):
self.assertEqual(resp.context['course'], self.course)
self.assertEqual(resp.status_code, 302)

def test_view_index_xhr(self):
"Check that we get a JSON response when requested via AJAX"
Expand Down
2 changes: 0 additions & 2 deletions cms/static/cms/js/spec/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,9 @@
'js/spec/models/section_spec',
'js/spec/models/settings_course_grader_spec',
'js/spec/models/settings_grading_spec',
'js/spec/models/textbook_spec',
'js/spec/models/upload_spec',
'js/spec/views/course_info_spec',
'js/spec/views/metadata_edit_spec',
'js/spec/views/textbook_spec',
'js/spec/views/upload_spec',
'js/spec/video/transcripts/message_manager_spec',
'js/spec/video/transcripts/utils_spec',
Expand Down
14 changes: 0 additions & 14 deletions cms/static/js/collections/chapter.js

This file was deleted.

8 changes: 0 additions & 8 deletions cms/static/js/collections/textbook.js

This file was deleted.

25 changes: 0 additions & 25 deletions cms/static/js/factories/textbooks.js

This file was deleted.

52 changes: 0 additions & 52 deletions cms/static/js/models/chapter.js

This file was deleted.

89 changes: 0 additions & 89 deletions cms/static/js/models/textbook.js

This file was deleted.

Loading
Loading