Revert "ziafazal/WL-328: Multi-Site Comprehensive Theming"
This reverts commit 954dae584a.
This commit is contained in:
@@ -22,7 +22,7 @@ from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from student.models import CourseEnrollment
|
||||
import lms.djangoapps.commerce.tests.test_utils as ecomm_test_utils
|
||||
from course_modes.models import CourseMode, Mode
|
||||
from openedx.core.djangoapps.theming.test_util import with_comprehensive_theme
|
||||
from openedx.core.djangoapps.theming.test_util import with_is_edx_domain
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@@ -352,7 +352,7 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
|
||||
self.assertEquals(course_modes, expected_modes)
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@with_comprehensive_theme("edx.org")
|
||||
@with_is_edx_domain(True)
|
||||
def test_hide_nav(self):
|
||||
# Create the course modes
|
||||
for mode in ["honor", "verified"]:
|
||||
|
||||
@@ -9,14 +9,9 @@ import pkg_resources
|
||||
|
||||
from django.conf import settings
|
||||
from mako.lookup import TemplateLookup
|
||||
from mako.exceptions import TopLevelLookupException
|
||||
|
||||
from microsite_configuration import microsite
|
||||
from . import LOOKUP
|
||||
from openedx.core.djangoapps.theming.helpers import (
|
||||
get_template as themed_template,
|
||||
get_template_path_with_theme,
|
||||
strip_site_theme_templates_path,
|
||||
)
|
||||
|
||||
|
||||
class DynamicTemplateLookup(TemplateLookup):
|
||||
@@ -54,25 +49,15 @@ class DynamicTemplateLookup(TemplateLookup):
|
||||
|
||||
def get_template(self, uri):
|
||||
"""
|
||||
Overridden method for locating a template in either the database or the site theme.
|
||||
|
||||
If not found, template lookup will be done in comprehensive theme for current site
|
||||
by prefixing path to theme.
|
||||
e.g if uri is `main.html` then new uri would be something like this `/red-theme/lms/static/main.html`
|
||||
|
||||
If still unable to find a template, it will fallback to the default template directories after stripping off
|
||||
the prefix path to theme.
|
||||
Overridden method which will hand-off the template lookup to the microsite subsystem
|
||||
"""
|
||||
template = themed_template(uri)
|
||||
microsite_template = microsite.get_template(uri)
|
||||
|
||||
if not template:
|
||||
try:
|
||||
template = super(DynamicTemplateLookup, self).get_template(get_template_path_with_theme(uri))
|
||||
except TopLevelLookupException:
|
||||
# strip off the prefix path to theme and look in default template dirs
|
||||
template = super(DynamicTemplateLookup, self).get_template(strip_site_theme_templates_path(uri))
|
||||
|
||||
return template
|
||||
return (
|
||||
microsite_template
|
||||
if microsite_template
|
||||
else super(DynamicTemplateLookup, self).get_template(uri)
|
||||
)
|
||||
|
||||
|
||||
def clear_lookups(namespace):
|
||||
|
||||
@@ -12,18 +12,16 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponse
|
||||
from django.template import Context
|
||||
from django.http import HttpResponse
|
||||
import logging
|
||||
|
||||
from microsite_configuration import microsite
|
||||
|
||||
from edxmako import lookup_template
|
||||
from edxmako.middleware import get_template_request_context
|
||||
from openedx.core.djangoapps.theming.helpers import get_template_path
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -115,7 +113,8 @@ def microsite_footer_context_processor(request):
|
||||
|
||||
def render_to_string(template_name, dictionary, context=None, namespace='main'):
|
||||
|
||||
template_name = get_template_path(template_name)
|
||||
# see if there is an override template defined in the microsite
|
||||
template_name = microsite.get_template_path(template_name)
|
||||
|
||||
context_instance = Context(dictionary)
|
||||
# add dictionary to context_instance
|
||||
|
||||
@@ -11,6 +11,7 @@ BaseMicrositeTemplateBackend is Base Class for the microsite template backend.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import abc
|
||||
import edxmako
|
||||
import os.path
|
||||
import threading
|
||||
|
||||
@@ -271,7 +272,9 @@ class BaseMicrositeBackend(AbstractBaseMicrositeBackend):
|
||||
Configure the paths for the microsites feature
|
||||
"""
|
||||
microsites_root = settings.MICROSITE_ROOT_DIR
|
||||
|
||||
if os.path.isdir(microsites_root):
|
||||
edxmako.paths.add_lookup('main', microsites_root)
|
||||
settings.STATICFILES_DIRS.insert(0, microsites_root)
|
||||
|
||||
log.info('Loading microsite path at %s', microsites_root)
|
||||
@@ -289,7 +292,6 @@ class BaseMicrositeBackend(AbstractBaseMicrositeBackend):
|
||||
microsites_root = settings.MICROSITE_ROOT_DIR
|
||||
|
||||
if self.has_configuration_set():
|
||||
settings.MAKO_TEMPLATES['main'].insert(0, microsites_root)
|
||||
settings.DEFAULT_TEMPLATE_ENGINE['DIRS'].append(microsites_root)
|
||||
|
||||
|
||||
|
||||
@@ -105,23 +105,6 @@ class DatabaseMicrositeBackendTests(DatabaseMicrositeTestCase):
|
||||
microsite.clear()
|
||||
self.assertIsNone(microsite.get_value('platform_name'))
|
||||
|
||||
def test_enable_microsites_pre_startup(self):
|
||||
"""
|
||||
Tests microsite.test_enable_microsites_pre_startup works as expected.
|
||||
"""
|
||||
# remove microsite root directory paths first
|
||||
settings.DEFAULT_TEMPLATE_ENGINE['DIRS'] = [
|
||||
path for path in settings.DEFAULT_TEMPLATE_ENGINE['DIRS']
|
||||
if path != settings.MICROSITE_ROOT_DIR
|
||||
]
|
||||
with patch.dict('django.conf.settings.FEATURES', {'USE_MICROSITES': False}):
|
||||
microsite.enable_microsites_pre_startup(log)
|
||||
self.assertNotIn(settings.MICROSITE_ROOT_DIR, settings.DEFAULT_TEMPLATE_ENGINE['DIRS'])
|
||||
with patch.dict('django.conf.settings.FEATURES', {'USE_MICROSITES': True}):
|
||||
microsite.enable_microsites_pre_startup(log)
|
||||
self.assertIn(settings.MICROSITE_ROOT_DIR, settings.DEFAULT_TEMPLATE_ENGINE['DIRS'])
|
||||
self.assertIn(settings.MICROSITE_ROOT_DIR, settings.MAKO_TEMPLATES['main'])
|
||||
|
||||
@patch('edxmako.paths.add_lookup')
|
||||
def test_enable_microsites(self, add_lookup):
|
||||
"""
|
||||
@@ -139,6 +122,7 @@ class DatabaseMicrositeBackendTests(DatabaseMicrositeTestCase):
|
||||
with patch.dict('django.conf.settings.FEATURES', {'USE_MICROSITES': True}):
|
||||
microsite.enable_microsites(log)
|
||||
self.assertIn(settings.MICROSITE_ROOT_DIR, settings.STATICFILES_DIRS)
|
||||
add_lookup.assert_called_once_with('main', settings.MICROSITE_ROOT_DIR)
|
||||
|
||||
def test_get_all_configs(self):
|
||||
"""
|
||||
|
||||
@@ -4,13 +4,7 @@ from pipeline_mako import compressed_css, compressed_js
|
||||
from django.utils.translation import get_language_bidi
|
||||
from mako.exceptions import TemplateLookupException
|
||||
|
||||
from openedx.core.djangoapps.theming.helpers import (
|
||||
get_page_title_breadcrumbs,
|
||||
get_value,
|
||||
get_template_path,
|
||||
get_themed_template_path,
|
||||
is_request_in_themed_site,
|
||||
)
|
||||
from openedx.core.djangoapps.theming.helpers import get_page_title_breadcrumbs, get_value, get_template_path, get_themed_template_path, is_request_in_themed_site
|
||||
from certificates.api import get_asset_url_by_slug
|
||||
from lang_pref.api import released_languages
|
||||
%>
|
||||
|
||||
@@ -22,7 +22,7 @@ from edxmako.shortcuts import render_to_string
|
||||
from edxmako.tests import mako_middleware_process_request
|
||||
from util.request import safe_get_host
|
||||
from util.testing import EventTestMixin
|
||||
from openedx.core.djangoapps.theming.test_util import with_comprehensive_theme
|
||||
from openedx.core.djangoapps.theming.test_util import with_is_edx_domain
|
||||
|
||||
|
||||
class TestException(Exception):
|
||||
@@ -100,7 +100,7 @@ class ActivationEmailTests(TestCase):
|
||||
self._create_account()
|
||||
self._assert_activation_email(self.ACTIVATION_SUBJECT, self.OPENEDX_FRAGMENTS)
|
||||
|
||||
@with_comprehensive_theme("edx.org")
|
||||
@with_is_edx_domain(True)
|
||||
def test_activation_email_edx_domain(self):
|
||||
self._create_account()
|
||||
self._assert_activation_email(self.ACTIVATION_SUBJECT, self.EDX_DOMAIN_FRAGMENTS)
|
||||
|
||||
@@ -44,6 +44,7 @@ from certificates.tests.factories import GeneratedCertificateFactory # pylint:
|
||||
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
|
||||
import shoppingcart # pylint: disable=import-error
|
||||
from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin
|
||||
from openedx.core.djangoapps.theming.test_util import with_is_edx_domain
|
||||
|
||||
# Explicitly import the cache from ConfigurationModel so we can reset it after each test
|
||||
from config_models.models import cache
|
||||
@@ -491,6 +492,7 @@ class DashboardTest(ModuleStoreTestCase):
|
||||
self.assertEquals(response_2.status_code, 200)
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@with_is_edx_domain(True)
|
||||
def test_dashboard_header_nav_has_find_courses(self):
|
||||
self.client.login(username="jack", password="test")
|
||||
response = self.client.get(reverse("dashboard"))
|
||||
|
||||
Reference in New Issue
Block a user