diff --git a/lms/djangoapps/course_home_api/utils.py b/lms/djangoapps/course_home_api/utils.py index ba39ea56ad..f6a5060f61 100644 --- a/lms/djangoapps/course_home_api/utils.py +++ b/lms/djangoapps/course_home_api/utils.py @@ -13,3 +13,11 @@ def get_microfrontend_url(course_key, view_name=None): mfe_link += '/{}'.format(view_name) return mfe_link + + +def is_request_from_learning_mfe(request): + """ + Returns whether the given request was made by the frontend-app-learning MFE. + """ + return (settings.LEARNING_MICROFRONTEND_URL and + request.META.get('HTTP_REFERER', '').startswith(settings.LEARNING_MICROFRONTEND_URL)) diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index fd9701d2d9..67d187cea8 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -55,6 +55,7 @@ from lms.djangoapps.ccx.custom_exception import CCXLocatorValidationException from lms.djangoapps.certificates import api as certs_api from lms.djangoapps.certificates.models import CertificateStatuses from lms.djangoapps.commerce.utils import EcommerceService +from lms.djangoapps.course_home_api.utils import is_request_from_learning_mfe from lms.djangoapps.courseware.access import has_access, has_ccx_coach_role from lms.djangoapps.courseware.access_utils import check_course_open_for_learner, check_public_access from lms.djangoapps.courseware.courses import ( @@ -1682,7 +1683,7 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True): 'web_app_course_url': reverse(COURSE_HOME_VIEW_NAME, args=[course.id]), 'on_courseware_page': True, 'verified_upgrade_link': verified_upgrade_deadline_link(request.user, course=course), - 'is_learning_mfe': request.META.get('HTTP_REFERER', '').startswith(settings.LEARNING_MICROFRONTEND_URL), + 'is_learning_mfe': is_request_from_learning_mfe(request), 'is_mobile_app': is_request_from_mobile_app(request), 'reset_deadlines_url': reverse(RESET_COURSE_DEADLINES_NAME), } diff --git a/lms/templates/courseware/courseware-chromeless.html b/lms/templates/courseware/courseware-chromeless.html index 99825e950a..b742d16446 100644 --- a/lms/templates/courseware/courseware-chromeless.html +++ b/lms/templates/courseware/courseware-chromeless.html @@ -11,7 +11,9 @@ from openedx.core.djangolib.js_utils import js_escaped_string <%def name="course_name()"> <% return _("{course_number} Courseware").format(course_number=course.display_number_with_default) %> %def> -<%include file="/dates_banner.html" /> +% if is_mobile_app: + <%include file="/dates_banner.html" /> +% endif <%block name="bodyclass">view-in-course view-courseware courseware ${course.css_class or ''}%block> <%block name="title">