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
30b910c9
Commit
30b910c9
authored
Dec 09, 2014
by
Marco Re
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add themes files to staticfiles_dir in Studio
parent
e8350d35
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
0 deletions
+87
-0
cms/startup.py
+33
-0
cms/tests/__init__.py
+4
-0
cms/tests/test_startup.py
+47
-0
pavelib/utils/test/suites/nose_suite.py
+3
-0
No files found.
cms/startup.py
View file @
30b910c9
...
@@ -30,6 +30,8 @@ def run():
...
@@ -30,6 +30,8 @@ def run():
add_mimetypes
()
add_mimetypes
()
if
settings
.
FEATURES
.
get
(
'USE_CUSTOM_THEME'
,
False
):
enable_theme
()
if
settings
.
FEATURES
.
get
(
'ENABLE_NOTIFICATIONS'
,
False
):
if
settings
.
FEATURES
.
get
(
'ENABLE_NOTIFICATIONS'
,
False
):
startup_notification_subsystem
()
startup_notification_subsystem
()
...
@@ -48,6 +50,37 @@ def add_mimetypes():
...
@@ -48,6 +50,37 @@ def add_mimetypes():
mimetypes
.
add_type
(
'application/font-woff'
,
'.woff'
)
mimetypes
.
add_type
(
'application/font-woff'
,
'.woff'
)
def
enable_theme
():
"""
Enable the settings for a custom theme, whose files should be stored
in ENV_ROOT/themes/THEME_NAME (e.g., edx_all/themes/stanford).
At this moment this is actually just a fix for collectstatic,
(see https://openedx.atlassian.net/browse/TNL-726),
but can be improved with a full theming option also for Studio
in the future (see lms.startup)
"""
# Workaround for setting THEME_NAME to an empty
# string which is the default due to this ansible
# bug: https://github.com/ansible/ansible/issues/4812
if
settings
.
THEME_NAME
==
""
:
settings
.
THEME_NAME
=
None
return
assert
settings
.
FEATURES
[
'USE_CUSTOM_THEME'
]
settings
.
FAVICON_PATH
=
'themes/{name}/images/favicon.ico'
.
format
(
name
=
settings
.
THEME_NAME
)
# Calculate the location of the theme's files
theme_root
=
settings
.
ENV_ROOT
/
"themes"
/
settings
.
THEME_NAME
# Namespace the theme's static files to 'themes/<theme_name>' to
# avoid collisions with default edX static files
settings
.
STATICFILES_DIRS
.
append
(
(
u'themes/{}'
.
format
(
settings
.
THEME_NAME
),
theme_root
/
'static'
)
)
def
startup_notification_subsystem
():
def
startup_notification_subsystem
():
"""
"""
Initialize the Notification subsystem
Initialize the Notification subsystem
...
...
cms/tests/__init__.py
0 → 100644
View file @
30b910c9
"""
Module for test in cms folder
All cms/test/* are already included in paver test
"""
cms/tests/test_startup.py
0 → 100644
View file @
30b910c9
"""
Test cms startup
"""
from
django.conf
import
settings
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
mock
import
patch
from
cms.startup
import
run
,
enable_theme
class
StartupTestCase
(
TestCase
):
"""
Test cms startup
"""
def
setUp
(
self
):
super
(
StartupTestCase
,
self
)
.
setUp
()
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"USE_CUSTOM_THEME"
:
True
})
@override_settings
(
THEME_NAME
=
"bar"
)
def
test_run_with_theme
(
self
):
self
.
assertEqual
(
settings
.
FEATURES
[
"USE_CUSTOM_THEME"
],
True
)
with
patch
(
'cms.startup.enable_theme'
)
as
mock_enable_theme
:
run
()
self
.
assertTrue
(
mock_enable_theme
.
called
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"USE_CUSTOM_THEME"
:
False
})
def
test_run_without_theme
(
self
):
self
.
assertEqual
(
settings
.
FEATURES
[
"USE_CUSTOM_THEME"
],
False
)
with
patch
(
'cms.startup.enable_theme'
)
as
mock_enable_theme
:
run
()
self
.
assertFalse
(
mock_enable_theme
.
called
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"USE_CUSTOM_THEME"
:
True
})
@override_settings
(
THEME_NAME
=
"bar"
)
@override_settings
(
FAVICON_PATH
=
"images/favicon.ico"
)
def
test_enable_theme
(
self
):
enable_theme
()
self
.
assertEqual
(
settings
.
FAVICON_PATH
,
'themes/bar/images/favicon.ico'
)
exp_path
=
(
u'themes/bar'
,
settings
.
ENV_ROOT
/
"themes/bar/static"
)
self
.
assertIn
(
exp_path
,
settings
.
STATICFILES_DIRS
)
pavelib/utils/test/suites/nose_suite.py
View file @
30b910c9
...
@@ -136,6 +136,9 @@ class SystemTestSuite(NoseTestSuite):
...
@@ -136,6 +136,9 @@ class SystemTestSuite(NoseTestSuite):
if
self
.
root
==
'lms'
:
if
self
.
root
==
'lms'
:
default_test_id
+=
" {system}/tests.py"
.
format
(
system
=
self
.
root
)
default_test_id
+=
" {system}/tests.py"
.
format
(
system
=
self
.
root
)
if
self
.
root
==
'cms'
:
default_test_id
+=
" {system}/tests/*"
.
format
(
system
=
self
.
root
)
return
default_test_id
return
default_test_id
...
...
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