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
5b644298
Commit
5b644298
authored
Apr 17, 2015
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7737 from edx/enrollment-api-full-urls
Returning complete URL for Enrollment API user messaging
parents
e81a883e
cd503938
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
common/djangoapps/enrollment/tests/test_views.py
+10
-6
common/djangoapps/enrollment/views.py
+1
-1
No files found.
common/djangoapps/enrollment/tests/test_views.py
View file @
5b644298
...
@@ -495,7 +495,11 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
...
@@ -495,7 +495,11 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
'user'
:
self
.
user
.
username
'user'
:
self
.
user
.
username
})
})
def
assert_access_denied
(
self
,
user_message_url
):
def
_get_absolute_url
(
self
,
path
):
""" Generate an absolute URL for a resource on the test server. """
return
u'http://testserver/{}'
.
format
(
path
.
lstrip
(
'/'
))
def
assert_access_denied
(
self
,
user_message_path
):
"""
"""
Verify that the view returns HTTP status 403 and includes a URL in the response, and no enrollment is created.
Verify that the view returns HTTP status 403 and includes a URL in the response, and no enrollment is created.
"""
"""
...
@@ -507,6 +511,7 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
...
@@ -507,6 +511,7 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
# Expect that the redirect URL is included in the response
# Expect that the redirect URL is included in the response
resp_data
=
json
.
loads
(
response
.
content
)
resp_data
=
json
.
loads
(
response
.
content
)
user_message_url
=
self
.
_get_absolute_url
(
user_message_path
)
self
.
assertEqual
(
resp_data
[
'user_message_url'
],
user_message_url
)
self
.
assertEqual
(
resp_data
[
'user_message_url'
],
user_message_url
)
# Verify that we were not enrolled
# Verify that we were not enrolled
...
@@ -517,8 +522,8 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
...
@@ -517,8 +522,8 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
""" Validates that enrollment changes are blocked if the request originates from an embargoed country. """
""" Validates that enrollment changes are blocked if the request originates from an embargoed country. """
# Use the helper to setup the embargo and simulate a request from a blocked IP address.
# Use the helper to setup the embargo and simulate a request from a blocked IP address.
with
restrict_course
(
self
.
course
.
id
)
as
redirect_
url
:
with
restrict_course
(
self
.
course
.
id
)
as
redirect_
path
:
self
.
assert_access_denied
(
redirect_
url
)
self
.
assert_access_denied
(
redirect_
path
)
def
_setup_embargo
(
self
):
def
_setup_embargo
(
self
):
restricted_course
=
RestrictedCourse
.
objects
.
create
(
course_key
=
self
.
course
.
id
)
restricted_course
=
RestrictedCourse
.
objects
.
create
(
course_key
=
self
.
course
.
id
)
...
@@ -548,9 +553,8 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
...
@@ -548,9 +553,8 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
self
.
user
.
profile
.
country
=
restricted_country
.
country
self
.
user
.
profile
.
country
=
restricted_country
.
country
self
.
user
.
profile
.
save
()
self
.
user
.
profile
.
save
()
user_message_url
=
reverse
(
'embargo_blocked_message'
,
path
=
reverse
(
'embargo_blocked_message'
,
kwargs
=
{
'access_point'
:
'enrollment'
,
'message_key'
:
'default'
})
kwargs
=
{
'access_point'
:
'enrollment'
,
'message_key'
:
'default'
})
self
.
assert_access_denied
(
path
)
self
.
assert_access_denied
(
user_message_url
)
@override_settings
(
EDX_API_KEY
=
EnrollmentTestMixin
.
API_KEY
)
@override_settings
(
EDX_API_KEY
=
EnrollmentTestMixin
.
API_KEY
)
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
...
...
common/djangoapps/enrollment/views.py
View file @
5b644298
...
@@ -384,7 +384,7 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
...
@@ -384,7 +384,7 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
"message"
:
(
"message"
:
(
u"Users from this location cannot access the course '{course_id}'."
u"Users from this location cannot access the course '{course_id}'."
)
.
format
(
course_id
=
course_id
),
)
.
format
(
course_id
=
course_id
),
"user_message_url"
:
re
direct_url
"user_message_url"
:
re
quest
.
build_absolute_uri
(
redirect_url
)
}
}
)
)
...
...
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