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
1a9f7938
Commit
1a9f7938
authored
Aug 15, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
16 deletions
+71
-16
lms/djangoapps/courseware/tests/test_views.py
+53
-14
lms/djangoapps/courseware/views.py
+18
-2
No files found.
lms/djangoapps/courseware/tests/test_views.py
View file @
1a9f7938
...
@@ -258,29 +258,44 @@ class ViewsTestCase(TestCase):
...
@@ -258,29 +258,44 @@ class ViewsTestCase(TestCase):
self
.
assertIn
(
'Coming Soon'
,
response
.
content
)
self
.
assertIn
(
'Coming Soon'
,
response
.
content
)
def
test_course_mktg_register
(
self
):
def
test_course_mktg_register
(
self
):
admin
=
AdminFactory
()
response
=
self
.
_load_mktg_about
()
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
)
self
.
assertIn
(
'Register for'
,
response
.
content
)
self
.
assertIn
(
'Register for'
,
response
.
content
)
self
.
assertNotIn
(
'and choose your student track'
,
response
.
content
)
self
.
assertNotIn
(
'and choose your student track'
,
response
.
content
)
def
test_course_mktg_register_multiple_modes
(
self
):
def
test_course_mktg_register_multiple_modes
(
self
):
admin
=
AdminFactory
()
CourseMode
.
objects
.
get_or_create
(
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'honor'
,
mode_slug
=
'honor'
,
mode_display_name
=
'Honor Code Certificate'
,
mode_display_name
=
'Honor Code Certificate'
,
course_id
=
self
.
course_key
)
course_id
=
self
.
course_key
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'verified'
,
)
mode_display_name
=
'Verified Certificate'
,
CourseMode
.
objects
.
get_or_create
(
course_id
=
self
.
course_key
)
mode_slug
=
'verified'
,
self
.
client
.
login
(
username
=
admin
.
username
,
password
=
'test'
)
mode_display_name
=
'Verified Certificate'
,
url
=
reverse
(
'mktg_about_course'
,
kwargs
=
{
'course_id'
:
self
.
course_key
.
to_deprecated_string
()})
course_id
=
self
.
course_key
response
=
self
.
client
.
get
(
url
)
)
response
=
self
.
_load_mktg_about
()
self
.
assertIn
(
'Register for'
,
response
.
content
)
self
.
assertIn
(
'Register for'
,
response
.
content
)
self
.
assertIn
(
'and choose your student track'
,
response
.
content
)
self
.
assertIn
(
'and choose your student track'
,
response
.
content
)
# clean up course modes
# clean up course modes
CourseMode
.
objects
.
all
()
.
delete
()
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
):
def
test_submission_history_accepts_valid_ids
(
self
):
# log into a staff account
# log into a staff account
admin
=
AdminFactory
()
admin
=
AdminFactory
()
...
@@ -320,6 +335,30 @@ class ViewsTestCase(TestCase):
...
@@ -320,6 +335,30 @@ class ViewsTestCase(TestCase):
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertFalse
(
'<script>'
in
response
.
content
)
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
# setting TIME_ZONE_DISPLAYED_FOR_DEADLINES explicitly
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
,
TIME_ZONE_DISPLAYED_FOR_DEADLINES
=
"UTC"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
,
TIME_ZONE_DISPLAYED_FOR_DEADLINES
=
"UTC"
)
...
...
lms/djangoapps/courseware/views.py
View file @
1a9f7938
...
@@ -7,6 +7,7 @@ import urllib
...
@@ -7,6 +7,7 @@ import urllib
import
json
import
json
from
collections
import
defaultdict
from
collections
import
defaultdict
from
django.utils
import
translation
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -710,15 +711,30 @@ def mktg_course_about(request, course_id):
...
@@ -710,15 +711,30 @@ def mktg_course_about(request, course_id):
settings
.
FEATURES
.
get
(
'ENABLE_LMS_MIGRATION'
))
settings
.
FEATURES
.
get
(
'ENABLE_LMS_MIGRATION'
))
course_modes
=
CourseMode
.
modes_for_course_dict
(
course
.
id
)
course_modes
=
CourseMode
.
modes_for_course_dict
(
course
.
id
)
return
render_to_response
(
'courseware/mktg_course_about.html'
,
{
context
=
{
'course'
:
course
,
'course'
:
course
,
'registered'
:
registered
,
'registered'
:
registered
,
'allow_registration'
:
allow_registration
,
'allow_registration'
:
allow_registration
,
'course_target'
:
course_target
,
'course_target'
:
course_target
,
'show_courseware_link'
:
show_courseware_link
,
'show_courseware_link'
:
show_courseware_link
,
'course_modes'
:
course_modes
,
'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
@login_required
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
...
...
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