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
21 changes: 8 additions & 13 deletions cms/djangoapps/contentstore/rest_api/v0/views/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from common.djangoapps.student.auth import has_studio_read_access, has_studio_write_access
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, verify_course_exists, view_auth_classes
from ..serializers import CourseTabSerializer, CourseTabUpdateSerializer, TabIDLocatorSerializer
from ....toggles import use_new_custom_pages
from ....views.tabs import edit_tab_handler, get_course_tabs, reorder_tabs_handler


Expand Down Expand Up @@ -79,24 +78,20 @@ def get(self, request: Request, course_id: str) -> Response:
```
"""
course_key = CourseKey.from_string(course_id)
if not use_new_custom_pages(course_key):
return Response(status=status.HTTP_403_FORBIDDEN)
if not has_studio_read_access(request.user, course_key):
self.permission_denied(request)

course_block = modulestore().get_course(course_key)
tabs_to_render = get_course_tabs(course_block, request.user)
serializedCourseTabs = CourseTabSerializer(tabs_to_render, many=True).data
if use_new_custom_pages(course_key):
json_tabs = []
for tab in serializedCourseTabs:
if tab.get('type') == 'static_tab':
url_slug = tab.get('settings').get('url_slug')
static_tab_loc = course_block.id.make_usage_key("static_tab", url_slug)
tab["id"] = str(static_tab_loc)
json_tabs.append(tab)
return Response(json_tabs)
return Response(serializedCourseTabs)
json_tabs = []
for tab in serializedCourseTabs:
if tab.get('type') == 'static_tab':
url_slug = tab.get('settings').get('url_slug')
static_tab_loc = course_block.id.make_usage_key("static_tab", url_slug)
tab["id"] = str(static_tab_loc)
json_tabs.append(tab)
return Response(json_tabs)


@view_auth_classes(is_authenticated=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ def get_use_new_home_page(self, obj):

def get_use_new_custom_pages(self, obj):
"""
Method to get the use_new_custom_pages switch
Method to indicate whether or not to use the new custom pages

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_custom_pages(course_key)
return True

def get_use_new_schedule_details_page(self, obj):
"""
Expand Down
7 changes: 5 additions & 2 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,8 +1498,6 @@ def test_get_json(handler):
test_get_html('export_handler')
with override_waffle_flag(toggles.LEGACY_STUDIO_COURSE_TEAM, True):
test_get_html('course_team_handler')
with override_waffle_flag(toggles.LEGACY_STUDIO_CUSTOM_PAGES, True):
test_get_html('tabs_handler')
with override_waffle_flag(toggles.LEGACY_STUDIO_SCHEDULE_DETAILS, True):
test_get_html('settings_handler')
with override_waffle_flag(toggles.LEGACY_STUDIO_GRADING, True):
Expand All @@ -1518,6 +1516,11 @@ def test_get_json(handler):
resp = self.client.get(course_updates_url)
assert resp.status_code == 200

resp = self.client.get(
get_url('cms.djangoapps.contentstore:v0:course_tab_list', course_key, 'course_id')
)
self.assertEqual(resp.status_code, 200)

# go look at the Edit page
unit_key = course_key.make_usage_key('vertical', 'test_vertical')
with override_waffle_flag(toggles.LEGACY_STUDIO_UNIT_EDITOR, True):
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 @@ -167,7 +167,6 @@ def test_discussion_fields_available(self, is_pages_and_resources_enabled,
@override_waffle_flag(toggles.LEGACY_STUDIO_IMPORT, True)
@override_waffle_flag(toggles.LEGACY_STUDIO_EXPORT, True)
@override_waffle_flag(toggles.LEGACY_STUDIO_COURSE_TEAM, True)
@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)
def test_disable_advanced_settings_feature(self, disable_advanced_settings):
Expand All @@ -184,7 +183,6 @@ def test_disable_advanced_settings_feature(self, disable_advanced_settings):
'import_handler',
'export_handler',
'course_team_handler',
'tabs_handler',
'settings_handler',
'grading_handler',
):
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 @@ -162,25 +162,6 @@ def individualize_anonymous_user_id(course_id):
return INDIVIDUALIZE_ANONYMOUS_USER_ID.is_enabled(course_id)


# .. toggle_name: legacy_studio.custom_pages
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Temporarily fall back to the old Studio custom pages tab.
# .. 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_CUSTOM_PAGES = CourseWaffleFlag("legacy_studio.custom_pages", __name__)


def use_new_custom_pages(course_key):
"""
Returns a boolean if new studio custom pages mfe is enabled
"""
return not LEGACY_STUDIO_CUSTOM_PAGES.is_enabled(course_key)


# .. toggle_name: contentstore.use_react_markdown_editor
# .. toggle_implementation: CourseWaffleFlag
# .. 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 @@ -44,7 +44,6 @@
use_new_advanced_settings_page,
use_new_certificates_page,
use_new_course_team_page,
use_new_custom_pages,
use_new_export_page,
use_new_grading_page,
use_new_group_configurations_page,
Expand Down Expand Up @@ -514,11 +513,10 @@ def get_custom_pages_url(course_locator) -> str:
Gets course authoring microfrontend URL for custom pages view.
"""
custom_pages_url = None
if use_new_custom_pages(course_locator):
mfe_base_url = get_course_authoring_url(course_locator)
course_mfe_url = f'{mfe_base_url}/course/{course_locator}/custom-pages'
if mfe_base_url:
custom_pages_url = course_mfe_url
mfe_base_url = get_course_authoring_url(course_locator)
course_mfe_url = f'{mfe_base_url}/course/{course_locator}/custom-pages'
if mfe_base_url:
custom_pages_url = course_mfe_url
return custom_pages_url


Expand Down
17 changes: 2 additions & 15 deletions cms/djangoapps/contentstore/views/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
from xmodule.modulestore.django import modulestore
from xmodule.tabs import CourseTab, CourseTabList, InvalidTabsException, StaticTab

from common.djangoapps.edxmako.shortcuts import render_to_response
from common.djangoapps.student.auth import has_course_author_access
from common.djangoapps.util.json_request import JsonResponse, JsonResponseBadRequest, expect_json
from ..toggles import use_new_custom_pages
from ..utils import get_lms_link_for_item, get_pages_and_resources_url, get_custom_pages_url
from ..utils import get_pages_and_resources_url, get_custom_pages_url

__all__ = ["tabs_handler", "update_tabs_handler"]

Expand Down Expand Up @@ -65,18 +63,7 @@ def tabs_handler(request, course_key_string):
elif request.method == "GET": # assume html
# get all tabs from the tabs list: static tabs (a.k.a. user-created tabs) and built-in tabs
# present in the same order they are displayed in LMS
if use_new_custom_pages(course_key):
return redirect(get_custom_pages_url(course_key))
tabs_to_render = list(get_course_tabs(course_item, request.user))

return render_to_response(
"edit-tabs.html",
{
"context_course": course_item,
"tabs_to_render": tabs_to_render,
"lms_link": get_lms_link_for_item(course_item.location),
},
)
return redirect(get_custom_pages_url(course_key))
else:
return HttpResponseNotFound()

Expand Down
6 changes: 1 addition & 5 deletions cms/djangoapps/contentstore/views/tests/test_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import json
import random

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
from cms.djangoapps.contentstore.views import tabs
Expand Down Expand Up @@ -68,12 +65,11 @@ def test_not_implemented(self):
data={'invalid_request': None},
)

@override_waffle_flag(toggles.LEGACY_STUDIO_CUSTOM_PAGES, True)
def test_view_index(self):
"""Basic check that the Pages page responds correctly"""

resp = self.client.get_html(self.url)
self.assertContains(resp, 'course-nav-list')
assert resp.status_code == 302

def test_reorder_tabs(self):
"""Test re-ordering of tabs"""
Expand Down
1 change: 0 additions & 1 deletion cms/static/cms/js/spec/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@
'js/spec/video/transcripts/editor_spec',
'js/spec/video/transcripts/file_uploader_spec',
'js/spec/models/component_template_spec',
'js/spec/models/explicit_url_spec',
'js/spec/models/xblock_info_spec',
'js/spec/models/xblock_validation_spec',
'js/spec/models/license_spec',
Expand Down
27 changes: 0 additions & 27 deletions cms/static/js/factories/edit_tabs.js

This file was deleted.

14 changes: 0 additions & 14 deletions cms/static/js/models/explicit_url.js

This file was deleted.

12 changes: 0 additions & 12 deletions cms/static/js/spec/models/explicit_url_spec.js

This file was deleted.

Loading
Loading