mirror of
https://github.com/kennethreitz-archive/www.gittip.com.git
synced 2026-06-21 15:50:59 +00:00
22 lines
696 B
JSON
22 lines
696 B
JSON
from aspen import Response, log_dammit
|
|
from gittip.models import Participant
|
|
|
|
# ========================================================================== ^L
|
|
|
|
if user.ANON:
|
|
raise Response(404)
|
|
|
|
new_username = request.body['username']
|
|
|
|
try:
|
|
old_username = user.username
|
|
user.change_username(new_username)
|
|
response.body = {"username": new_username}
|
|
log_dammit("user with username %s has become username %s" % (old_username, new_username))
|
|
except (Participant.UsernameContainsInvalidCharacters, Participant.UsernameIsRestricted):
|
|
raise Response(400)
|
|
except Participant.UsernameAlreadyTaken:
|
|
raise Response(409)
|
|
except Participant.UsernameTooLong:
|
|
raise Response(413)
|