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
8f6182aa
Commit
8f6182aa
authored
Sep 20, 2016
by
Douglas Hall
Committed by
Douglas Hall
Sep 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow for site override of MKTG_URLS setting in index view
parent
a9939fa1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
14 deletions
+32
-14
common/djangoapps/edxmako/shortcuts.py
+23
-5
common/djangoapps/edxmako/tests.py
+4
-4
lms/djangoapps/branding/views.py
+5
-1
lms/djangoapps/shoppingcart/tests/test_configuration_overrides.py
+0
-4
No files found.
common/djangoapps/edxmako/shortcuts.py
View file @
8f6182aa
...
...
@@ -13,6 +13,7 @@
# limitations under the License.
import
logging
from
urlparse
import
urljoin
from
django.http
import
HttpResponse
from
django.template
import
Context
...
...
@@ -42,12 +43,20 @@ def marketing_link(name):
'ENABLE_MKTG_SITE'
,
settings
.
FEATURES
.
get
(
'ENABLE_MKTG_SITE'
,
False
)
)
marketing_urls
=
configuration_helpers
.
get_value
(
'MKTG_URLS'
,
settings
.
MKTG_URLS
)
if
enable_mktg_site
and
name
in
settings
.
MKTG_URLS
:
if
enable_mktg_site
and
name
in
marketing_urls
:
# special case for when we only want the root marketing URL
if
name
==
'ROOT'
:
return
settings
.
MKTG_URLS
.
get
(
'ROOT'
)
return
settings
.
MKTG_URLS
.
get
(
'ROOT'
)
+
settings
.
MKTG_URLS
.
get
(
name
)
return
marketing_urls
.
get
(
'ROOT'
)
# Using urljoin here allows us to enable a marketing site and set
# a site ROOT, but still specify absolute URLs for other marketing
# URLs in the MKTG_URLS setting
# e.g. urljoin('http://marketing.com', 'http://open-edx.org/about') >>> 'http://open-edx.org/about'
return
urljoin
(
marketing_urls
.
get
(
'ROOT'
),
marketing_urls
.
get
(
name
))
# only link to the old pages when the marketing site isn't on
elif
not
enable_mktg_site
and
name
in
link_map
:
# don't try to reverse disabled marketing links
...
...
@@ -75,9 +84,13 @@ def is_marketing_link_set(name):
'ENABLE_MKTG_SITE'
,
settings
.
FEATURES
.
get
(
'ENABLE_MKTG_SITE'
,
False
)
)
marketing_urls
=
configuration_helpers
.
get_value
(
'MKTG_URLS'
,
settings
.
MKTG_URLS
)
if
enable_mktg_site
:
return
name
in
settings
.
MKTG_URLS
return
name
in
marketing_urls
else
:
return
name
in
settings
.
MKTG_URL_LINK_MAP
...
...
@@ -91,12 +104,17 @@ def marketing_link_context_processor(request):
'MKTG_URL_' and whose values are the corresponding URLs as computed by the
marketing_link method.
"""
marketing_urls
=
configuration_helpers
.
get_value
(
'MKTG_URLS'
,
settings
.
MKTG_URLS
)
return
dict
(
[
(
"MKTG_URL_"
+
k
,
marketing_link
(
k
))
for
k
in
(
settings
.
MKTG_URL_LINK_MAP
.
viewkeys
()
|
settings
.
MKTG_URLS
.
viewkeys
()
marketing_urls
.
viewkeys
()
)
]
)
...
...
common/djangoapps/edxmako/tests.py
View file @
8f6182aa
...
...
@@ -27,12 +27,12 @@ class ShortcutsTests(UrlResetMixin, TestCase):
"""
Test the edxmako shortcuts file
"""
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'
https://
dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URL_LINK_MAP
=
{
'ABOUT'
:
'login'
})
def
test_marketing_link
(
self
):
# test marketing site on
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_MKTG_SITE'
:
True
}):
expected_link
=
'dummy-root/about-us'
expected_link
=
'
https://
dummy-root/about-us'
link
=
marketing_link
(
'ABOUT'
)
self
.
assertEquals
(
link
,
expected_link
)
# test marketing site off
...
...
@@ -42,7 +42,7 @@ class ShortcutsTests(UrlResetMixin, TestCase):
link
=
marketing_link
(
'ABOUT'
)
self
.
assertEquals
(
link
,
expected_link
)
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'
https://
dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URL_LINK_MAP
=
{
'ABOUT'
:
'login'
})
def
test_is_marketing_link_set
(
self
):
# test marketing site on
...
...
@@ -54,7 +54,7 @@ class ShortcutsTests(UrlResetMixin, TestCase):
self
.
assertTrue
(
is_marketing_link_set
(
'ABOUT'
))
self
.
assertFalse
(
is_marketing_link_set
(
'NOT_CONFIGURED'
))
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URLS
=
{
'ROOT'
:
'
https://
dummy-root'
,
'ABOUT'
:
'/about-us'
})
@override_settings
(
MKTG_URL_LINK_MAP
=
{
'ABOUT'
:
'login'
})
def
test_is_any_marketing_link_set
(
self
):
# test marketing site on
...
...
lms/djangoapps/branding/views.py
View file @
8f6182aa
...
...
@@ -76,7 +76,11 @@ def index(request):
)
if
enable_mktg_site
:
return
redirect
(
settings
.
MKTG_URLS
.
get
(
'ROOT'
))
marketing_urls
=
configuration_helpers
.
get_value
(
'MKTG_URLS'
,
settings
.
MKTG_URLS
)
return
redirect
(
marketing_urls
.
get
(
'ROOT'
))
domain
=
request
.
META
.
get
(
'HTTP_HOST'
)
...
...
lms/djangoapps/shoppingcart/tests/test_configuration_overrides.py
View file @
8f6182aa
...
...
@@ -117,8 +117,6 @@ class TestOrderHistoryOnSiteDashboard(ModuleStoreTestCase):
cart
.
purchase
(
first
=
'FirstNameTesting123'
,
street1
=
'StreetTesting123'
)
self
.
courseless_donation_order_id
=
cart
.
id
@mock.patch
(
"openedx.core.djangoapps.site_configuration.helpers.get_value"
,
fake_site
)
@mock.patch
(
"openedx.core.djangoapps.site_configuration.helpers.get_all_orgs"
,
fake_all_orgs
)
def
test_shows_orders_with_current_site_courses_only
(
self
):
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
"password"
)
response
=
self
.
client
.
get
(
reverse
(
"dashboard"
))
...
...
@@ -136,8 +134,6 @@ class TestOrderHistoryOnSiteDashboard(ModuleStoreTestCase):
self
.
assertNotIn
(
receipt_url_cert
,
content
)
self
.
assertNotIn
(
receipt_url_donation
,
content
)
@mock.patch
(
"openedx.core.djangoapps.site_configuration.helpers.get_value"
,
mock
.
Mock
(
return_value
=
None
))
@mock.patch
(
"openedx.core.djangoapps.site_configuration.helpers.get_all_orgs"
,
fake_all_orgs
)
def
test_shows_orders_with_non_site_courses_only_when_no_configuration_override_exists
(
self
):
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
"password"
)
response
=
self
.
client
.
get
(
reverse
(
"dashboard"
))
...
...
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