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
This commit is contained in:
Kristin Aoki
2024-03-13 09:57:58 -04:00
committed by GitHub
parent ec1e58f442
commit dc234d5acc
3 changed files with 13 additions and 20 deletions

View File

@@ -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):

View File

@@ -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

View File

@@ -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