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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user