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
6fa7815f
Commit
6fa7815f
authored
Feb 03, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6872 from edx/will/country-access-message-theme
Country access messaging theme fixup
parents
e0610245
ce9c258f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
4 deletions
+37
-4
common/djangoapps/embargo/messages.py
+11
-2
common/djangoapps/embargo/tests/test_views.py
+19
-0
common/djangoapps/embargo/views.py
+7
-2
lms/templates/embargo/default_courseware.html
+0
-0
lms/templates/embargo/default_enrollment.html
+0
-0
No files found.
common/djangoapps/embargo/messages.py
View file @
6fa7815f
...
@@ -19,7 +19,7 @@ BlockedMessage = namedtuple('BlockedMessage', [
...
@@ -19,7 +19,7 @@ BlockedMessage = namedtuple('BlockedMessage', [
ENROLL_MESSAGES
=
{
ENROLL_MESSAGES
=
{
'default'
:
BlockedMessage
(
'default'
:
BlockedMessage
(
description
=
'Default'
,
description
=
'Default'
,
template
=
'
static_templates/enrollment_access_block
.html'
template
=
'
embargo/default_enrollment
.html'
),
),
'embargo'
:
BlockedMessage
(
'embargo'
:
BlockedMessage
(
description
=
'Embargo'
,
description
=
'Embargo'
,
...
@@ -31,10 +31,19 @@ ENROLL_MESSAGES = {
...
@@ -31,10 +31,19 @@ ENROLL_MESSAGES = {
COURSEWARE_MESSAGES
=
{
COURSEWARE_MESSAGES
=
{
'default'
:
BlockedMessage
(
'default'
:
BlockedMessage
(
description
=
'Default'
,
description
=
'Default'
,
template
=
'
static_templates/courseware_access_block
.html'
template
=
'
embargo/default_courseware
.html'
),
),
'embargo'
:
BlockedMessage
(
'embargo'
:
BlockedMessage
(
description
=
'Embargo'
,
description
=
'Embargo'
,
template
=
'static_templates/embargo.html'
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'
)
}
common/djangoapps/embargo/tests/test_views.py
View file @
6fa7815f
...
@@ -5,6 +5,7 @@ from mock import patch
...
@@ -5,6 +5,7 @@ from mock import patch
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
django.conf
import
settings
from
mako.exceptions
import
TopLevelLookupException
import
ddt
import
ddt
from
util.testing
import
UrlResetMixin
from
util.testing
import
UrlResetMixin
...
@@ -47,6 +48,24 @@ class CourseAccessMessageViewTest(UrlResetMixin, TestCase):
...
@@ -47,6 +48,24 @@ class CourseAccessMessageViewTest(UrlResetMixin, TestCase):
def
test_invalid_message_key
(
self
,
access_point
):
def
test_invalid_message_key
(
self
,
access_point
):
self
.
_load_page
(
access_point
,
'invalid'
,
expected_status
=
404
)
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
):
def
_load_page
(
self
,
access_point
,
message_key
,
expected_status
=
200
):
"""Load the message page and check the status code. """
"""Load the message page and check the status code. """
url
=
reverse
(
'embargo_blocked_message'
,
kwargs
=
{
url
=
reverse
(
'embargo_blocked_message'
,
kwargs
=
{
...
...
common/djangoapps/embargo/views.py
View file @
6fa7815f
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
from
django.http
import
Http404
from
django.http
import
Http404
from
django.views.generic.base
import
View
from
django.views.generic.base
import
View
from
django.conf
import
settings
from
edxmako.shortcuts
import
render_to_response
from
edxmako.shortcuts
import
render_to_response
...
@@ -55,14 +56,18 @@ class CourseAccessMessageView(View):
...
@@ -55,14 +56,18 @@ class CourseAccessMessageView(View):
"""
"""
message_dict
=
dict
()
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.
# The access point determines which set of messages to use.
# This allows us to show different messages to students who
# This allows us to show different messages to students who
# are enrolling in a course than we show to students
# are enrolling in a course than we show to students
# who are enrolled and accessing courseware.
# who are enrolled and accessing courseware.
if
access_point
==
self
.
ENROLLMENT_ACCESS_POINT
:
el
if
access_point
==
self
.
ENROLLMENT_ACCESS_POINT
:
message_dict
=
messages
.
ENROLL_MESSAGES
message_dict
=
messages
.
ENROLL_MESSAGES
elif
access_point
==
self
.
COURSEWARE_ACCESS_POINT
:
elif
access_point
==
self
.
COURSEWARE_ACCESS_POINT
:
message_dict
=
messages
.
COURSEWARE_MESSAGES
message_dict
=
messages
.
COURSEWARE_MESSAGES
# Return the message corresponding to the given key if one is available.
return
message_dict
.
get
(
message_key
)
return
message_dict
.
get
(
message_key
)
lms/templates/
static_templates/courseware_access_block
.html
→
lms/templates/
embargo/default_courseware
.html
View file @
6fa7815f
File moved
lms/templates/
static_templates/enrollment_access_block
.html
→
lms/templates/
embargo/default_enrollment
.html
View file @
6fa7815f
File moved
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