Merge pull request #6872 from edx/will/country-access-message-theme
Country access messaging theme fixup
This commit is contained in:
@@ -19,7 +19,7 @@ BlockedMessage = namedtuple('BlockedMessage', [
|
||||
ENROLL_MESSAGES = {
|
||||
'default': BlockedMessage(
|
||||
description='Default',
|
||||
template='static_templates/enrollment_access_block.html'
|
||||
template='embargo/default_enrollment.html'
|
||||
),
|
||||
'embargo': BlockedMessage(
|
||||
description='Embargo',
|
||||
@@ -31,10 +31,19 @@ ENROLL_MESSAGES = {
|
||||
COURSEWARE_MESSAGES = {
|
||||
'default': BlockedMessage(
|
||||
description='Default',
|
||||
template='static_templates/courseware_access_block.html'
|
||||
template='embargo/default_courseware.html'
|
||||
),
|
||||
'embargo': BlockedMessage(
|
||||
description='Embargo',
|
||||
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'
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ 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
|
||||
import ddt
|
||||
|
||||
from util.testing import UrlResetMixin
|
||||
@@ -47,6 +48,24 @@ class CourseAccessMessageViewTest(UrlResetMixin, TestCase):
|
||||
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})
|
||||
@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')
|
||||
|
||||
def _load_page(self, access_point, message_key, expected_status=200):
|
||||
"""Load the message page and check the status code. """
|
||||
url = reverse('embargo_blocked_message', kwargs={
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from django.http import Http404
|
||||
from django.views.generic.base import View
|
||||
from django.conf import settings
|
||||
|
||||
from edxmako.shortcuts import render_to_response
|
||||
|
||||
@@ -55,14 +56,18 @@ 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.
|
||||
if access_point == self.ENROLLMENT_ACCESS_POINT:
|
||||
elif access_point == self.ENROLLMENT_ACCESS_POINT:
|
||||
message_dict = messages.ENROLL_MESSAGES
|
||||
elif access_point == self.COURSEWARE_ACCESS_POINT:
|
||||
message_dict = messages.COURSEWARE_MESSAGES
|
||||
|
||||
# Return the message corresponding to the given key if one is available.
|
||||
return message_dict.get(message_key)
|
||||
|
||||
Reference in New Issue
Block a user