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
a36eb51a
Commit
a36eb51a
authored
Oct 27, 2017
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move microsite config from startup.py to settings and AppConfig.ready.
parent
6939a581
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
13 deletions
+35
-13
common/djangoapps/microsite_configuration/apps.py
+15
-0
lms/envs/common.py
+15
-1
lms/startup.py
+0
-10
lms/tests.py
+5
-2
No files found.
common/djangoapps/microsite_configuration/apps.py
0 → 100644
View file @
a36eb51a
import
logging
from
django.apps
import
AppConfig
from
.microsite
import
enable_microsites
log
=
logging
.
getLogger
(
__name__
)
class
MicrositeConfigurationConfig
(
AppConfig
):
name
=
'microsite_configuration'
verbose_name
=
"Microsite Configuration"
def
ready
(
self
):
# Mako requires the directories to be added after the django setup.
enable_microsites
(
log
)
lms/envs/common.py
View file @
a36eb51a
...
...
@@ -557,6 +557,8 @@ def _make_main_mako_templates(settings):
for
theme
in
get_themes_unchecked
(
themes_dirs
,
PROJECT_ROOT
):
if
theme
.
themes_base_dir
not
in
settings
.
MAIN_MAKO_TEMPLATES_BASE
:
settings
.
MAIN_MAKO_TEMPLATES_BASE
.
insert
(
0
,
theme
.
themes_base_dir
)
if
settings
.
FEATURES
.
get
(
'USE_MICROSITES'
,
False
)
and
getattr
(
settings
,
"MICROSITE_CONFIGURATION"
,
False
):
settings
.
MAIN_MAKO_TEMPLATES_BASE
.
insert
(
0
,
settings
.
MICROSITE_ROOT_DIR
)
return
settings
.
MAIN_MAKO_TEMPLATES_BASE
MAKO_TEMPLATES
[
'main'
]
=
_make_main_mako_templates
derived_dict_entry
(
'MAKO_TEMPLATES'
,
'main'
)
...
...
@@ -620,6 +622,18 @@ TEMPLATES = [
}
]
DEFAULT_TEMPLATE_ENGINE
=
TEMPLATES
[
0
]
DEFAULT_TEMPLATE_ENGINE_DIRS
=
DEFAULT_TEMPLATE_ENGINE
[
'DIRS'
][:]
def
_add_microsite_dirs_to_default_template_engine
(
settings
):
"""
Derives the final DEFAULT_TEMPLATE_ENGINE['DIRS'] setting from other settings.
"""
if
settings
.
FEATURES
.
get
(
'USE_MICROSITES'
,
False
)
and
getattr
(
settings
,
"MICROSITE_CONFIGURATION"
,
False
):
DEFAULT_TEMPLATE_ENGINE_DIRS
.
append
(
settings
.
MICROSITE_ROOT_DIR
)
return
DEFAULT_TEMPLATE_ENGINE_DIRS
DEFAULT_TEMPLATE_ENGINE
[
'DIRS'
]
=
_add_microsite_dirs_to_default_template_engine
derived_dict_entry
(
'DEFAULT_TEMPLATE_ENGINE'
,
'DIRS'
)
###############################################################################################
...
...
@@ -2176,7 +2190,7 @@ INSTALLED_APPS = [
'openedx.core.djangoapps.dark_lang'
,
# Microsite configuration
'microsite_configuration'
,
'microsite_configuration
.apps.MicrositeConfigurationConfig
'
,
# RSS Proxy
'rss_proxy'
,
...
...
lms/startup.py
View file @
a36eb51a
...
...
@@ -21,8 +21,6 @@ import lms_xblock.runtime
from
startup_configurations.validate_config
import
validate_lms_config
from
microsite_configuration
import
microsite
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -35,20 +33,12 @@ def run():
"""
django_db_models_options
.
patch
()
# We currently use 2 template rendering engines, mako and django_templates,
# and one of them (django templates), requires the directories be added
# before the django.setup().
microsite
.
enable_microsites_pre_startup
(
log
)
django
.
setup
()
autostartup
()
add_mimetypes
()
# Mako requires the directories to be added after the django setup.
microsite
.
enable_microsites
(
log
)
# In order to allow modules to use a handler url, we need to
# monkey-patch the x_module library.
# TODO: Remove this code when Runtimes are no longer created by modulestores
...
...
lms/tests.py
View file @
a36eb51a
"""Tests for the lms module itself."""
import
logging
import
mimetypes
from
django.core.urlresolvers
import
reverse
...
...
@@ -7,11 +8,13 @@ from django.test import TestCase
from
mock
import
patch
from
edxmako
import
LOOKUP
,
add_lookup
from
lms
import
startup
from
microsite_configuration
import
microsite
from
openedx.features.course_experience
import
course_home_url_name
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
log
=
logging
.
getLogger
(
__name__
)
class
LmsModuleTests
(
TestCase
):
"""
...
...
@@ -38,7 +41,7 @@ class TemplateLookupTests(TestCase):
self
.
assertEqual
(
len
([
directory
for
directory
in
directories
if
'external_module'
in
directory
]),
1
)
# This should not clear the directories list
startup
.
enable_microsites
(
)
microsite
.
enable_microsites
(
log
)
directories
=
LOOKUP
[
'main'
]
.
directories
self
.
assertEqual
(
len
([
directory
for
directory
in
directories
if
'external_module'
in
directory
]),
1
)
...
...
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