From dc234d5accbe03bca165ba611e0d154e87921d4a Mon Sep 17 00:00:00 2001 From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:57:58 -0400 Subject: [PATCH] feat: update page renders for studio-frontend pages (#34329) * feat: update page renders for studio-frontend pages * fix: checklist redirect url * fix: failing tests * fix: checklist link * fix: redirect url typo * fix: no newline error --- .../contentstore/tests/test_contentstore.py | 2 +- .../contentstore/views/checklists.py | 24 +++++++------------ cms/djangoapps/contentstore/views/public.py | 7 +++--- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index e09ff48834..39e826b3e4 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -2155,7 +2155,7 @@ class EntryPageTestCase(TestCase): @override_waffle_switch(waffle.ENABLE_ACCESSIBILITY_POLICY_PAGE, active=True) def test_accessibility(self): - self._test_page('/accessibility') + self._test_page('/accessibility', 302) def _create_course(test, course_key, course_data): diff --git a/cms/djangoapps/contentstore/views/checklists.py b/cms/djangoapps/contentstore/views/checklists.py index b5d6abd758..eb5c651a3d 100644 --- a/cms/djangoapps/contentstore/views/checklists.py +++ b/cms/djangoapps/contentstore/views/checklists.py @@ -1,35 +1,27 @@ # lint-amnesty, pylint: disable=missing-module-docstring +from django.conf import settings from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied -from django.views.decorators.csrf import ensure_csrf_cookie +from django.http.response import Http404 +from django.shortcuts import redirect from opaque_keys.edx.keys import CourseKey -from common.djangoapps.edxmako.shortcuts import render_to_response from common.djangoapps.student.auth import has_course_author_access -from cms.djangoapps.contentstore.utils import get_proctored_exam_settings_url -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order __all__ = ['checklists_handler'] @login_required -@ensure_csrf_cookie def checklists_handler(request, course_key_string=None): ''' The restful handler for course checklists. It allows retrieval of the checklists (as an HTML page). - - GET - html: return an html page which will show course checklists. Note that only the checklists container - is returned and that the actual data is determined with a client-side request. ''' course_key = CourseKey.from_string(course_key_string) if not has_course_author_access(request.user, course_key): raise PermissionDenied() - - course_block = modulestore().get_course(course_key) - return render_to_response('checklists.html', { - 'language_code': request.LANGUAGE_CODE, - 'context_course': course_block, - 'mfe_proctored_exam_settings_url': get_proctored_exam_settings_url(course_block.id), - }) + mfe_base_url = settings.COURSE_AUTHORING_MICROFRONTEND_URL + if mfe_base_url: + studio_checklist_url = f'{mfe_base_url}/course/{course_key_string}/checklists' + return redirect(studio_checklist_url) + raise Http404 diff --git a/cms/djangoapps/contentstore/views/public.py b/cms/djangoapps/contentstore/views/public.py index f4d1f7c778..71f5ee5512 100644 --- a/cms/djangoapps/contentstore/views/public.py +++ b/cms/djangoapps/contentstore/views/public.py @@ -74,7 +74,8 @@ def accessibility(request): Display the accessibility accommodation form. """ if ENABLE_ACCESSIBILITY_POLICY_PAGE.is_enabled(): - return render_to_response('accessibility.html', { - 'language_code': request.LANGUAGE_CODE - }) + mfe_base_url = settings.COURSE_AUTHORING_MICROFRONTEND_URL + if mfe_base_url: + studio_accessbility_url = f'{mfe_base_url}/accessibility' + return redirect(studio_accessbility_url) raise Http404