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
353f310c
Commit
353f310c
authored
Oct 02, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed error message to be more in-line with possible reasons of the problem
parent
7093dadb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
lms/djangoapps/api_manager/users/tests.py
+4
-2
lms/djangoapps/api_manager/users/views.py
+3
-1
No files found.
lms/djangoapps/api_manager/users/tests.py
View file @
353f310c
...
...
@@ -377,9 +377,11 @@ class UsersApiTests(ModuleStoreTestCase):
data
=
{
'email'
:
self
.
test_email
,
'username'
:
local_username
,
'password'
:
self
.
test_password
,
'first_name'
:
self
.
test_first_name
,
'last_name'
:
self
.
test_last_name
}
response
=
self
.
do_post
(
test_uri
,
data
)
response
=
self
.
do_post
(
test_uri
,
data
)
expected_message
=
"Username '{username}' or email '{email}' already exists"
.
format
(
username
=
local_username
,
email
=
self
.
test_email
)
self
.
assertEqual
(
response
.
status_code
,
409
)
self
.
assert
Greater
(
response
.
data
[
'message'
],
0
)
self
.
assert
Equal
(
response
.
data
[
'message'
],
expected_message
)
self
.
assertEqual
(
response
.
data
[
'field_conflict'
],
'username or email'
)
@mock.patch.dict
(
"student.models.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_EMAIL_DIGEST"
:
True
})
...
...
lms/djangoapps/api_manager/users/views.py
View file @
353f310c
...
...
@@ -325,7 +325,9 @@ class UsersList(SecureListAPIView):
try
:
user
=
User
.
objects
.
create
(
email
=
email
,
username
=
username
,
is_staff
=
is_staff
)
except
IntegrityError
:
response_data
[
'message'
]
=
"User '
%
s' already exists"
%
(
username
)
response_data
[
'message'
]
=
_
(
"Username '{username}' or email '{email}' already exists"
)
.
format
(
username
=
username
,
email
=
email
)
response_data
[
'field_conflict'
]
=
"username or email"
return
Response
(
response_data
,
status
=
status
.
HTTP_409_CONFLICT
)
...
...
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