Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion common/djangoapps/util/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def get_link_for_about_page(course):
).get('CUSTOM_COURSE_URLS')

if use_catalog_mfe():
about_base_url = settings.CATALOG_MICROFRONTEND_URL
about_base_url = configuration_helpers.get_value(
'CATALOG_MICROFRONTEND_URL',
settings.CATALOG_MICROFRONTEND_URL,
)
else:
about_base_url = configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL)

Expand Down
23 changes: 21 additions & 2 deletions lms/djangoapps/branding/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
log = logging.getLogger(__name__)


def _catalog_mfe_base_url() -> str:
"""
Return the site-aware base URL for the Catalog MFE.

Reads `CATALOG_MICROFRONTEND_URL` from Site Configuration when available;
otherwise falls back to `settings.CATALOG_MICROFRONTEND_URL`.
"""
return configuration_helpers.get_value(
'CATALOG_MICROFRONTEND_URL',
settings.CATALOG_MICROFRONTEND_URL,
)


@ensure_csrf_cookie
@transaction.non_atomic_requests
@cache_if_anonymous()
Expand All @@ -46,7 +59,10 @@ def index(request):
return redirect('dashboard')

if use_catalog_mfe():
return redirect(f'{settings.CATALOG_MICROFRONTEND_URL}/', permanent=True)
return redirect(
f'{_catalog_mfe_base_url()}/',
permanent=True,
)

enable_mktg_site = configuration_helpers.get_value(
'ENABLE_MKTG_SITE',
Expand Down Expand Up @@ -94,7 +110,10 @@ def courses(request):
profile page. Otherwise, it's the edX courseware.views.views.courses page
"""
if use_catalog_mfe():
return redirect(f'{settings.CATALOG_MICROFRONTEND_URL}/courses', permanent=True)
return redirect(
f'{_catalog_mfe_base_url()}/',
permanent=True,
)

enable_mktg_site = configuration_helpers.get_value(
'ENABLE_MKTG_SITE',
Expand Down
7 changes: 5 additions & 2 deletions lms/djangoapps/learner_home/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from common.djangoapps.course_modes.models import CourseMode
from openedx.features.course_experience import course_home_url
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from xmodule.data import CertificatesDisplayBehaviors
from lms.djangoapps.learner_home.utils import course_progress_url

Expand Down Expand Up @@ -595,8 +596,10 @@ class EnterpriseDashboardSerializer(serializers.Serializer):

def get_url(self, instance):
return urljoin(
settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
instance["slug"],
configuration_helpers.get_value(
'ENTERPRISE_LEARNER_PORTAL_BASE_URL',
settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
),
)


Expand Down
6 changes: 5 additions & 1 deletion lms/djangoapps/learner_home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ def get_platform_settings():
"""Get settings used for platform level connections: emails, url routes, etc."""

course_search_url = marketing_link("COURSES")
catalog_microfrontend_url = configuration_helpers.get_value(
"CATALOG_MICROFRONTEND_URL",
settings.CATALOG_MICROFRONTEND_URL,
)
if toggles.use_catalog_mfe():
course_search_url = f"{settings.CATALOG_MICROFRONTEND_URL}/courses"
course_search_url = f"{catalog_microfrontend_url}/courses"

return {
"supportEmail": settings.DEFAULT_FEEDBACK_EMAIL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from openedx.core.constants import COURSE_PUBLISHED
from openedx.core.djangoapps.catalog.utils import get_programs
from openedx.core.djangoapps.programs.utils import ProgramProgressMeter
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.features.enterprise_support.api import get_enterprise_learner_data_from_db

User = get_user_model()
Expand Down Expand Up @@ -190,7 +191,10 @@ def emit_event(self, user, program, suggested_course_run, suggested_course, comp
if enterprise_customer and enterprise_customer['enable_learner_portal']:
# If user is an enterprise learner then we want to redirect to B2B course landing page on learner portal.
recommended_course_url = urljoin(
settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
configuration_helpers.get_value(
'ENTERPRISE_LEARNER_PORTAL_BASE_URL',
settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
),
'/'.join([enterprise_customer['slug'], 'course', suggested_course['key']]),
)
else:
Expand Down
2 changes: 1 addition & 1 deletion lms/templates/header/navbar-logo-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<h1 class="header-logo">
% if enterprise_customer_link:
<a href="${settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL}/${enterprise_customer_link.get('slug')}">
<a href="${configuration_helpers.get_value('ENTERPRISE_LEARNER_PORTAL_BASE_URL', settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL)}/${enterprise_customer_link.get('slug')}">
<img class="logo" src="${enterprise_customer_link.get('logo')}" alt="${_('{name} Dashboard').format(name=enterprise_customer_link.get('name'))}"/>
% if settings.LOGO_IMAGE_EXTRA_TEXT == 'edge':
<span class="font-italic"> | EDGE</span>
Expand Down
5 changes: 3 additions & 2 deletions lms/templates/header/user_dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.utils.translation import gettext as _

from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name, get_enterprise_learner_portal
%>

Expand Down Expand Up @@ -41,13 +42,13 @@
% if not enterprise_customer_portal:
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('dashboard')}" role="menuitem">${_("Dashboard")}</a></div>
% else:
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL}/${enterprise_customer_portal.get('slug')}" role="menuitem">${_("Dashboard")}</a></div>
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${configuration_helpers.get_value('ENTERPRISE_LEARNER_PORTAL_BASE_URL', settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL)}/${enterprise_customer_portal.get('slug')}" role="menuitem">${_("Dashboard")}</a></div>
% endif

<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${urljoin(settings.PROFILE_MICROFRONTEND_URL, f'{user.username}')}" role="menuitem">${_("Profile")}</a></div>
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${settings.ACCOUNT_MICROFRONTEND_URL}" role="menuitem">${_("Account")}</a></div>
% if should_show_order_history:
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${settings.ORDER_HISTORY_MICROFRONTEND_URL}" role="menuitem">${_("Order History")}</a></div>
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${configuration_helpers.get_value('ORDER_HISTORY_MICROFRONTEND_URL', settings.ORDER_HISTORY_MICROFRONTEND_URL)}" role="menuitem">${_("Order History")}</a></div>
% endif
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('logout')}" role="menuitem">${_("Sign Out")}</a></div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions openedx/features/enterprise_support/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,10 @@ def get_enterprise_learner_portal_enabled_message(enterprise_customer):
return None

learner_portal_url = "{base_url}/{slug}?utm_source=lms_dashboard_banner".format(
base_url=settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
base_url=configuration_helpers.get_value(
'ENTERPRISE_LEARNER_PORTAL_BASE_URL',
settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
),
slug=enterprise_customer['slug']
)

Expand Down Expand Up @@ -935,7 +938,10 @@ def get_enterprise_learner_portal_context(request):
'enterprise_customer_slug': enterprise_customer.get('slug'),
'enterprise_customer_learner_portal_enabled': enterprise_customer.get('enable_learner_portal', False),
'enterprise_customer_uuid': enterprise_customer.get('uuid'),
'enterprise_learner_portal_base_url': settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
'enterprise_learner_portal_base_url': configuration_helpers.get_value(
'ENTERPRISE_LEARNER_PORTAL_BASE_URL',
settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL,
),
'enterprise_learner_portal_enabled_message': enterprise_learner_portal_enabled_message,
})
return context
Expand Down