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
0172ff31
Commit
0172ff31
authored
May 16, 2017
by
Anthony Mangano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ability to show footer language selector on LMS
parent
6129494a
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
93 additions
and
34 deletions
+93
-34
cms/envs/bok_choy.env.json
+1
-1
cms/envs/common.py
+2
-2
cms/templates/widgets/header.html
+3
-2
common/djangoapps/pipeline_mako/templates/static_content.html
+0
-9
lms/envs/bok_choy.env.json
+1
-1
lms/envs/common.py
+5
-2
lms/envs/devstack_docker.py
+1
-1
lms/templates/footer.html
+3
-2
lms/templates/navigation.html
+3
-2
lms/templates/widgets/footer-language-selector.html
+5
-2
openedx/core/djangoapps/lang_pref/api.py
+17
-0
openedx/core/djangoapps/lang_pref/tests/test_api.py
+41
-1
themes/edx.org/lms/templates/footer.html
+3
-2
themes/red-theme/lms/templates/footer.html
+3
-2
themes/stanford-style/lms/templates/footer.html
+5
-5
No files found.
cms/envs/bok_choy.env.json
View file @
0172ff31
...
...
@@ -75,7 +75,7 @@
"PREVIEW_LMS_BASE"
:
"preview.localhost:8003"
,
"ENABLE_CONTENT_LIBRARIES"
:
true
,
"ENABLE_SPECIAL_EXAMS"
:
true
,
"SHOW_LANGUAGE_SELECTOR"
:
true
,
"SHOW_
HEADER_
LANGUAGE_SELECTOR"
:
true
,
"ENABLE_EXTENDED_COURSE_DETAILS"
:
true
,
"CUSTOM_COURSES_EDX"
:
true
},
...
...
cms/envs/common.py
View file @
0172ff31
...
...
@@ -227,8 +227,8 @@ FEATURES = {
'ORGANIZATIONS_APP'
:
False
,
# Show
Language selecto
r
'SHOW_LANGUAGE_SELECTOR'
:
False
,
# Show
the language selector in the heade
r
'SHOW_
HEADER_
LANGUAGE_SELECTOR'
:
False
,
# Set this to False to facilitate cleaning up invalid xml from your modulestore.
'ENABLE_XBLOCK_XML_VALIDATION'
:
True
,
...
...
cms/templates/widgets/header.html
View file @
0172ff31
...
...
@@ -4,6 +4,7 @@
from
django
.
conf
import
settings
from
django
.
core
.
urlresolvers
import
reverse
from
django
.
utils
.
translation
import
ugettext
as
_
from
openedx
.
core
.
djangoapps
.
lang_pref
.
api
import
header_language_selector_is_enabled
,
released_languages
%
>
<div
class=
"wrapper-header wrapper"
id=
"view-top"
>
<header
class=
"primary"
role=
"banner"
>
...
...
@@ -183,8 +184,8 @@
</div>
<div
class=
"wrapper wrapper-r"
>
% if
static.show_language_selector
():
<
%
languages =
static.get_
released_languages()
%
>
% if
header_language_selector_is_enabled
():
<
%
languages =
released_languages()
%
>
% if len(languages) > 1:
<nav
class=
"user-language-selector"
aria-label=
"${_('Language preference')}"
>
<form
action=
"/i18n/setlang/"
method=
"post"
class=
"settings-language-form"
id=
"language-settings-form"
>
...
...
common/djangoapps/pipeline_mako/templates/static_content.html
View file @
0172ff31
...
...
@@ -18,7 +18,6 @@ from openedx.core.djangoapps.theming.helpers import (
is_request_in_themed_site
,
)
from
certificates
.
api
import
get_asset_url_by_slug
from
openedx
.
core
.
djangoapps
.
lang_pref
.
api
import
released_languages
logger =
logging.getLogger(__name__)
%
>
...
...
@@ -194,11 +193,3 @@ else:
<
%
def
name=
"get_tech_support_email_address()"
><
%
return
get_value
('
email_from_address
',
settings
.
TECH_SUPPORT_EMAIL
)
%
></
%
def>
<
%
def
name=
"show_language_selector()"
><
%
return
get_value
('
SHOW_LANGUAGE_SELECTOR
',
settings
.
FEATURES
.
get
('
SHOW_LANGUAGE_SELECTOR
',
False
))
%
></
%
def>
<
%
def
name=
"get_released_languages()"
><
%
return
released_languages
()
%
></
%
def>
lms/envs/bok_choy.env.json
View file @
0172ff31
...
...
@@ -88,7 +88,7 @@
"AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING"
:
true
,
"ENABLE_COURSE_DISCOVERY"
:
true
,
"ENABLE_SPECIAL_EXAMS"
:
true
,
"SHOW_LANGUAGE_SELECTOR"
:
true
,
"SHOW_
HEADER_
LANGUAGE_SELECTOR"
:
true
,
"CUSTOM_COURSES_EDX"
:
true
},
"FEEDBACK_SUBMISSION_EMAIL"
:
""
,
...
...
lms/envs/common.py
View file @
0172ff31
...
...
@@ -345,8 +345,11 @@ FEATURES = {
# Enable LTI Provider feature.
'ENABLE_LTI_PROVIDER'
:
False
,
# Show Language selector.
'SHOW_LANGUAGE_SELECTOR'
:
False
,
# Show the language selector in the header
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
False
,
# Show the language selector in the footer
'SHOW_FOOTER_LANGUAGE_SELECTOR'
:
False
,
# Write new CSM history to the extended table.
# This will eventually default to True and may be
...
...
lms/envs/devstack_docker.py
View file @
0172ff31
...
...
@@ -30,8 +30,8 @@ FEATURES.update({
'ENABLE_COURSEWARE_SEARCH'
:
False
,
'ENABLE_COURSE_DISCOVERY'
:
False
,
'ENABLE_DASHBOARD_SEARCH'
:
False
,
'SHOW_LANGUAGE_SELECTOR'
:
True
,
'ENABLE_DISCUSSION_SERVICE'
:
False
,
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
True
})
ENABLE_MKTG_SITE
=
os
.
environ
.
get
(
'ENABLE_MARKETING_SITE'
,
False
)
...
...
lms/templates/footer.html
View file @
0172ff31
...
...
@@ -4,6 +4,7 @@
from
django
.
core
.
urlresolvers
import
reverse
from
django
.
utils
.
translation
import
ugettext
as
_
from
branding
.
api
import
get_footer
from
openedx
.
core
.
djangoapps
.
lang_pref
.
api
import
footer_language_selector_is_enabled
%
>
<
%
footer =
get_footer(is_secure=is_secure)
%
>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
...
...
@@ -28,8 +29,8 @@
</ol>
</nav>
% if
include_language_selector
:
<
%
include
file=
"
widgets/footer-language-selector.html
"
/>
% if
context.get('include_language_selector', footer_language_selector_is_enabled())
:
<
%
include
file=
"
${static.get_template_path('widgets/footer-language-selector.html')}
"
/>
% endif
<div
class=
"wrapper-logo"
>
...
...
lms/templates/navigation.html
View file @
0172ff31
...
...
@@ -14,6 +14,7 @@ from branding import api as branding_api
#
app
that
handles
site
status
messages
from
status
.
status
import
get_site_status_msg
from
openedx
.
features
.
enterprise_support
.
api
import
get_enterprise_customer_logo_url
from
openedx
.
core
.
djangoapps
.
lang_pref
.
api
import
header_language_selector_is_enabled
,
released_languages
%
>
## Provide a hook for themes to inject branding on top.
...
...
@@ -176,8 +177,8 @@ site_status_msg = get_site_status_msg(course_id)
</
%
block>
</ol>
% endif
% if
static.show_language_selector
():
<
%
languages =
static.get_
released_languages()
%
>
% if
header_language_selector_is_enabled
():
<
%
languages =
released_languages()
%
>
% if len(languages) > 1:
<ol
class=
"user"
>
<li
class=
"primary"
>
...
...
lms/templates/widgets/footer-language-selector.html
View file @
0172ff31
...
...
@@ -15,6 +15,7 @@
if
not
settings
.
LANGUAGE_COOKIE:
raise
ValueError
('
settings
.
LANGUAGE_COOKIE
is
required
to
use
footer-language-selector
.')
%
>
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<div
class=
"footer-language-selector"
>
<label
for=
"footer-language-select"
>
...
...
@@ -53,8 +54,10 @@
setLanguageCookie: function(value, callback) {
var cookie = '
$
{
settings
.
LANGUAGE_COOKIE
|
n
,
js_escaped_string
}
=
' + value + '
;
path
=
/'
;
%
if
settings
.
SESSION_COOKIE_DOMAIN
:
cookie
+=
';domain=${settings.SESSION_COOKIE_DOMAIN | n, js_escaped_string}'
;
<%
session_cookie_domain
=
static
.
get_value
(
'SESSION_COOKIE_DOMAIN'
,
settings
.
SESSION_COOKIE_DOMAIN
)
%>
%
if
session_cookie_domain
:
cookie
+=
';domain=${session_cookie_domain | n, js_escaped_string}'
;
%
endif
%
if
COOKIE_DURATION
:
cookie
+=
';max-age=${COOKIE_DURATION | n, js_escaped_string}'
;
...
...
openedx/core/djangoapps/lang_pref/api.py
View file @
0172ff31
...
...
@@ -5,7 +5,9 @@ from collections import namedtuple
from
django.conf
import
settings
from
django.utils.translation
import
ugettext
as
_
from
openedx.core.djangoapps.dark_lang.models
import
DarkLangConfig
from
openedx.core.djangoapps.site_configuration.helpers
import
get_value
# Named tuples can be referenced using object-like variable
...
...
@@ -14,6 +16,21 @@ from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
Language
=
namedtuple
(
'Language'
,
'code name'
)
def
header_language_selector_is_enabled
():
"""Return true if the header language selector has been enabled via settings or site-specific configuration."""
setting
=
get_value
(
'SHOW_HEADER_LANGUAGE_SELECTOR'
,
settings
.
FEATURES
.
get
(
'SHOW_HEADER_LANGUAGE_SELECTOR'
,
False
))
# The SHOW_LANGUAGE_SELECTOR setting is deprecated, but might still be in use on some installations.
deprecated_setting
=
get_value
(
'SHOW_LANGUAGE_SELECTOR'
,
settings
.
FEATURES
.
get
(
'SHOW_LANGUAGE_SELECTOR'
,
False
))
return
setting
or
deprecated_setting
def
footer_language_selector_is_enabled
():
"""Return true if the footer language selector has been enabled via settings or site-specific configuration."""
return
get_value
(
'SHOW_FOOTER_LANGUAGE_SELECTOR'
,
settings
.
FEATURES
.
get
(
'SHOW_FOOTER_LANGUAGE_SELECTOR'
,
False
))
def
released_languages
():
"""Retrieve the list of released languages.
...
...
openedx/core/djangoapps/lang_pref/tests/test_api.py
View file @
0172ff31
# -*- coding: utf-8 -*-
""" Tests for the language API. """
from
mock
import
patch
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.utils
import
translation
...
...
@@ -8,8 +9,8 @@ from django.contrib.auth.models import User
import
ddt
from
openedx.core.djangoapps.dark_lang.models
import
DarkLangConfig
from
openedx.core.djangoapps.lang_pref
import
api
as
language_api
from
openedx.core.djangoapps.site_configuration.tests.test_util
import
with_site_configuration_context
EN
=
language_api
.
Language
(
'en'
,
'English'
)
ES_419
=
language_api
.
Language
(
'es-419'
,
u'Español (Latinoamérica)'
)
...
...
@@ -20,6 +21,45 @@ class LanguageApiTest(TestCase):
"""
Tests of the language APIs.
"""
@ddt.data
(
# Should return the base config value
({
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
True
},
{},
True
),
# Should return the site config value
({
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
False
},
{
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
True
},
True
),
({
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
True
},
{
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
False
},
False
),
# SHOW_LANGUAGE_SELECTOR should supercede SHOW_HEADER_LANGUAGE_SELECTOR when true
({
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
False
,
'SHOW_LANGUAGE_SELECTOR'
:
True
},
{},
True
),
({
'SHOW_HEADER_LANGUAGE_SELECTOR'
:
False
},
{
'SHOW_LANGUAGE_SELECTOR'
:
True
},
True
)
)
@ddt.unpack
def
test_header_language_selector_is_enabled
(
self
,
base_config
,
site_config
,
expected
):
"""
Verify that the header language selector config is correct.
"""
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
base_config
):
with
with_site_configuration_context
(
configuration
=
site_config
):
self
.
assertEqual
(
language_api
.
header_language_selector_is_enabled
(),
expected
)
@ddt.data
(
# Should return the base config value
({
'SHOW_FOOTER_LANGUAGE_SELECTOR'
:
True
},
{},
True
),
# Should return the site config value
({
'SHOW_FOOTER_LANGUAGE_SELECTOR'
:
False
},
{
'SHOW_FOOTER_LANGUAGE_SELECTOR'
:
True
},
True
),
({
'SHOW_FOOTER_LANGUAGE_SELECTOR'
:
True
},
{
'SHOW_FOOTER_LANGUAGE_SELECTOR'
:
False
},
False
)
)
@ddt.unpack
def
test_footer_language_selector_is_enabled
(
self
,
base_config
,
site_config
,
expected
):
"""
Verify that the footer language selector config is correct.
"""
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
base_config
):
with
with_site_configuration_context
(
configuration
=
site_config
):
self
.
assertEqual
(
language_api
.
footer_language_selector_is_enabled
(),
expected
)
@ddt.data
(
*
[
(
'en'
,
[],
[],
[]),
(
'en'
,
[
EN
],
[],
[
EN
]),
...
...
themes/edx.org/lms/templates/footer.html
View file @
0172ff31
...
...
@@ -4,6 +4,7 @@
from
django
.
utils
.
translation
import
ugettext
as
_
from
branding
.
api
import
get_footer
from
openedx
.
core
.
djangoapps
.
lang_pref
.
api
import
footer_language_selector_is_enabled
%
>
<
%
footer =
get_footer(is_secure=is_secure)
%
>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
...
...
@@ -45,8 +46,8 @@
</ul>
</nav>
% if
include_language_selector
:
<
%
include
file=
"
widgets/footer-language-selector.html
"
/>
% if
context.get('include_language_selector', footer_language_selector_is_enabled())
:
<
%
include
file=
"
${static.get_template_path('widgets/footer-language-selector.html')}
"
/>
% endif
<p
class=
"copyright"
>
${_(
...
...
themes/red-theme/lms/templates/footer.html
View file @
0172ff31
...
...
@@ -3,6 +3,7 @@
<
%!
from
django
.
core
.
urlresolvers
import
reverse
from
django
.
utils
.
translation
import
ugettext
as
_
from
openedx
.
core
.
djangoapps
.
lang_pref
.
api
import
footer_language_selector_is_enabled
%
>
<div
class=
"wrapper wrapper-footer"
>
...
...
@@ -43,8 +44,8 @@ from django.utils.translation import ugettext as _
</ol>
</nav>
% if
include_language_selector
:
<
%
include
file=
'widgets/footer-language-selector.html'
/>
% if
context.get('include_language_selector', footer_language_selector_is_enabled())
:
<
%
include
file=
"${static.get_template_path('widgets/footer-language-selector.html')}"
/>
% endif
<div
class=
"wrapper-logo"
>
...
...
themes/stanford-style/lms/templates/footer.html
View file @
0172ff31
## mako
<
%!
from
datetime
import
date
from
django
.
core
.
urlresolvers
import
reverse
from
django
.
utils
.
translation
import
ugettext
as
_
from
openedx
.
core
.
djangoapps
.
lang_pref
.
api
import
footer_language_selector_is_enabled
%
>
<
%!
from
datetime
import
date
%
>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<!-- footer overrides for stanford theme go here -->
<div
class=
"wrapper-footer"
>
<footer>
...
...
@@ -22,8 +22,8 @@
</ol>
</nav>
% if
include_language_selector
:
<
%
include
file=
'widgets/footer-language-selector.html'
/>
% if
context.get('include_language_selector', footer_language_selector_is_enabled())
:
<
%
include
file=
"${static.get_template_path('widgets/footer-language-selector.html')}"
/>
% endif
</div>
...
...
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