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
5452b882
Commit
5452b882
authored
Jun 04, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add email changing to user API.
parent
322f51f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
lms/djangoapps/api_manager/users/views.py
+19
-0
No files found.
lms/djangoapps/api_manager/users/views.py
View file @
5452b882
...
...
@@ -468,6 +468,25 @@ class UsersDetail(SecureAPIView):
if
is_staff
is
not
None
:
existing_user
.
is_staff
=
is_staff
response_data
[
'is_staff'
]
=
existing_user
.
is_staff
email
=
request
.
DATA
.
get
(
'email'
)
if
email
is
not
None
:
email_fail
=
False
try
:
validate_email
(
email
)
except
ValidationError
:
email_fail
=
True
response_data
[
'message'
]
=
_
(
'Invalid email address {}.'
)
.
format
(
repr
(
email
))
if
email
!=
existing_user
.
email
:
try
:
# Email addresses need to be unique in the LMS, though Django doesn't enforce it directly.
User
.
objects
.
get
(
email
=
email
)
email_fail
=
True
response_data
[
'message'
]
=
_
(
'A user with that email address already exists.'
)
except
ObjectDoesNotExist
:
pass
if
email_fail
:
return
Response
(
response_data
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
existing_user
.
email
=
email
existing_user
.
save
()
username
=
request
.
DATA
.
get
(
'username'
,
None
)
...
...
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