ENT-3143: display message banner guiding user to their enterprise LP if enabled (#24625)
* display message banner guiding user to their enterprise LP if enabled * adding new sass class name to use same styling as recovery email alert
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
urgency: 'high',
|
||||
type: '',
|
||||
hideCloseBtn: true,
|
||||
isRecoveryEmailMsg: false
|
||||
isRecoveryEmailMsg: false,
|
||||
isLearnerPortalEnabled: false
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -114,7 +114,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
&.recovery-email-alert {
|
||||
&.recovery-email-alert,
|
||||
&.learner-portal-enabled-alert {
|
||||
&#banner-msg {
|
||||
background: $state-info-bg;
|
||||
box-shadow: none;
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user