ENT-32 Show enterprise customer branding on Logistration.
nit: css
This commit is contained in:
@@ -60,6 +60,7 @@ class FieldOverridePerformanceTestCase(FieldOverrideTestMixin, ProceduralCourseT
|
||||
self.request_factory = RequestFactory()
|
||||
self.student = UserFactory.create()
|
||||
self.request = self.request_factory.get("foo")
|
||||
self.request.session = {}
|
||||
self.request.user = self.student
|
||||
|
||||
patcher = mock.patch('edxmako.request_context.get_current_request', return_value=self.request)
|
||||
|
||||
@@ -47,6 +47,7 @@ from third_party_auth import pipeline
|
||||
from third_party_auth.decorators import xframe_allow_whitelisted
|
||||
from util.bad_request_rate_limiter import BadRequestRateLimiter
|
||||
from util.date_utils import strftime_localized
|
||||
from util.enterprise_helpers import set_enterprise_branding_filter_param
|
||||
|
||||
AUDIT_LOG = logging.getLogger("audit")
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -68,7 +69,6 @@ def login_and_registration_form(request, initial_mode="login"):
|
||||
"""
|
||||
# Determine the URL to redirect to following login/registration/third_party_auth
|
||||
redirect_to = get_next_url_for_login_page(request)
|
||||
|
||||
# If we're already logged in, redirect to the dashboard
|
||||
if request.user.is_authenticated():
|
||||
return redirect(redirect_to)
|
||||
@@ -76,6 +76,21 @@ def login_and_registration_form(request, initial_mode="login"):
|
||||
# Retrieve the form descriptions from the user API
|
||||
form_descriptions = _get_form_descriptions(request)
|
||||
|
||||
# Our ?next= URL may itself contain a parameter 'tpa_hint=x' that we need to check.
|
||||
# If present, we display a login page focused on third-party auth with that provider.
|
||||
third_party_auth_hint = None
|
||||
if '?' in redirect_to:
|
||||
try:
|
||||
next_args = urlparse.parse_qs(urlparse.urlparse(redirect_to).query)
|
||||
provider_id = next_args['tpa_hint'][0]
|
||||
if third_party_auth.provider.Registry.get(provider_id=provider_id):
|
||||
third_party_auth_hint = provider_id
|
||||
initial_mode = "hinted_login"
|
||||
except (KeyError, ValueError, IndexError):
|
||||
pass
|
||||
|
||||
set_enterprise_branding_filter_param(request=request, provider_id=third_party_auth_hint)
|
||||
|
||||
# If this is a themed site, revert to the old login/registration pages.
|
||||
# We need to do this for now to support existing themes.
|
||||
# Themed sites can use the new logistration page by setting
|
||||
@@ -92,19 +107,6 @@ def login_and_registration_form(request, initial_mode="login"):
|
||||
if ext_auth_response is not None:
|
||||
return ext_auth_response
|
||||
|
||||
# Our ?next= URL may itself contain a parameter 'tpa_hint=x' that we need to check.
|
||||
# If present, we display a login page focused on third-party auth with that provider.
|
||||
third_party_auth_hint = None
|
||||
if '?' in redirect_to:
|
||||
try:
|
||||
next_args = urlparse.parse_qs(urlparse.urlparse(redirect_to).query)
|
||||
provider_id = next_args['tpa_hint'][0]
|
||||
if third_party_auth.provider.Registry.get(provider_id=provider_id):
|
||||
third_party_auth_hint = provider_id
|
||||
initial_mode = "hinted_login"
|
||||
except (KeyError, ValueError, IndexError):
|
||||
pass
|
||||
|
||||
# Otherwise, render the combined login/registration page
|
||||
context = {
|
||||
'data': {
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
|
||||
img {
|
||||
height: 30px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
img.ec-logo-size {
|
||||
width: 84px;
|
||||
height: 56px;
|
||||
}
|
||||
}
|
||||
|
||||
nav {
|
||||
|
||||
@@ -14,6 +14,7 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
from branding import api as branding_api
|
||||
# app that handles site status messages
|
||||
from status.status import get_site_status_msg
|
||||
from util.enterprise_helpers import get_enterprise_customer_logo_url
|
||||
%>
|
||||
|
||||
## Provide a hook for themes to inject branding on top.
|
||||
@@ -51,7 +52,14 @@ site_status_msg = get_site_status_msg(course_id)
|
||||
<h1 class="logo">
|
||||
<a href="${marketing_link('ROOT')}">
|
||||
<%block name="navigation_logo">
|
||||
<img src="${branding_api.get_logo_url(is_secure)}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}"/>
|
||||
<%
|
||||
logo_url = get_enterprise_customer_logo_url(request)
|
||||
logo_size = 'ec-logo-size'
|
||||
if logo_url is None:
|
||||
logo_url = branding_api.get_logo_url(is_secure)
|
||||
logo_size = ''
|
||||
%>
|
||||
<img class="${logo_size}" src="${logo_url}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}"/>
|
||||
</%block>
|
||||
</a>
|
||||
</h1>
|
||||
|
||||
Reference in New Issue
Block a user