refactor: use get_link_for_about_page, remove duplicate function
This commit is contained in:
@@ -66,7 +66,7 @@ from common.djangoapps.student import auth
|
||||
from common.djangoapps.student.roles import CourseStaffRole
|
||||
from common.djangoapps.student.models import CourseEnrollment, UserTestGroup
|
||||
from common.djangoapps.util.cache import cache, cache_if_anonymous
|
||||
from common.djangoapps.util.course import course_location_from_key
|
||||
from common.djangoapps.util.course import course_location_from_key, get_link_for_about_page
|
||||
from common.djangoapps.util.db import outer_atomic
|
||||
from common.djangoapps.util.milestones_helpers import get_prerequisite_courses_display
|
||||
from common.djangoapps.util.views import ensure_valid_course_key, ensure_valid_usage_key
|
||||
@@ -146,7 +146,6 @@ from openedx.core.lib.mobile_utils import is_request_from_mobile_app
|
||||
from openedx.features.course_duration_limits.access import generate_course_expired_fragment
|
||||
from openedx.features.course_experience import course_home_url
|
||||
from openedx.features.course_experience.url_helpers import (
|
||||
get_catalog_mfe_course_about_url,
|
||||
get_courseware_url,
|
||||
get_learning_mfe_home_url,
|
||||
is_request_from_learning_mfe
|
||||
@@ -821,7 +820,8 @@ def course_about(request, course_id): # pylint: disable=too-many-statements
|
||||
|
||||
# If the course about page is being rendered in the MFE, redirect to the MFE.
|
||||
if branding_toggles.use_catalog_mfe():
|
||||
return redirect(get_catalog_mfe_course_about_url(course_key), permanent=True)
|
||||
course_overview = CourseOverview.get_from_id(course_key)
|
||||
return redirect(get_link_for_about_page(course_overview), permanent=True)
|
||||
|
||||
with modulestore().bulk_operations(course_key):
|
||||
permission = get_permission_for_course_about()
|
||||
|
||||
@@ -175,28 +175,6 @@ def get_learning_mfe_home_url(
|
||||
return mfe_link
|
||||
|
||||
|
||||
def get_catalog_mfe_course_about_url(
|
||||
course_key: CourseKey,
|
||||
params: Optional[QueryDict] = None,
|
||||
) -> str:
|
||||
"""
|
||||
Given a course run key, return the appropriate course about page URL in the Catalog MFE.
|
||||
|
||||
We're building a URL like this:
|
||||
|
||||
http://localhost:2000/course/course-v1:edX+DemoX+Demo_Course/about
|
||||
|
||||
`course_key` can be either an OpaqueKey or a string.
|
||||
`params` is an optional QueryDict object (e.g. request.GET)
|
||||
"""
|
||||
mfe_link = f'{settings.CATALOG_MICROFRONTEND_URL}/courses/{course_key}/about'
|
||||
|
||||
if params:
|
||||
mfe_link += f'?{params.urlencode()}'
|
||||
|
||||
return mfe_link
|
||||
|
||||
|
||||
def is_request_from_learning_mfe(request: HttpRequest):
|
||||
"""
|
||||
Returns whether the given request was made by the frontend-app-learning MFE.
|
||||
|
||||
Reference in New Issue
Block a user