Remove all usages of USE_CUSTOM_THEME and THEME_NAME from python files
This commit is contained in:
@@ -209,9 +209,6 @@ COURSES_WITH_UNSAFE_CODE = ENV_TOKENS.get("COURSES_WITH_UNSAFE_CODE", [])
|
||||
|
||||
ASSET_IGNORE_REGEX = ENV_TOKENS.get('ASSET_IGNORE_REGEX', ASSET_IGNORE_REGEX)
|
||||
|
||||
# Theme overrides
|
||||
THEME_NAME = ENV_TOKENS.get('THEME_NAME', None)
|
||||
|
||||
# following setting is for backward compatibility
|
||||
if ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR', None):
|
||||
COMPREHENSIVE_THEME_DIR = ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR')
|
||||
|
||||
@@ -101,7 +101,6 @@
|
||||
"STATIC_URL_BASE": "/static/",
|
||||
"SYSLOG_SERVER": "",
|
||||
"TECH_SUPPORT_EMAIL": "technical@example.com",
|
||||
"THEME_NAME": "",
|
||||
"TIME_ZONE": "America/New_York",
|
||||
"WIKI_ENABLED": true,
|
||||
"OAUTH_OIDC_ISSUER": "https://www.example.com/oauth2"
|
||||
|
||||
@@ -40,9 +40,6 @@ def run():
|
||||
|
||||
add_mimetypes()
|
||||
|
||||
if settings.FEATURES.get('USE_CUSTOM_THEME', False):
|
||||
enable_theme()
|
||||
|
||||
# In order to allow descriptors 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
|
||||
@@ -63,34 +60,3 @@ def add_mimetypes():
|
||||
mimetypes.add_type('application/x-font-opentype', '.otf')
|
||||
mimetypes.add_type('application/x-font-ttf', '.ttf')
|
||||
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')
|
||||
)
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
"""
|
||||
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)
|
||||
@@ -1,64 +0,0 @@
|
||||
"""
|
||||
Preprocess templatized asset files, enabling asset authors to use
|
||||
Python/Django inside of Sass and CoffeeScript. This preprocessing
|
||||
will happen before the invocation of the asset compiler (currently
|
||||
handled by the assets paver file).
|
||||
|
||||
For this to work, assets need to be named with the appropriate
|
||||
template extension (e.g., .mako for Mako templates). Currently Mako
|
||||
is the only template engine supported.
|
||||
"""
|
||||
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Basic management command to preprocess asset template files.
|
||||
"""
|
||||
|
||||
help = "Preprocess asset template files to ready them for compilation."
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('files', type=unicode, nargs='+', help='files to pre-process')
|
||||
parser.add_argument('dest_dir', type=unicode, help='destination directory')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
theme_name = getattr(settings, "THEME_NAME", None)
|
||||
use_custom_theme = settings.FEATURES.get("USE_CUSTOM_THEME", False)
|
||||
if not use_custom_theme or not theme_name:
|
||||
# No custom theme, nothing to do!
|
||||
return
|
||||
|
||||
dest_dir = options['dest_dir']
|
||||
for source_file in options['files']:
|
||||
self.process_one_file(source_file, dest_dir, theme_name)
|
||||
|
||||
def process_one_file(self, source_file, dest_dir, theme_name):
|
||||
"""Pre-process a .scss file to replace our markers with real code."""
|
||||
with open(source_file) as fsource:
|
||||
original_content = fsource.read()
|
||||
|
||||
content = original_content.replace(
|
||||
"//<THEME-OVERRIDE>",
|
||||
"@import '{}';".format(theme_name),
|
||||
)
|
||||
|
||||
if content != original_content:
|
||||
if not os.path.exists(dest_dir):
|
||||
os.makedirs(dest_dir)
|
||||
dest_file = os.path.join(dest_dir, os.path.basename(source_file))
|
||||
with open(dest_file, "w") as fout:
|
||||
fout.write(textwrap.dedent("""\
|
||||
/*
|
||||
* This file is dynamically generated and ignored by Git.
|
||||
* DO NOT MAKE CHANGES HERE. Instead, go edit its source:
|
||||
* {}
|
||||
*/
|
||||
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
|
||||
""".format(source_file)))
|
||||
fout.write(content)
|
||||
@@ -38,12 +38,3 @@ COURSEWARE_MESSAGES = {
|
||||
template='static_templates/embargo.html'
|
||||
)
|
||||
}
|
||||
|
||||
# Backwards compatibility with themes
|
||||
# created for earlier implementations of the embargo app.
|
||||
CUSTOM_THEME_OVERRIDES = {
|
||||
'embargo': BlockedMessage(
|
||||
description='Embargo',
|
||||
template='static_templates/theme-embargo.html'
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import unittest
|
||||
from mock import patch
|
||||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
from mako.exceptions import TopLevelLookupException
|
||||
@@ -11,6 +10,7 @@ import ddt
|
||||
from util.testing import UrlResetMixin
|
||||
from embargo import messages
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
|
||||
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@@ -53,23 +53,21 @@ class CourseAccessMessageViewTest(CacheIsolationTestCase, UrlResetMixin):
|
||||
def test_invalid_message_key(self, access_point):
|
||||
self._load_page(access_point, 'invalid', expected_status=404)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'USE_CUSTOM_THEME': True})
|
||||
@with_comprehensive_theme("test-theme")
|
||||
@ddt.data('enrollment', 'courseware')
|
||||
def test_custom_theme_override(self, access_point):
|
||||
# Custom override specified for the "embargo" message
|
||||
# for backwards compatibility with previous versions
|
||||
# of the embargo app.
|
||||
# This template isn't available by default, but we can at least
|
||||
# verify that the view will look for it when the USE_CUSTOM_THEME
|
||||
# feature flag is specified.
|
||||
with self.assertRaisesRegexp(TopLevelLookupException, 'static_templates/theme-embargo.html'):
|
||||
self._load_page(access_point, 'embargo')
|
||||
|
||||
@patch.dict(settings.FEATURES, {'USE_CUSTOM_THEME': True})
|
||||
@ddt.data('enrollment', 'courseware')
|
||||
def test_custom_theme_override_not_specified(self, access_point):
|
||||
# No custom override specified for the "default" message
|
||||
self._load_page(access_point, 'default')
|
||||
url = reverse('embargo_blocked_message', kwargs={
|
||||
'access_point': access_point,
|
||||
'message_key': "embargo"
|
||||
})
|
||||
response = self.client.get(url)
|
||||
self.assertContains(
|
||||
response,
|
||||
"This is a test template to test embargo message override for theming."
|
||||
)
|
||||
|
||||
def _load_page(self, access_point, message_key, expected_status=200):
|
||||
"""Load the message page and check the status code. """
|
||||
|
||||
@@ -56,16 +56,11 @@ class CourseAccessMessageView(View):
|
||||
"""
|
||||
message_dict = dict()
|
||||
|
||||
# Backwards compatibility with themes created for
|
||||
# earlier implementations of the embargo app.
|
||||
if settings.FEATURES.get('USE_CUSTOM_THEME') and message_key in messages.CUSTOM_THEME_OVERRIDES:
|
||||
message_dict = messages.CUSTOM_THEME_OVERRIDES
|
||||
|
||||
# The access point determines which set of messages to use.
|
||||
# This allows us to show different messages to students who
|
||||
# are enrolling in a course than we show to students
|
||||
# who are enrolled and accessing courseware.
|
||||
elif access_point == self.ENROLLMENT_ACCESS_POINT:
|
||||
if access_point == self.ENROLLMENT_ACCESS_POINT:
|
||||
message_dict = messages.ENROLL_MESSAGES
|
||||
elif access_point == self.COURSEWARE_ACCESS_POINT:
|
||||
message_dict = messages.COURSEWARE_MESSAGES
|
||||
|
||||
@@ -13,7 +13,6 @@ from openedx.core.djangoapps.site_configuration.helpers import (
|
||||
|
||||
from openedx.core.djangoapps.theming.helpers import (
|
||||
get_template_path,
|
||||
get_themed_template_path,
|
||||
is_request_in_themed_site,
|
||||
)
|
||||
from certificates.api import get_asset_url_by_slug
|
||||
@@ -156,10 +155,6 @@ else:
|
||||
return get_template_path(relative_path, **kwargs)
|
||||
%></%def>
|
||||
|
||||
<%def name="get_themed_template_path(relative_path, default_path, **kwargs)"><%
|
||||
return get_themed_template_path(relative_path, default_path, **kwargs)
|
||||
%></%def>
|
||||
|
||||
<%def name="is_request_in_themed_site()"><%
|
||||
return is_request_in_themed_site()
|
||||
%></%def>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<%page expression_filter="h"/>
|
||||
<%!
|
||||
from django.utils.translation import ugettext as _
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
%>
|
||||
<%inherit file="../main.html" />
|
||||
|
||||
<%block name="pagetitle">${_("This Course Unavailable In Your Country")}</%block>
|
||||
|
||||
<!-- This is a test template to test embargo message override for theming. -->
|
||||
<main id="main" aria-label="Content" tabindex="-1">
|
||||
<section class="outside-app">
|
||||
<p>
|
||||
${Text(_("Our system indicates that you are trying to access this {platform_name} "
|
||||
"course from a country or region currently subject to U.S. economic and trade "
|
||||
"sanctions. Unfortunately, at this time {platform_name} must comply with "
|
||||
"export controls, and we cannot allow you to access this course."
|
||||
)).format(
|
||||
platform_name=Text(settings.PLATFORM_NAME),
|
||||
)}
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
@@ -38,18 +38,3 @@ class FaviconTestCase(UrlResetMixin, TestCase):
|
||||
"/static/images/foo.ico",
|
||||
status_code=301, target_status_code=404 # @@@ how to avoid 404?
|
||||
)
|
||||
|
||||
@patch.dict("django.conf.settings.FEATURES", {"USE_CUSTOM_THEME": True})
|
||||
@override_settings(FAVICON_PATH="images/bar_fav.ico")
|
||||
@override_settings(THEME_NAME="bar")
|
||||
def test_favicon_redirect_with_theme(self):
|
||||
self.assertEqual(settings.FEATURES["USE_CUSTOM_THEME"], True)
|
||||
self.reset_urls()
|
||||
|
||||
resp = self.client.get("/favicon.ico")
|
||||
self.assertEqual(resp.status_code, 301)
|
||||
self.assertRedirects(
|
||||
resp,
|
||||
"/static/images/bar_fav.ico",
|
||||
status_code=301, target_status_code=404 # @@@ how to avoid 404?
|
||||
)
|
||||
|
||||
@@ -267,9 +267,6 @@ BULK_EMAIL_ROUTING_KEY = HIGH_PRIORITY_QUEUE
|
||||
# we have to reset the value here.
|
||||
BULK_EMAIL_ROUTING_KEY_SMALL_JOBS = LOW_PRIORITY_QUEUE
|
||||
|
||||
# Theme overrides
|
||||
THEME_NAME = ENV_TOKENS.get('THEME_NAME', None)
|
||||
|
||||
# following setting is for backward compatibility
|
||||
if ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR', None):
|
||||
COMPREHENSIVE_THEME_DIR = ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR')
|
||||
|
||||
@@ -138,7 +138,6 @@
|
||||
"SUPPORT_SITE_LINK": "https://support.example.com",
|
||||
"SYSLOG_SERVER": "",
|
||||
"TECH_SUPPORT_EMAIL": "technical@example.com",
|
||||
"THEME_NAME": "",
|
||||
"THIRD_PARTY_AUTH_BACKENDS": [
|
||||
"social.backends.google.GoogleOAuth2",
|
||||
"social.backends.linkedin.LinkedinOAuth2",
|
||||
|
||||
@@ -153,9 +153,6 @@ FEATURES = {
|
||||
# Enable URL that shows information about the status of variuous services
|
||||
'ENABLE_SERVICE_STATUS': False,
|
||||
|
||||
# Toggle to indicate use of the Stanford theming system
|
||||
'USE_CUSTOM_THEME': False,
|
||||
|
||||
# Don't autoplay videos for students
|
||||
'AUTOPLAY_VIDEOS': False,
|
||||
|
||||
|
||||
@@ -58,9 +58,6 @@ def run():
|
||||
# Mako requires the directories to be added after the django setup.
|
||||
microsite.enable_microsites(log)
|
||||
|
||||
if settings.FEATURES.get('USE_CUSTOM_THEME', False):
|
||||
enable_stanford_theme()
|
||||
|
||||
# Initialize Segment analytics module by setting the write_key.
|
||||
if settings.LMS_SEGMENT_KEY:
|
||||
analytics.write_key = settings.LMS_SEGMENT_KEY
|
||||
@@ -100,40 +97,6 @@ def add_mimetypes():
|
||||
mimetypes.add_type('application/font-woff', '.woff')
|
||||
|
||||
|
||||
def enable_stanford_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).
|
||||
"""
|
||||
# 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 getattr(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
|
||||
|
||||
# Include the theme's templates in the template search paths
|
||||
settings.DEFAULT_TEMPLATE_ENGINE['DIRS'].insert(0, theme_root / 'templates')
|
||||
edxmako.paths.add_lookup('main', theme_root / 'templates', prepend=True)
|
||||
|
||||
# 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')
|
||||
)
|
||||
|
||||
# Include theme locale path for django translations lookup
|
||||
settings.LOCALE_PATHS = (theme_root / 'conf/locale',) + settings.LOCALE_PATHS
|
||||
|
||||
|
||||
def enable_microsites():
|
||||
"""
|
||||
Calls the enable_microsites function in the microsite backend.
|
||||
|
||||
@@ -6,8 +6,4 @@
|
||||
@import 'base/font_face';
|
||||
@import 'base/mixins';
|
||||
|
||||
// This comment is used by preprocess_assets.py to include resources from a
|
||||
// theme, for old-style deprecated theming.
|
||||
//<THEME-OVERRIDE>
|
||||
|
||||
@import 'build-course'; // shared app style assets/rendering
|
||||
|
||||
@@ -6,8 +6,4 @@
|
||||
@import 'base/font_face';
|
||||
@import 'base/mixins';
|
||||
|
||||
// This comment is used by preprocess_assets.py to include resources from a
|
||||
// theme, for old-style deprecated theming.
|
||||
//<THEME-OVERRIDE>
|
||||
|
||||
@import 'build-course'; // shared app style assets/rendering
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
@import 'base/variables';
|
||||
@import 'base/mixins';
|
||||
|
||||
// This comment is used by preprocess_assets.py to include resources from a
|
||||
// theme, for old-style deprecated theming.
|
||||
//<THEME-OVERRIDE>
|
||||
|
||||
footer#footer-openedx {
|
||||
@import 'base/reset';
|
||||
@import 'base/extends';
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
@import 'base/variables';
|
||||
@import 'base/mixins';
|
||||
|
||||
// This comment is used by preprocess_assets.py to include resources from a
|
||||
// theme, for old-style deprecated theming.
|
||||
//<THEME-OVERRIDE>
|
||||
|
||||
footer#footer-openedx {
|
||||
@import 'base/reset';
|
||||
@import 'base/extends';
|
||||
|
||||
@@ -15,8 +15,4 @@
|
||||
@import 'base/variables';
|
||||
@import 'base/mixins';
|
||||
|
||||
// This comment is used by preprocess_assets.py to include resources from a
|
||||
// theme, for old-style deprecated theming.
|
||||
//<THEME-OVERRIDE>
|
||||
|
||||
@import 'build-lms-v1'; // shared app style assets/rendering
|
||||
|
||||
@@ -14,8 +14,4 @@
|
||||
@import 'base/variables';
|
||||
@import 'base/mixins';
|
||||
|
||||
// This comment is used by preprocess_assets.py to include resources from a
|
||||
// theme, for old-style deprecated theming.
|
||||
//<THEME-OVERRIDE>
|
||||
|
||||
@import 'build-lms-v1'; // shared app style assets/rendering
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
When USE_CUSTOM_THEME is true, .scss files are pre-processed to add imports of
|
||||
the theme settings. This directory will hold the output of the pre-processing.
|
||||
@@ -1,4 +1,4 @@
|
||||
## mako
|
||||
<%page expression_filter="h" args="online_help_token"/>
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
<%include file="${static.get_themed_template_path(relative_path='theme-header.html', default_path='navigation.html')}" args="online_help_token=online_help_token" />
|
||||
<%include file="${static.get_template_path(relative_path='navigation.html')}" args="online_help_token=online_help_token" />
|
||||
|
||||
@@ -141,7 +141,7 @@ from pipeline_mako import render_require_js_path_overrides
|
||||
</div>
|
||||
|
||||
% if not disable_footer:
|
||||
<%include file="themable-footer.html" />
|
||||
<%include file="${static.get_template_path('footer.html')}" />
|
||||
% endif
|
||||
|
||||
% if not disable_window_wrap:
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
## mako
|
||||
<%page expression_filter="h"/>
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
|
||||
## This file only exists as an additional layer of indirection to preserve
|
||||
## backwards compatibility with Stanford theming
|
||||
## (as much as possible). If you are writing your own theme using the
|
||||
## "comprehensive theming" system, do NOT override this file. You should
|
||||
## override "footer.html" instead.
|
||||
|
||||
<%include file="${static.get_themed_template_path(relative_path='theme-footer.html', default_path='footer.html')}" />
|
||||
55
lms/urls.py
55
lms/urls.py
@@ -176,33 +176,31 @@ urlpatterns += (url(
|
||||
RedirectView.as_view(url=settings.STATIC_URL + favicon_path, permanent=True)
|
||||
),)
|
||||
|
||||
# Semi-static views only used by edX, not by themes
|
||||
if not settings.FEATURES["USE_CUSTOM_THEME"]:
|
||||
urlpatterns += (
|
||||
url(r'^blog$', 'static_template_view.views.render',
|
||||
{'template': 'blog.html'}, name="blog"),
|
||||
url(r'^contact$', 'static_template_view.views.render',
|
||||
{'template': 'contact.html'}, name="contact"),
|
||||
url(r'^donate$', 'static_template_view.views.render',
|
||||
{'template': 'donate.html'}, name="donate"),
|
||||
url(r'^faq$', 'static_template_view.views.render',
|
||||
{'template': 'faq.html'}, name="faq"),
|
||||
url(r'^help$', 'static_template_view.views.render',
|
||||
{'template': 'help.html'}, name="help_edx"),
|
||||
url(r'^jobs$', 'static_template_view.views.render',
|
||||
{'template': 'jobs.html'}, name="jobs"),
|
||||
url(r'^news$', 'static_template_view.views.render',
|
||||
{'template': 'news.html'}, name="news"),
|
||||
url(r'^press$', 'static_template_view.views.render',
|
||||
{'template': 'press.html'}, name="press"),
|
||||
url(r'^media-kit$', 'static_template_view.views.render',
|
||||
{'template': 'media-kit.html'}, name="media-kit"),
|
||||
url(r'^copyright$', 'static_template_view.views.render',
|
||||
{'template': 'copyright.html'}, name="copyright"),
|
||||
urlpatterns += (
|
||||
url(r'^blog$', 'static_template_view.views.render',
|
||||
{'template': 'blog.html'}, name="blog"),
|
||||
url(r'^contact$', 'static_template_view.views.render',
|
||||
{'template': 'contact.html'}, name="contact"),
|
||||
url(r'^donate$', 'static_template_view.views.render',
|
||||
{'template': 'donate.html'}, name="donate"),
|
||||
url(r'^faq$', 'static_template_view.views.render',
|
||||
{'template': 'faq.html'}, name="faq"),
|
||||
url(r'^help$', 'static_template_view.views.render',
|
||||
{'template': 'help.html'}, name="help_edx"),
|
||||
url(r'^jobs$', 'static_template_view.views.render',
|
||||
{'template': 'jobs.html'}, name="jobs"),
|
||||
url(r'^news$', 'static_template_view.views.render',
|
||||
{'template': 'news.html'}, name="news"),
|
||||
url(r'^press$', 'static_template_view.views.render',
|
||||
{'template': 'press.html'}, name="press"),
|
||||
url(r'^media-kit$', 'static_template_view.views.render',
|
||||
{'template': 'media-kit.html'}, name="media-kit"),
|
||||
url(r'^copyright$', 'static_template_view.views.render',
|
||||
{'template': 'copyright.html'}, name="copyright"),
|
||||
|
||||
# Press releases
|
||||
url(r'^press/([_a-zA-Z0-9-]+)$', 'static_template_view.views.render_press_release', name='press_release'),
|
||||
)
|
||||
# Press releases
|
||||
url(r'^press/([_a-zA-Z0-9-]+)$', 'static_template_view.views.render_press_release', name='press_release'),
|
||||
)
|
||||
|
||||
# Only enable URLs for those marketing links actually enabled in the
|
||||
# settings. Disable URLs by marking them as None.
|
||||
@@ -222,11 +220,6 @@ for key, value in settings.MKTG_URL_LINK_MAP.items():
|
||||
# no file extension was specified in the key
|
||||
template = "%s.%s" % (template, settings.STATIC_TEMPLATE_VIEW_DEFAULT_FILE_EXTENSION)
|
||||
|
||||
# To allow theme templates to inherit from default templates,
|
||||
# prepend a standard prefix
|
||||
if settings.FEATURES["USE_CUSTOM_THEME"]:
|
||||
template = "theme-" + template
|
||||
|
||||
# Make the assumption that the URL we want is the lowercased
|
||||
# version of the map key
|
||||
urlpatterns += (url(r'^%s$' % key.lower(),
|
||||
|
||||
@@ -41,26 +41,6 @@ def get_template(uri):
|
||||
return microsite.get_template(uri)
|
||||
|
||||
|
||||
def get_themed_template_path(relative_path, default_path, **kwargs):
|
||||
"""
|
||||
This is a proxy function to hide microsite_configuration behind comprehensive theming.
|
||||
|
||||
The workflow considers the "Stanford theming" feature alongside of microsites. It returns
|
||||
the path of the themed template (i.e. relative_path) if Stanford theming is enabled AND
|
||||
microsite theming is disabled, otherwise it will return the path of either the microsite
|
||||
override template or the base lms template.
|
||||
|
||||
:param relative_path: relative path of themed template
|
||||
:param default_path: relative path of the microsite's or lms template to use if
|
||||
theming is disabled or microsite is enabled
|
||||
"""
|
||||
is_stanford_theming_enabled = settings.FEATURES.get("USE_CUSTOM_THEME", False)
|
||||
is_microsite = microsite.is_request_in_microsite()
|
||||
if is_stanford_theming_enabled and not is_microsite:
|
||||
return relative_path
|
||||
return microsite.get_template_path(default_path, **kwargs)
|
||||
|
||||
|
||||
def get_template_path_with_theme(relative_path):
|
||||
"""
|
||||
Returns template path in current site's theme if it finds one there otherwise returns same path.
|
||||
|
||||
@@ -137,3 +137,57 @@ class TestComprehensiveThemeDisabledCMS(TestCase):
|
||||
resp = self.client.get('/signin')
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertNotContains(resp, "Login Page override for test-theme.")
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
class TestStanfordTheme(TestCase):
|
||||
"""
|
||||
Test html, sass and static file overrides for stanford theme.
|
||||
These tests are added to ensure expected behavior after USE_CUSTOM_THEME is removed and
|
||||
a new theme 'stanford-style' is added instead.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Clear static file finders cache and register cleanup methods.
|
||||
"""
|
||||
super(TestStanfordTheme, self).setUp()
|
||||
|
||||
# Clear the internal staticfiles caches, to get test isolation.
|
||||
staticfiles.finders.get_finder.cache_clear()
|
||||
|
||||
@with_comprehensive_theme("stanford-style")
|
||||
def test_footer(self):
|
||||
"""
|
||||
Test stanford theme footer.
|
||||
"""
|
||||
resp = self.client.get('/')
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
# This string comes from header.html of test-theme
|
||||
self.assertContains(resp, "footer overrides for stanford theme go here")
|
||||
|
||||
@with_comprehensive_theme("stanford-style")
|
||||
def test_logo_image(self):
|
||||
"""
|
||||
Test custom logo.
|
||||
"""
|
||||
result = staticfiles.finders.find('stanford-style/images/logo.png')
|
||||
self.assertEqual(result, settings.REPO_ROOT / 'themes/stanford-style/lms/static/images/logo.png')
|
||||
|
||||
@with_comprehensive_theme("stanford-style")
|
||||
def test_favicon_image(self):
|
||||
"""
|
||||
Test correct favicon for custom theme.
|
||||
"""
|
||||
result = staticfiles.finders.find('stanford-style/images/favicon.ico')
|
||||
self.assertEqual(result, settings.REPO_ROOT / 'themes/stanford-style/lms/static/images/favicon.ico')
|
||||
|
||||
@with_comprehensive_theme("stanford-style")
|
||||
def test_index_page(self):
|
||||
"""
|
||||
Test custom theme overrides for index page.
|
||||
"""
|
||||
resp = self.client.get('/')
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
# This string comes from header.html of test-theme
|
||||
self.assertContains(resp, "Free courses from <strong>Stanford</strong>")
|
||||
|
||||
@@ -585,23 +585,6 @@ def _compile_sass(system, theme, debug, force, timing_info):
|
||||
return True
|
||||
|
||||
|
||||
def compile_templated_sass(systems, settings):
|
||||
"""
|
||||
Render Mako templates for Sass files.
|
||||
`systems` is a list of systems (e.g. 'lms' or 'studio' or both)
|
||||
`settings` is the Django settings module to use.
|
||||
"""
|
||||
for system in systems:
|
||||
if system == "studio":
|
||||
system = "cms"
|
||||
sh(django_cmd(
|
||||
system, settings, 'preprocess_assets',
|
||||
'{system}/static/sass/*.scss'.format(system=system),
|
||||
'{system}/static/themed_sass'.format(system=system)
|
||||
))
|
||||
print("\t\tFinished preprocessing {} assets.".format(system))
|
||||
|
||||
|
||||
def process_npm_assets():
|
||||
"""
|
||||
Process vendor libraries installed via NPM.
|
||||
@@ -766,7 +749,6 @@ def update_assets(args):
|
||||
)
|
||||
args = parser.parse_args(args)
|
||||
|
||||
compile_templated_sass(args.system, args.settings)
|
||||
process_xmodule_assets()
|
||||
process_npm_assets()
|
||||
compile_coffeescript()
|
||||
|
||||
@@ -28,10 +28,6 @@ EXPECTED_LMS_SASS_COMMAND = [
|
||||
EXPECTED_CMS_SASS_COMMAND = [
|
||||
u"python manage.py cms --settings={asset_settings} compile_sass cms ",
|
||||
]
|
||||
EXPECTED_PREPROCESS_ASSETS_COMMAND = (
|
||||
u"python manage.py {system} --settings={asset_settings} preprocess_assets"
|
||||
u" {system}/static/sass/*.scss {system}/static/themed_sass"
|
||||
)
|
||||
EXPECTED_COLLECT_STATIC_COMMAND = (
|
||||
u"python manage.py {system} --settings={asset_settings} collectstatic --noinput > /dev/null"
|
||||
)
|
||||
@@ -233,9 +229,6 @@ class TestPaverServerTasks(PaverTestCase):
|
||||
expected_asset_settings = "test_static_optimized"
|
||||
expected_collect_static = not is_fast and expected_settings != "devstack"
|
||||
if not is_fast:
|
||||
expected_messages.append(EXPECTED_PREPROCESS_ASSETS_COMMAND.format(
|
||||
system=system, asset_settings=expected_asset_settings
|
||||
))
|
||||
expected_messages.append(u"xmodule_assets common/static/xmodule")
|
||||
expected_messages.append(u"install npm_assets")
|
||||
expected_messages.append(EXPECTED_COFFEE_COMMAND.format(platform_root=self.platform_root))
|
||||
@@ -272,12 +265,6 @@ class TestPaverServerTasks(PaverTestCase):
|
||||
expected_collect_static = not is_fast and expected_settings != "devstack"
|
||||
expected_messages = []
|
||||
if not is_fast:
|
||||
expected_messages.append(EXPECTED_PREPROCESS_ASSETS_COMMAND.format(
|
||||
system="lms", asset_settings=expected_asset_settings
|
||||
))
|
||||
expected_messages.append(EXPECTED_PREPROCESS_ASSETS_COMMAND.format(
|
||||
system="cms", asset_settings=expected_asset_settings
|
||||
))
|
||||
expected_messages.append(u"xmodule_assets common/static/xmodule")
|
||||
expected_messages.append(u"install npm_assets")
|
||||
expected_messages.append(EXPECTED_COFFEE_COMMAND.format(platform_root=self.platform_root))
|
||||
|
||||
@@ -99,20 +99,6 @@ theme (so far):
|
||||
* ``header.html``
|
||||
* ``footer.html``
|
||||
|
||||
You should **not** use the following names in your comprehensive theme:
|
||||
|
||||
* ``themable-footer.html``
|
||||
|
||||
If you look at the ``main.html`` template file, you will notice that it includes
|
||||
``header.html`` and ``themable-footer.html``, rather than ``footer.html``.
|
||||
You might be inclined to override ``themable-footer.html`` as a result. DO NOT
|
||||
DO THIS. ``themable-footer.html`` is an additional layer of indirection that
|
||||
is necessary to avoid breaking microsites, which also refers to a file named
|
||||
``footer.html``. The goal is to eventually make comprehensive theming do
|
||||
everything that microsites does now, and then deprecate and remove microsites
|
||||
from the codebase. At that point, the ``themable-footer.html`` file will go
|
||||
away, since the additional layer of indirection will no longer be necessary.
|
||||
|
||||
Installing your theme
|
||||
---------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
<%inherit file="../main.html" />
|
||||
|
||||
<%block name="pagetitle">${_("This Course Unavailable In Your Country")}</%block>
|
||||
|
||||
<section class="outside-app">
|
||||
<p>
|
||||
<!-- Use this file to add embargo message for stanford theme, if you want to use the default embargo message then
|
||||
simply remove this file.-->
|
||||
</p>
|
||||
</section>
|
||||
@@ -0,0 +1,11 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
<%inherit file="../main.html" />
|
||||
|
||||
<%block name="pagetitle">${_("This Course Unavailable In Your Country")}</%block>
|
||||
|
||||
<section class="outside-app">
|
||||
<p>
|
||||
<!-- Use this file to add embargo message for stanford theme, if you want to use the default embargo message then
|
||||
simply remove this file.-->
|
||||
</p>
|
||||
</section>
|
||||
@@ -6,7 +6,7 @@
|
||||
<%!
|
||||
from datetime import date
|
||||
%>
|
||||
|
||||
<!-- footer overrides for stanford theme go here -->
|
||||
<div class="wrapper-footer">
|
||||
<footer>
|
||||
<div class="colophon">
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<%page expression_filter="h"/>
|
||||
<%!
|
||||
from django.utils.translation import ugettext as _
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
%>
|
||||
<%inherit file="../main.html" />
|
||||
|
||||
<%block name="pagetitle">${_("This Course Unavailable In Your Country")}</%block>
|
||||
|
||||
<main id="main" aria-label="Content" tabindex="-1">
|
||||
<section class="outside-app">
|
||||
<p>
|
||||
<!-- Use this file to add embargo message for stanford theme, if you want to use the default embargo message then
|
||||
simply remove this file.-->
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
Reference in New Issue
Block a user