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
d65902ed
Commit
d65902ed
authored
Dec 09, 2014
by
Marco Re
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add themes files to staticfiles_dir in Studio
parent
95cc2bb8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
0 deletions
+88
-0
cms/startup.py
+34
-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 @
d65902ed
...
@@ -21,6 +21,9 @@ def run():
...
@@ -21,6 +21,9 @@ def run():
add_mimetypes
()
add_mimetypes
()
if
settings
.
FEATURES
.
get
(
'USE_CUSTOM_THEME'
,
False
):
enable_theme
()
def
add_mimetypes
():
def
add_mimetypes
():
"""
"""
...
@@ -34,3 +37,34 @@ def add_mimetypes():
...
@@ -34,3 +37,34 @@ def add_mimetypes():
mimetypes
.
add_type
(
'application/x-font-opentype'
,
'.otf'
)
mimetypes
.
add_type
(
'application/x-font-opentype'
,
'.otf'
)
mimetypes
.
add_type
(
'application/x-font-ttf'
,
'.ttf'
)
mimetypes
.
add_type
(
'application/x-font-ttf'
,
'.ttf'
)
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'
)
)
cms/tests/__init__.py
0 → 100644
View file @
d65902ed
"""
Module for test in cms folder
All cms/test/* are already included in paver test
"""
cms/tests/test_startup.py
0 → 100644
View file @
d65902ed
"""
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 @
d65902ed
...
@@ -138,6 +138,9 @@ class SystemTestSuite(NoseTestSuite):
...
@@ -138,6 +138,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