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
8ec2de93
Commit
8ec2de93
authored
Sep 29, 2015
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRF 3.1 now uses request.data instead of request.DATA
parent
e21ddabe
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
30 additions
and
30 deletions
+30
-30
common/djangoapps/enrollment/views.py
+6
-6
lms/djangoapps/commerce/api/v0/views.py
+2
-2
lms/djangoapps/discussion_api/views.py
+4
-4
lms/djangoapps/mobile_api/social_facebook/groups/views.py
+2
-2
lms/djangoapps/mobile_api/social_facebook/preferences/views.py
+1
-1
lms/djangoapps/mobile_api/users/views.py
+2
-2
lms/djangoapps/teams/views.py
+6
-6
openedx/core/djangoapps/user_api/accounts/views.py
+1
-1
openedx/core/djangoapps/user_api/preferences/views.py
+3
-3
openedx/core/djangoapps/user_api/views.py
+2
-2
openedx/core/lib/api/view_utils.py
+1
-1
No files found.
common/djangoapps/enrollment/views.py
View file @
8ec2de93
...
...
@@ -497,8 +497,8 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
"""
# Get the User, Course ID, and Mode from the request.
username
=
request
.
DATA
.
get
(
'user'
,
request
.
user
.
username
)
course_id
=
request
.
DATA
.
get
(
'course_details'
,
{})
.
get
(
'course_id'
)
username
=
request
.
data
.
get
(
'user'
,
request
.
user
.
username
)
course_id
=
request
.
data
.
get
(
'course_details'
,
{})
.
get
(
'course_id'
)
if
not
course_id
:
return
Response
(
...
...
@@ -516,7 +516,7 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
}
)
mode
=
request
.
DATA
.
get
(
'mode'
,
CourseMode
.
HONOR
)
mode
=
request
.
data
.
get
(
'mode'
,
CourseMode
.
HONOR
)
has_api_key_permissions
=
self
.
has_api_key_permissions
(
request
)
...
...
@@ -555,7 +555,7 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
return
embargo_response
try
:
is_active
=
request
.
DATA
.
get
(
'is_active'
)
is_active
=
request
.
data
.
get
(
'is_active'
)
# Check if the requested activation status is None or a Boolean
if
is_active
is
not
None
and
not
isinstance
(
is_active
,
bool
):
return
Response
(
...
...
@@ -565,7 +565,7 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
}
)
enrollment_attributes
=
request
.
DATA
.
get
(
'enrollment_attributes'
)
enrollment_attributes
=
request
.
data
.
get
(
'enrollment_attributes'
)
enrollment
=
api
.
get_enrollment
(
username
,
unicode
(
course_id
))
mode_changed
=
enrollment
and
mode
is
not
None
and
enrollment
[
'mode'
]
!=
mode
active_changed
=
enrollment
and
is_active
is
not
None
and
enrollment
[
'is_active'
]
!=
is_active
...
...
@@ -605,7 +605,7 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
# Will reactivate inactive enrollments.
response
=
api
.
add_enrollment
(
username
,
unicode
(
course_id
),
mode
=
mode
,
is_active
=
is_active
)
email_opt_in
=
request
.
DATA
.
get
(
'email_opt_in'
,
None
)
email_opt_in
=
request
.
data
.
get
(
'email_opt_in'
,
None
)
if
email_opt_in
is
not
None
:
org
=
course_id
.
org
update_email_opt_in
(
request
.
user
,
org
,
email_opt_in
)
...
...
lms/djangoapps/commerce/api/v0/views.py
View file @
8ec2de93
...
...
@@ -45,7 +45,7 @@ class BasketsView(APIView):
Returns
Tuple (data_is_valid, course_key, error_msg)
"""
course_id
=
request
.
DATA
.
get
(
'course_id'
)
course_id
=
request
.
data
.
get
(
'course_id'
)
if
not
course_id
:
return
False
,
None
,
u'Field course_id is missing.'
...
...
@@ -69,7 +69,7 @@ class BasketsView(APIView):
Errors here aren't expected, but should not break the outer enrollment transaction.
"""
email_opt_in
=
request
.
DATA
.
get
(
'email_opt_in'
,
None
)
email_opt_in
=
request
.
data
.
get
(
'email_opt_in'
,
None
)
if
email_opt_in
is
not
None
:
try
:
update_email_opt_in
(
user
,
course_key
.
org
,
email_opt_in
)
...
...
lms/djangoapps/discussion_api/views.py
View file @
8ec2de93
...
...
@@ -270,14 +270,14 @@ class ThreadViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
Implements the POST method for the list endpoint as described in the
class docstring.
"""
return
Response
(
create_thread
(
request
,
request
.
DATA
))
return
Response
(
create_thread
(
request
,
request
.
data
))
def
partial_update
(
self
,
request
,
thread_id
):
"""
Implements the PATCH method for the instance endpoint as described in
the class docstring.
"""
return
Response
(
update_thread
(
request
,
thread_id
,
request
.
DATA
))
return
Response
(
update_thread
(
request
,
thread_id
,
request
.
data
))
def
destroy
(
self
,
request
,
thread_id
):
"""
...
...
@@ -425,7 +425,7 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
Implements the POST method for the list endpoint as described in the
class docstring.
"""
return
Response
(
create_comment
(
request
,
request
.
DATA
))
return
Response
(
create_comment
(
request
,
request
.
data
))
def
destroy
(
self
,
request
,
comment_id
):
"""
...
...
@@ -440,4 +440,4 @@ class CommentViewSet(_ViewMixin, DeveloperErrorViewMixin, ViewSet):
Implements the PATCH method for the instance endpoint as described in
the class docstring.
"""
return
Response
(
update_comment
(
request
,
comment_id
,
request
.
DATA
))
return
Response
(
update_comment
(
request
,
comment_id
,
request
.
data
))
lms/djangoapps/mobile_api/social_facebook/groups/views.py
View file @
8ec2de93
...
...
@@ -45,7 +45,7 @@ class Groups(generics.CreateAPIView, mixins.DestroyModelMixin):
serializer_class
=
serializers
.
GroupSerializer
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
serializer
=
self
.
get_serializer
(
data
=
request
.
DATA
)
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
if
not
serializer
.
is_valid
():
return
Response
(
serializer
.
errors
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
try
:
...
...
@@ -106,7 +106,7 @@ class GroupsMembers(generics.CreateAPIView, mixins.DestroyModelMixin):
serializer_class
=
serializers
.
GroupsMembersSerializer
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
serializer
=
self
.
get_serializer
(
data
=
request
.
DATA
)
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
if
not
serializer
.
is_valid
():
return
Response
(
serializer
.
errors
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
graph
=
facebook_graph_api
()
...
...
lms/djangoapps/mobile_api/social_facebook/preferences/views.py
View file @
8ec2de93
...
...
@@ -39,7 +39,7 @@ class UserSharing(generics.ListCreateAPIView):
serializer_class
=
serializers
.
UserSharingSerializar
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
serializer
=
self
.
get_serializer
(
data
=
request
.
DATA
)
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
if
serializer
.
is_valid
():
value
=
serializer
.
data
[
'share_with_facebook_friends'
]
set_user_preference
(
request
.
user
,
"share_with_facebook_friends"
,
value
)
...
...
lms/djangoapps/mobile_api/users/views.py
View file @
8ec2de93
...
...
@@ -182,8 +182,8 @@ class UserCourseStatus(views.APIView):
"""
Update the ID of the module that the specified user last visited in the specified course.
"""
module_id
=
request
.
DATA
.
get
(
"last_visited_module_id"
)
modification_date_string
=
request
.
DATA
.
get
(
"modification_date"
)
module_id
=
request
.
data
.
get
(
"last_visited_module_id"
)
modification_date_string
=
request
.
data
.
get
(
"modification_date"
)
modification_date
=
None
if
modification_date_string
:
modification_date
=
dateparse
.
parse_datetime
(
modification_date_string
)
...
...
lms/djangoapps/teams/views.py
View file @
8ec2de93
...
...
@@ -488,7 +488,7 @@ class TeamsListView(ExpandableFieldViewMixin, GenericAPIView):
field_errors
=
{}
course_key
=
None
course_id
=
request
.
DATA
.
get
(
'course_id'
)
course_id
=
request
.
data
.
get
(
'course_id'
)
try
:
course_key
=
CourseKey
.
from_string
(
course_id
)
# Ensure the course exists
...
...
@@ -517,7 +517,7 @@ class TeamsListView(ExpandableFieldViewMixin, GenericAPIView):
if
course_key
and
not
has_team_api_access
(
request
.
user
,
course_key
):
return
Response
(
status
=
status
.
HTTP_403_FORBIDDEN
)
data
=
request
.
DATA
.
copy
()
data
=
request
.
data
.
copy
()
data
[
'course_id'
]
=
course_key
serializer
=
CourseTeamCreationSerializer
(
data
=
data
)
...
...
@@ -1098,10 +1098,10 @@ class MembershipListView(ExpandableFieldViewMixin, GenericAPIView):
"""POST /api/team/v0/team_membership"""
field_errors
=
{}
if
'username'
not
in
request
.
DATA
:
if
'username'
not
in
request
.
data
:
field_errors
[
'username'
]
=
build_api_error
(
ugettext_noop
(
"Username is required."
))
if
'team_id'
not
in
request
.
DATA
:
if
'team_id'
not
in
request
.
data
:
field_errors
[
'team_id'
]
=
build_api_error
(
ugettext_noop
(
"Team id is required."
))
if
field_errors
:
...
...
@@ -1110,11 +1110,11 @@ class MembershipListView(ExpandableFieldViewMixin, GenericAPIView):
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
try
:
team
=
CourseTeam
.
objects
.
get
(
team_id
=
request
.
DATA
[
'team_id'
])
team
=
CourseTeam
.
objects
.
get
(
team_id
=
request
.
data
[
'team_id'
])
except
CourseTeam
.
DoesNotExist
:
return
Response
(
status
=
status
.
HTTP_404_NOT_FOUND
)
username
=
request
.
DATA
[
'username'
]
username
=
request
.
data
[
'username'
]
if
not
has_team_api_access
(
request
.
user
,
team
.
course_id
,
access_username
=
username
):
return
Response
(
status
=
status
.
HTTP_404_NOT_FOUND
)
...
...
openedx/core/djangoapps/user_api/accounts/views.py
View file @
8ec2de93
...
...
@@ -162,7 +162,7 @@ class AccountView(APIView):
"""
try
:
with
transaction
.
commit_on_success
():
update_account_settings
(
request
.
user
,
request
.
DATA
,
username
=
username
)
update_account_settings
(
request
.
user
,
request
.
data
,
username
=
username
)
except
UserNotAuthorized
:
return
Response
(
status
=
status
.
HTTP_403_FORBIDDEN
if
request
.
user
.
is_staff
else
status
.
HTTP_404_NOT_FOUND
)
except
UserNotFound
:
...
...
openedx/core/djangoapps/user_api/preferences/views.py
View file @
8ec2de93
...
...
@@ -107,7 +107,7 @@ class PreferencesView(APIView):
"""
PATCH /api/user/v1/preferences/{username}/
"""
if
not
request
.
DATA
or
not
getattr
(
request
.
DATA
,
"keys"
,
None
):
if
not
request
.
data
or
not
getattr
(
request
.
data
,
"keys"
,
None
):
error_message
=
_
(
"No data provided for user preference update"
)
return
Response
(
{
...
...
@@ -118,7 +118,7 @@ class PreferencesView(APIView):
)
try
:
with
transaction
.
commit_on_success
():
update_user_preferences
(
request
.
user
,
request
.
DATA
,
username
=
username
)
update_user_preferences
(
request
.
user
,
request
.
data
,
username
=
username
)
except
UserNotAuthorized
:
return
Response
(
status
=
status
.
HTTP_403_FORBIDDEN
)
except
UserNotFound
:
...
...
@@ -218,7 +218,7 @@ class PreferencesDetailView(APIView):
PUT /api/user/v1/preferences/{username}/{preference_key}
"""
try
:
set_user_preference
(
request
.
user
,
preference_key
,
request
.
DATA
,
username
=
username
)
set_user_preference
(
request
.
user
,
preference_key
,
request
.
data
,
username
=
username
)
except
UserNotAuthorized
:
return
Response
(
status
=
status
.
HTTP_403_FORBIDDEN
)
except
UserNotFound
:
...
...
openedx/core/djangoapps/user_api/views.py
View file @
8ec2de93
...
...
@@ -875,7 +875,7 @@ class UpdateEmailOptInPreference(APIView):
assume False.
"""
course_id
=
request
.
DATA
[
'course_id'
]
course_id
=
request
.
data
[
'course_id'
]
try
:
org
=
locator
.
CourseLocator
.
from_string
(
course_id
)
.
org
except
InvalidKeyError
:
...
...
@@ -885,6 +885,6 @@ class UpdateEmailOptInPreference(APIView):
content_type
=
"text/plain"
)
# Only check for true. All other values are False.
email_opt_in
=
request
.
DATA
[
'email_opt_in'
]
.
lower
()
==
'true'
email_opt_in
=
request
.
data
[
'email_opt_in'
]
.
lower
()
==
'true'
update_email_opt_in
(
request
.
user
,
org
,
email_opt_in
)
return
HttpResponse
(
status
=
status
.
HTTP_200_OK
)
openedx/core/lib/api/view_utils.py
View file @
8ec2de93
...
...
@@ -173,7 +173,7 @@ class RetrievePatchAPIView(RetrieveModelMixin, UpdateModelMixin, GenericAPIView)
def
patch
(
self
,
request
,
*
args
,
**
kwargs
):
"""Checks for validation errors, then updates the model using the UpdateModelMixin."""
field_errors
=
self
.
_validate_patch
(
request
.
DATA
)
field_errors
=
self
.
_validate_patch
(
request
.
data
)
if
field_errors
:
return
Response
({
'field_errors'
:
field_errors
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
return
self
.
partial_update
(
request
,
*
args
,
**
kwargs
)
...
...
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