Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
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
1a9f7938
Commit
1a9f7938
authored
10 years ago
by
Will Daly
Browse files
Options
Downloads
Plain Diff
Merge pull request #4842 from edx/will/ecom-90
Use English for the marketing site buttons in an edx-controlled domain
parents
d54b347c
88ebac4f
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/tests/test_views.py
+53
-14
53 additions, 14 deletions
lms/djangoapps/courseware/tests/test_views.py
lms/djangoapps/courseware/views.py
+18
-2
18 additions, 2 deletions
lms/djangoapps/courseware/views.py
with
71 additions
and
16 deletions
lms/djangoapps/courseware/tests/test_views.py
+
53
−
14
View file @
1a9f7938
...
...
@@ -258,29 +258,44 @@ class ViewsTestCase(TestCase):
self
.
assertIn
(
'
Coming Soon
'
,
response
.
content
)
def
test_course_mktg_register
(
self
):
admin
=
AdminFactory
()
self
.
client
.
login
(
username
=
admin
.
username
,
password
=
'
test
'
)
url
=
reverse
(
'
mktg_about_course
'
,
kwargs
=
{
'
course_id
'
:
self
.
course_key
.
to_deprecated_string
()})
response
=
self
.
client
.
get
(
url
)
response
=
self
.
_load_mktg_about
()
self
.
assertIn
(
'
Register for
'
,
response
.
content
)
self
.
assertNotIn
(
'
and choose your student track
'
,
response
.
content
)
def
test_course_mktg_register_multiple_modes
(
self
):
admin
=
AdminFactory
()
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'
honor
'
,
mode_display_name
=
'
Honor Code Certificate
'
,
course_id
=
self
.
course_key
)
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'
verified
'
,
mode_display_name
=
'
Verified Certificate
'
,
course_id
=
self
.
course_key
)
self
.
client
.
login
(
username
=
admin
.
username
,
password
=
'
test
'
)
url
=
reverse
(
'
mktg_about_course
'
,
kwargs
=
{
'
course_id
'
:
self
.
course_key
.
to_deprecated_string
()})
response
=
self
.
client
.
get
(
url
)
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'
honor
'
,
mode_display_name
=
'
Honor Code Certificate
'
,
course_id
=
self
.
course_key
)
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'
verified
'
,
mode_display_name
=
'
Verified Certificate
'
,
course_id
=
self
.
course_key
)
response
=
self
.
_load_mktg_about
()
self
.
assertIn
(
'
Register for
'
,
response
.
content
)
self
.
assertIn
(
'
and choose your student track
'
,
response
.
content
)
# clean up course modes
CourseMode
.
objects
.
all
().
delete
()
@patch.dict
(
settings
.
FEATURES
,
{
'
IS_EDX_DOMAIN
'
:
True
})
def
test_mktg_about_language_edx_domain
(
self
):
# Since we're in an edx-controlled domain, and our marketing site
# supports only English, override the language setting
# and use English.
response
=
self
.
_load_mktg_about
(
language
=
'
eo
'
)
self
.
assertContains
(
response
,
"
Register for
"
)
@patch.dict
(
settings
.
FEATURES
,
{
'
IS_EDX_DOMAIN
'
:
False
})
def
test_mktg_about_language_openedx
(
self
):
# If we're in an OpenEdX installation,
# may want to support languages other than English,
# so respect the language code.
response
=
self
.
_load_mktg_about
(
language
=
'
eo
'
)
self
.
assertContains
(
response
,
u
"
Régïstér för
"
.
encode
(
'
utf-8
'
))
def
test_submission_history_accepts_valid_ids
(
self
):
# log into a staff account
admin
=
AdminFactory
()
...
...
@@ -320,6 +335,30 @@ class ViewsTestCase(TestCase):
response
=
self
.
client
.
get
(
url
)
self
.
assertFalse
(
'
<script>
'
in
response
.
content
)
def
_load_mktg_about
(
self
,
language
=
None
):
"""
Retrieve the marketing about button (iframed into the marketing site)
and return the HTTP response.
Keyword Args:
language (string): If provided, send this in the
'
Accept-Language
'
HTTP header.
Returns:
Response
"""
# Log in as an administrator to guarantee that we can access the button
admin
=
AdminFactory
()
self
.
client
.
login
(
username
=
admin
.
username
,
password
=
'
test
'
)
# If provided, set the language header
headers
=
{}
if
language
is
not
None
:
headers
[
'
HTTP_ACCEPT_LANGUAGE
'
]
=
language
url
=
reverse
(
'
mktg_about_course
'
,
kwargs
=
{
'
course_id
'
:
unicode
(
self
.
course_key
)})
return
self
.
client
.
get
(
url
,
**
headers
)
# setting TIME_ZONE_DISPLAYED_FOR_DEADLINES explicitly
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
,
TIME_ZONE_DISPLAYED_FOR_DEADLINES
=
"
UTC
"
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/views.py
+
18
−
2
View file @
1a9f7938
...
...
@@ -7,6 +7,7 @@ import urllib
import
json
from
collections
import
defaultdict
from
django.utils
import
translation
from
django.utils.translation
import
ugettext
as
_
from
django.conf
import
settings
...
...
@@ -710,15 +711,30 @@ def mktg_course_about(request, course_id):
settings
.
FEATURES
.
get
(
'
ENABLE_LMS_MIGRATION
'
))
course_modes
=
CourseMode
.
modes_for_course_dict
(
course
.
id
)
return
render_to_response
(
'
courseware/mktg_course_about.html
'
,
{
context
=
{
'
course
'
:
course
,
'
registered
'
:
registered
,
'
allow_registration
'
:
allow_registration
,
'
course_target
'
:
course_target
,
'
show_courseware_link
'
:
show_courseware_link
,
'
course_modes
'
:
course_modes
,
}
)
}
# The edx.org marketing site currently displays only in English.
# To avoid displaying a different language in the register / access button,
# we force the language to English.
# However, OpenEdX installations with a different marketing front-end
# may want to respect the language specified by the user or the site settings.
force_english
=
settings
.
FEATURES
.
get
(
'
IS_EDX_DOMAIN
'
,
False
)
if
force_english
:
translation
.
activate
(
'
en-us
'
)
try
:
return
render_to_response
(
'
courseware/mktg_course_about.html
'
,
context
)
finally
:
# Just to be safe, reset the language if we forced it to be English.
if
force_english
:
translation
.
deactivate
()
@login_required
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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