From 4bb1914ec63a061c8f967dddb7f979c568ffc781 Mon Sep 17 00:00:00 2001 From: Alex Dusenbery Date: Wed, 16 Sep 2020 11:35:52 -0400 Subject: [PATCH] ENT-3367 | Show at most 1 Enterprise Learner Portal dashboard link in the header user-menu. Also, guard against no branding config when getting learner portal data. --- lms/templates/header/navbar-logo-header.html | 5 +- lms/templates/header/user_dropdown.html | 12 +- openedx/features/enterprise_support/api.py | 130 +++++++++++++----- .../enterprise_support/tests/test_api.py | 61 ++++++-- .../enterprise_support/tests/test_utils.py | 87 ++++++++++-- openedx/features/enterprise_support/utils.py | 80 ++++++++--- 6 files changed, 284 insertions(+), 91 deletions(-) diff --git a/lms/templates/header/navbar-logo-header.html b/lms/templates/header/navbar-logo-header.html index a0b364c6af..8496b990e9 100644 --- a/lms/templates/header/navbar-logo-header.html +++ b/lms/templates/header/navbar-logo-header.html @@ -8,15 +8,14 @@ from django.urls import reverse from django.utils.translation import ugettext as _ from lms.djangoapps.ccx.overrides import get_current_ccx 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_portals +from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name, get_enterprise_learner_portal # App that handles subdomain specific branding from branding import api as branding_api %> <% -enterprise_customer_links = get_enterprise_learner_portals(request) -enterprise_customer_link = enterprise_customer_links[0] if enterprise_customer_links else None # Only want to show the first link +enterprise_customer_link = get_enterprise_learner_portal(request) %>

diff --git a/lms/templates/header/user_dropdown.html b/lms/templates/header/user_dropdown.html index 84bfc6aa27..8d82d62de3 100644 --- a/lms/templates/header/user_dropdown.html +++ b/lms/templates/header/user_dropdown.html @@ -12,7 +12,7 @@ from django.utils.translation import ugettext as _ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user from openedx.core.djangoapps.user_api.accounts.toggles import should_redirect_to_order_history_microfrontend from openedx.core.djangoapps.user_api.accounts.utils import retrieve_last_sitewide_block_completed -from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name, get_enterprise_learner_portals +from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name, get_enterprise_learner_portal %> <% @@ -22,10 +22,10 @@ profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium'] username = self.real_user.username resume_block = retrieve_last_sitewide_block_completed(self.real_user) displayname = get_enterprise_learner_generic_name(request) or username -enterprise_customer_portals = get_enterprise_learner_portals(request) +enterprise_customer_portal = get_enterprise_learner_portal(request) ## Enterprises with the learner portal enabled should not show order history, as it does ## not apply to the learner's method of purchasing content. -should_show_order_history = should_redirect_to_order_history_microfrontend() and not enterprise_customer_portals +should_show_order_history = should_redirect_to_order_history_microfrontend() and not enterprise_customer_portal %>