Skip to content

Commit

Permalink
feat: update page renders for studio-frontend pages (openedx#34329)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
KristinAoki authored Mar 13, 2024
1 parent ec1e58f commit dc234d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@ def test_logout(self):

@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):
Expand Down
24 changes: 8 additions & 16 deletions cms/djangoapps/contentstore/views/checklists.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions cms/djangoapps/contentstore/views/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit dc234d5

Please sign in to comment.