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
88ebac4f
Commit
88ebac4f
authored
Aug 14, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use English for the marketing site buttons in an edx-controlled domain
parent
2ca86a8d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
14 deletions
+69
-14
lms/djangoapps/courseware/tests/test_views.py
+51
-12
lms/djangoapps/courseware/views.py
+18
-2
No files found.
lms/djangoapps/courseware/tests/test_views.py
View file @
88ebac4f
...
...
@@ -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'
,
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'
,
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
)
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"
)
...
...
lms/djangoapps/courseware/views.py
View file @
88ebac4f
...
...
@@ -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
)
...
...
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