Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6d7e583e
Commit
6d7e583e
authored
Dec 20, 2017
by
zubair-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move the method for updating the context of third party auth to openedx enterprise utils
parent
f3318465
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
31 deletions
+43
-31
lms/djangoapps/student_account/views.py
+2
-31
openedx/features/enterprise_support/utils.py
+41
-0
No files found.
lms/djangoapps/student_account/views.py
View file @
6d7e583e
...
...
@@ -37,10 +37,10 @@ from openedx.core.djangoapps.user_api.errors import (
UserNotFound
,
UserAPIInternalError
)
from
openedx.core.djangolib.markup
import
HTML
,
Text
from
openedx.core.lib.edx_api_utils
import
get_edx_api_data
from
openedx.core.lib.time_zone_utils
import
TIME_ZONE_CHOICES
from
openedx.features.enterprise_support.api
import
enterprise_customer_for_request
,
get_enterprise_learner_data
from
openedx.features.enterprise_support.utils
import
update_third_party_auth_context_for_enterprise
from
student.helpers
import
destroy_oauth_tokens
,
get_next_url_for_login_page
from
student.models
import
UserProfile
from
student.views
import
register_user
as
old_register_view
...
...
@@ -381,36 +381,7 @@ def _third_party_auth_context(request, redirect_to, tpa_hint=None):
context
[
'errorMessage'
]
=
_
(
unicode
(
msg
))
# pylint: disable=translation-of-non-string
break
context
=
_update_context_for_enterprise_error_message
(
context
,
enterprise_customer
)
return
context
def
_update_context_for_enterprise_error_message
(
context
,
enterprise_customer
=
None
):
"""
Return updated context with modified `errorMessage` for enterprise.
"""
if
enterprise_customer
and
context
[
'errorMessage'
]:
context
[
'errorMessage'
]
=
Text
(
_
(
u'We are sorry, you are not authorized to access {platform_name} via this channel. '
u'Please contact your {enterprise} administrator in order to access {platform_name} '
u'or contact {edx_support_link}.{line_break}'
u'{line_break}'
u'Error Details:{line_break}{error_message}'
)
)
.
format
(
platform_name
=
configuration_helpers
.
get_value
(
'PLATFORM_NAME'
,
settings
.
PLATFORM_NAME
),
enterprise
=
enterprise_customer
[
'name'
],
error_message
=
context
[
'errorMessage'
],
edx_support_link
=
HTML
(
'<a href="{edx_support_url}">{support_url_name}</a>'
)
.
format
(
edx_support_url
=
configuration_helpers
.
get_value
(
'SUPPORT_SITE_LINK'
,
settings
.
SUPPORT_SITE_LINK
),
support_url_name
=
_
(
'edX Support'
),
),
line_break
=
HTML
(
'<br/>'
)
)
context
=
update_third_party_auth_context_for_enterprise
(
context
,
enterprise_customer
)
return
context
...
...
openedx/features/enterprise_support/utils.py
View file @
6d7e583e
...
...
@@ -3,6 +3,10 @@ from __future__ import unicode_literals
import
hashlib
import
six
from
django.conf
import
settings
from
django.utils.translation
import
ugettext
as
_
from
openedx.core.djangoapps.site_configuration
import
helpers
as
configuration_helpers
from
openedx.core.djangolib.markup
import
HTML
,
Text
def
get_cache_key
(
**
kwargs
):
...
...
@@ -27,3 +31,40 @@ def get_cache_key(**kwargs):
key
=
'__'
.
join
([
'{}:{}'
.
format
(
item
,
value
)
for
item
,
value
in
six
.
iteritems
(
kwargs
)])
return
hashlib
.
md5
(
key
)
.
hexdigest
()
def
update_third_party_auth_context_for_enterprise
(
context
,
enterprise_customer
=
None
):
"""
Return updated context of third party auth with modified for enterprise.
Arguments:
context (dict): Context for third party auth providers and auth pipeline.
enterprise_customer (dict): data for enterprise customer
Returns:
context (dict): Updated context of third party auth with modified
`errorMessage`.
"""
if
enterprise_customer
and
context
[
'errorMessage'
]:
context
[
'errorMessage'
]
=
Text
(
_
(
u'We are sorry, you are not authorized to access {platform_name} via this channel. '
u'Please contact your {enterprise} administrator in order to access {platform_name} '
u'or contact {edx_support_link}.{line_break}'
u'{line_break}'
u'Error Details:{line_break}{error_message}'
)
)
.
format
(
platform_name
=
configuration_helpers
.
get_value
(
'PLATFORM_NAME'
,
settings
.
PLATFORM_NAME
),
enterprise
=
enterprise_customer
[
'name'
],
error_message
=
context
[
'errorMessage'
],
edx_support_link
=
HTML
(
'<a href="{edx_support_url}">{support_url_name}</a>'
)
.
format
(
edx_support_url
=
configuration_helpers
.
get_value
(
'SUPPORT_SITE_LINK'
,
settings
.
SUPPORT_SITE_LINK
),
support_url_name
=
_
(
'edX Support'
),
),
line_break
=
HTML
(
'<br/>'
)
)
return
context
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment