diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index b7e1bd97722f7687b45256ff22d9a20d0d189e48..d4b846546fab2c56a7563f3992cd7e7bfbf3f6b9 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -44,7 +44,10 @@ from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_f from openedx.core.djangoapps.util.maintenance_banner import add_maintenance_banner from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace from openedx.core.djangolib.markup import HTML, Text -from openedx.features.enterprise_support.api import get_dashboard_consent_notification +from openedx.features.enterprise_support.api import ( + get_dashboard_consent_notification, + get_enterprise_learner_portal_enabled_message, +) from shoppingcart.models import DonationConfiguration from student.api import COURSE_DASHBOARD_PLUGIN_VIEW_NAME from student.helpers import cert_info, check_verify_status_by_course, get_resume_urls_for_enrollments @@ -623,6 +626,9 @@ def student_dashboard(request): enterprise_message = get_dashboard_consent_notification(request, user, course_enrollments) + # Display a message guiding the user to their Enterprise's Learner Portal if enabled + enterprise_learner_portal_enabled_message = get_enterprise_learner_portal_enabled_message(request) + recovery_email_message = recovery_email_activation_message = None if is_secondary_email_feature_enabled(): try: @@ -833,6 +839,7 @@ def student_dashboard(request): 'empty_dashboard_message': empty_dashboard_message, 'recovery_email_message': recovery_email_message, 'recovery_email_activation_message': recovery_email_activation_message, + 'enterprise_learner_portal_enabled_message': enterprise_learner_portal_enabled_message, 'show_load_all_courses_link': show_load_all_courses_link(user, course_limit, course_enrollments), # TODO START: clean up as part of REVEM-199 (START) 'course_info': get_dashboard_course_info(user, course_enrollments), diff --git a/lms/static/js/views/message_banner.js b/lms/static/js/views/message_banner.js index 17560de5d416cb1597b2ce29fcbf13123c7dcf95..d7d9729fd2bc7e6a88f569a04d68cc65156e6486 100644 --- a/lms/static/js/views/message_banner.js +++ b/lms/static/js/views/message_banner.js @@ -27,7 +27,8 @@ urgency: 'high', type: '', hideCloseBtn: true, - isRecoveryEmailMsg: false + isRecoveryEmailMsg: false, + isLearnerPortalEnabled: false }); }, diff --git a/lms/static/sass/elements/_system-feedback.scss b/lms/static/sass/elements/_system-feedback.scss index 27602c9460cd747fcb72bdfe4b6502ff66ad3aa6..be359388500833516adc10fa43e734852502b2ea 100644 --- a/lms/static/sass/elements/_system-feedback.scss +++ b/lms/static/sass/elements/_system-feedback.scss @@ -114,7 +114,8 @@ } } - &.recovery-email-alert { + &.recovery-email-alert, + &.learner-portal-enabled-alert { &#banner-msg { background: $state-info-bg; box-shadow: none; diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index dcc03a6de756f633c732028eed4456b13bb8716b..2721a6bd27bd968028b220c9cf558b138f3ca93b 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -99,6 +99,13 @@ from student.models import CourseEnrollment banner.showMessage(${recovery_email_activation_message | n, dump_js_escaped_json}) </%static:require_module> % endif + % if enterprise_learner_portal_enabled_message: + <%static:require_module module_name="js/views/message_banner" class_name="MessageBannerView"> + var banner = new MessageBannerView({urgency: 'low', type: 'warning', isLearnerPortalEnabled: true}); + $('#content').prepend(banner.$el); + banner.showMessage(${enterprise_learner_portal_enabled_message | n, dump_js_escaped_json}) + </%static:require_module> + % endif </%block> <div class="dashboard-notifications" tabindex="-1"> diff --git a/lms/templates/fields/message_banner.underscore b/lms/templates/fields/message_banner.underscore index 23e01bb2d48daf485763d5bd2c3dbfcbd960607d..dc019c5d030595a704a72ebd8b261ed43ce71692 100644 --- a/lms/templates/fields/message_banner.underscore +++ b/lms/templates/fields/message_banner.underscore @@ -1,4 +1,4 @@ -<div id="banner-msg" class="wrapper-msg urgency-<%- urgency %> <%- type %> <% if (isRecoveryEmailMsg == true) { %> recovery-email-alert <% } %>" role="alert"> +<div id="banner-msg" class="wrapper-msg urgency-<%- urgency %> <%- type %> <% if (isRecoveryEmailMsg == true) { %> recovery-email-alert <% } %> <% if (isLearnerPortalEnabled == true) { %> learner-portal-enabled-alert <% } %>" role="alert"> <i <% if (hideCloseBtn == true) { %> hidden <% } %> id="close" class="fa fa-close close-icon"></i> <div class="msg"> <div class="msg-content"> diff --git a/openedx/features/enterprise_support/api.py b/openedx/features/enterprise_support/api.py index 6aef2315baa66b2c28e5b9c8f2f8d3e38a804669..45b1df59c3f90736b8b20d89cdd3bfee7a2f7964 100644 --- a/openedx/features/enterprise_support/api.py +++ b/openedx/features/enterprise_support/api.py @@ -23,6 +23,7 @@ from slumber.exceptions import HttpClientError, HttpNotFoundError, HttpServerErr from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers +from openedx.core.djangolib.markup import HTML, Text from openedx.features.enterprise_support.utils import get_data_consent_share_cache_key from third_party_auth.pipeline import get as get_partial_pipeline from third_party_auth.provider import Registry @@ -569,6 +570,45 @@ def get_enterprise_learner_data(user): return enterprise_learner_data['results'] +@enterprise_is_enabled() +def get_enterprise_learner_portal_enabled_message(request): + """ + Returns message to be displayed in dashboard if the user is linked to an Enterprise with the Learner Portal enabled. + + Note: request.session['enterprise_customer'] will be used in case the user is linked to + multiple Enterprises. Otherwise, it won't exist and the Enterprise Learner data + will be used. If that doesn't exist return None. + + Args: + request: request made to the LMS dashboard + """ + if request.session['enterprise_customer']: + enterprise_customer = request.session['enterprise_customer'] + else: + learner_data = get_enterprise_learner_data(request.user) + if learner_data: + enterprise_customer = learner_data[0]['enterprise_customer'] + else: + return None + + if enterprise_customer['enable_learner_portal']: + learner_portal_url = settings.ENTERPRISE_LEARNER_PORTAL_BASE_URL + '/' + enterprise_customer['slug'] + return Text(_( + "Your organization {bold_start}{enterprise_customer_name}{bold_end} uses a custom dashboard for learning. " + "{link_start}Click here{link_end} to continue in that experience." + )).format( + enterprise_customer_name=enterprise_customer['name'], + link_start=HTML("<a href='{learner_portal_url}'>").format( + learner_portal_url=learner_portal_url, + ), + link_end=HTML("</a>"), + bold_start=HTML("<b>"), + bold_end=HTML("</b>"), + ) + else: + return None + + def get_consent_notification_data(enterprise_customer): """ Returns the consent notification data from DataSharingConsentPage modal diff --git a/themes/edx.org/lms/templates/dashboard.html b/themes/edx.org/lms/templates/dashboard.html index 6c17bdc91c1676447623f1186856faeddfafaf68..577c8c8035a5aac40a6aad025cc05deff56895cd 100644 --- a/themes/edx.org/lms/templates/dashboard.html +++ b/themes/edx.org/lms/templates/dashboard.html @@ -104,6 +104,13 @@ from student.models import CourseEnrollment banner.showMessage(${recovery_email_activation_message | n, dump_js_escaped_json}) </%static:require_module> % endif + % if enterprise_learner_portal_enabled_message: + <%static:require_module module_name="js/views/message_banner" class_name="MessageBannerView"> + var banner = new MessageBannerView({urgency: 'low', type: 'warning', isLearnerPortalEnabled: true}); + $('#content').prepend(banner.$el); + banner.showMessage(${enterprise_learner_portal_enabled_message | n, dump_js_escaped_json}) + </%static:require_module> + % endif </%block> <div class="dashboard-notifications" tabindex="-1">