Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
9bb9d655
Unverified
Commit
9bb9d655
authored
4 years ago
by
Feanil Patel
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #24438 from edx/feanil/fix_url_link_map_logic_archbom-1336
Correct logic on building marketing links.
parents
a26b9317
4ac2c5e9
Branches
Branches containing commit
Tags
release-2020-07-09-11.20
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/edxmako/shortcuts.py
+5
-2
5 additions, 2 deletions
common/djangoapps/edxmako/shortcuts.py
common/djangoapps/edxmako/tests.py
+15
-0
15 additions, 0 deletions
common/djangoapps/edxmako/tests.py
with
20 additions
and
2 deletions
common/djangoapps/edxmako/shortcuts.py
+
5
−
2
View file @
9bb9d655
...
...
@@ -24,6 +24,7 @@ from six.moves.urllib.parse import urljoin
from
django.core.validators
import
URLValidator
from
django.core.exceptions
import
ValidationError
from
edx_django_utils.monitoring
import
set_custom_metric
from
openedx.core.djangoapps.site_configuration
import
helpers
as
configuration_helpers
from
openedx.core.djangoapps.theming.helpers
import
is_request_in_themed_site
from
xmodule.util.xmodule_django
import
get_current_request_hostname
...
...
@@ -87,13 +88,15 @@ def marketing_link(name):
# don't try to reverse disabled marketing links
if
link_map
[
name
]
is
not
None
:
host_name
=
get_current_request_hostname
()
if
all
([
host_name
and
'
edge
'
in
host_name
,
'
http
'
in
link_map
[
name
]]
):
if
link_map
[
name
].
startswith
(
'
http
'
):
return
link_map
[
name
]
else
:
try
:
return
reverse
(
link_map
[
name
])
except
NoReverseMatch
:
raise
Http404
log
.
debug
(
u
"
Cannot find corresponding link for name: %s
"
,
name
)
set_custom_metric
(
'
unresolved_marketing_link
'
,
name
)
return
'
#
'
else
:
log
.
debug
(
u
"
Cannot find corresponding link for name: %s
"
,
name
)
return
'
#
'
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/edxmako/tests.py
+
15
−
0
View file @
9bb9d655
...
...
@@ -98,6 +98,21 @@ class ShortcutsTests(UrlResetMixin, TestCase):
link
=
marketing_link
(
'
TOS
'
)
self
.
assertEqual
(
link
,
expected_link
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'
lms.urls
'
,
'
Test only valid in lms
'
)
def
test_link_map_url_reverse
(
self
):
url_link_map
=
{
'
ABOUT
'
:
'
dashboard
'
,
'
BAD_URL
'
:
'
foobarbaz
'
,
}
with
patch
.
dict
(
'
django.conf.settings.FEATURES
'
,
{
'
ENABLE_MKTG_SITE
'
:
False
}):
with
override_settings
(
MKTG_URL_LINK_MAP
=
url_link_map
):
link
=
marketing_link
(
'
ABOUT
'
)
assert
link
==
'
/dashboard
'
link
=
marketing_link
(
'
BAD_URL
'
)
assert
link
==
'
#
'
class
AddLookupTests
(
TestCase
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment