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
2d1d5822
Commit
2d1d5822
authored
Jan 22, 2015
by
stephensanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow the enrollment API to be used without knowing the authenticted user name.
parent
fcd7736d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
common/djangoapps/enrollment/tests/test_views.py
+17
-0
common/djangoapps/enrollment/urls.py
+5
-0
common/djangoapps/enrollment/views.py
+1
-0
No files found.
common/djangoapps/enrollment/tests/test_views.py
View file @
2d1d5822
...
...
@@ -106,6 +106,23 @@ class EnrollmentTest(ModuleStoreTestCase, APITestCase):
self
.
assertEqual
(
1
,
len
(
data
[
'course_details'
][
'course_modes'
]))
self
.
assertEqual
(
'professional'
,
data
[
'course_details'
][
'course_modes'
][
0
][
'slug'
])
def
test_user_not_specified
(
self
):
CourseModeFactory
.
create
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'honor'
,
mode_display_name
=
'Honor'
,
)
# Create an enrollment
self
.
_create_enrollment
()
resp
=
self
.
client
.
get
(
reverse
(
'courseenrollment'
,
kwargs
=
{
"course_id"
:
unicode
(
self
.
course
.
id
)})
)
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_200_OK
)
data
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
unicode
(
self
.
course
.
id
),
data
[
'course_details'
][
'course_id'
])
self
.
assertEqual
(
'honor'
,
data
[
'mode'
])
self
.
assertTrue
(
data
[
'is_active'
])
def
test_user_not_authenticated
(
self
):
# Log out, so we're no longer authenticated
self
.
client
.
logout
()
...
...
common/djangoapps/enrollment/urls.py
View file @
2d1d5822
...
...
@@ -20,6 +20,11 @@ urlpatterns = patterns(
EnrollmentView
.
as_view
(),
name
=
'courseenrollment'
),
url
(
r'^enrollment/{course_key}$'
.
format
(
course_key
=
settings
.
COURSE_ID_PATTERN
),
EnrollmentView
.
as_view
(),
name
=
'courseenrollment'
),
url
(
r'^enrollment$'
,
EnrollmentListView
.
as_view
(),
name
=
'courseenrollments'
),
url
(
r'^course/{course_key}$'
.
format
(
course_key
=
settings
.
COURSE_ID_PATTERN
),
...
...
common/djangoapps/enrollment/views.py
View file @
2d1d5822
...
...
@@ -82,6 +82,7 @@ class EnrollmentView(APIView):
A JSON serialized representation of the course enrollment.
"""
user
=
user
if
user
else
request
.
user
.
username
if
request
.
user
.
username
!=
user
:
# Return a 404 instead of a 403 (Unauthorized). If one user is looking up
# other users, do not let them deduce the existence of an enrollment.
...
...
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