fix updateUser - added save ro DB

fix parameter name
                             fix documentation
This commit is contained in:
Aran Zaiger 2015-06-16 22:28:05 +03:00
parent d428da5df0
commit 4bb17157d0

View file

@ -83,8 +83,8 @@ def updateUser(token):
<b>Payload</b><br> <b>Payload</b><br>
- JSON Object, Example: <br> - JSON Object, Example: <br>
{<br> {<br>
'name': 'Campus name',<br> 'name': 'new name',<br>
'isLecturer': '@campus.ac.com',<br> 'isLecturer': true<br>
}<br> }<br>
<br> <br>
<b>Response</b> <b>Response</b>
@ -100,23 +100,24 @@ def updateUser(token):
try: try:
payload = json.loads(request.data) payload = json.loads(request.data)
except Exception as e: except Exception as e:
return bad_request(e) return bad_request()
user = get_user_by_token(token) user = get_user_by_token(token)
if user is None: if user is None:
return bad_request("Not a user!") return bad_request("Not a user!")
try: try:
user.name = payload['user'] user.name = payload['name']
except Exception: except Exception:
pass pass
try: try:
user.isLecturer = payload['isLecturer'] user.isLecturer = payload['isLecturer']
except Exception: except Exception as e:
pass print e
db.put(user)
db.save
return ok("User updated") return ok("User updated")