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
6490551f
Commit
6490551f
authored
Mar 04, 2016
by
Sanford Student
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MA-2103
parent
2b880d2d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
6 deletions
+7
-6
lms/djangoapps/course_api/api.py
+3
-1
lms/djangoapps/course_api/forms.py
+0
-3
lms/djangoapps/course_api/tests/test_forms.py
+2
-1
lms/djangoapps/course_api/tests/test_views.py
+2
-1
No files found.
lms/djangoapps/course_api/api.py
View file @
6490551f
...
...
@@ -2,7 +2,7 @@
Course API
"""
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
rest_framework.exceptions
import
PermissionDenied
from
lms.djangoapps.courseware.courses
import
(
...
...
@@ -19,6 +19,8 @@ def get_effective_user(requesting_user, target_username):
"""
if
target_username
==
requesting_user
.
username
:
return
requesting_user
elif
target_username
==
''
:
return
AnonymousUser
()
elif
can_view_courses_for_username
(
requesting_user
,
target_username
):
return
User
.
objects
.
get
(
username
=
target_username
)
else
:
...
...
lms/djangoapps/course_api/forms.py
View file @
6490551f
...
...
@@ -22,9 +22,6 @@ class UsernameValidatorMixin(object):
as an anonymous user.
"""
username
=
self
.
cleaned_data
.
get
(
'username'
)
if
not
username
:
if
not
self
.
initial
[
'requesting_user'
]
.
is_anonymous
():
raise
ValidationError
(
"A username is required for non-anonymous access."
)
return
username
or
''
...
...
lms/djangoapps/course_api/tests/test_forms.py
View file @
6490551f
...
...
@@ -26,8 +26,9 @@ class UsernameTestMixin(object):
self
.
assert_valid
(
self
.
cleaned_data
)
def
test_no_user_param
(
self
):
self
.
set_up_data
(
AnonymousUser
())
self
.
form_data
.
pop
(
'username'
)
self
.
assert_
error
(
'username'
,
"A username is required for non-anonymous access."
)
self
.
assert_
valid
(
self
.
cleaned_data
)
@ddt.ddt
...
...
lms/djangoapps/course_api/tests/test_views.py
View file @
6490551f
...
...
@@ -86,7 +86,8 @@ class CourseListViewTestCase(CourseApiTestViewMixin, SharedModuleStoreTestCase):
def
test_missing_username
(
self
):
self
.
setup_user
(
self
.
honor_user
)
self
.
verify_response
(
expected_status_code
=
400
)
response_to_missing_username
=
self
.
verify_response
(
expected_status_code
=
200
)
self
.
assertIsNotNone
(
response_to_missing_username
.
data
)
# pylint: disable=no-member
@SharedModuleStoreTestCase.modifies_courseware
def
test_filter_by_org
(
self
):
...
...
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