use id for editUser
This commit is contained in:
parent
92baea5c88
commit
bf3584bcf9
1 changed files with 5 additions and 5 deletions
|
@ -315,8 +315,8 @@ def editUser(request):
|
||||||
param data {
|
param data {
|
||||||
key: value
|
key: value
|
||||||
}
|
}
|
||||||
required key: username
|
required key: id
|
||||||
optional keys: newUsername, email, level, note
|
optional keys: username, email, level, note
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'status': {'code': int, 'text': string}
|
'status': {'code': int, 'text': string}
|
||||||
|
@ -326,7 +326,7 @@ def editUser(request):
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.load(request.POST['data'])
|
data = json.load(request.POST['data'])
|
||||||
user = get_object_or_404_json(models.User, username=data['username'])
|
user = get_object_or_404_json(models.User, username=data['id'])
|
||||||
profile = user.get_profile()
|
profile = user.get_profile()
|
||||||
if 'email' in data:
|
if 'email' in data:
|
||||||
user.email = data['email']
|
user.email = data['email']
|
||||||
|
@ -334,8 +334,8 @@ def editUser(request):
|
||||||
profile.set_level(data['level'])
|
profile.set_level(data['level'])
|
||||||
if 'note' in data:
|
if 'note' in data:
|
||||||
profile.note = data['note']
|
profile.note = data['note']
|
||||||
if 'newUsername' in data:
|
if 'username' in data:
|
||||||
user.username = data['newUsername']
|
user.username = data['username']
|
||||||
user.save()
|
user.save()
|
||||||
profile.save()
|
profile.save()
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
Loading…
Reference in a new issue