Add ability to change an organization’s email address

This commit is contained in:
Joseph Schorr 2014-01-20 16:12:23 -05:00
parent f0add0e6cf
commit cbf80281ba
7 changed files with 262 additions and 3 deletions

View file

@ -522,7 +522,20 @@ def change_organization_details(orgname):
if 'invoice_email' in org_data:
logger.debug('Changing invoice_email for organization: %s', org.username)
model.change_invoice_email(org, org_data['invoice_email'])
if 'email' in org_data and org_data['email'] != org.email:
new_email = org_data['email']
if model.find_user_by_email(new_email):
# Email already used.
error_resp = jsonify({
'message': 'E-mail address already used'
})
error_resp.status_code = 400
return error_resp
logger.debug('Changing email address for organization: %s', org.username)
model.update_email(org, new_email)
teams = model.get_teams_within_org(org)
return jsonify(org_view(org, teams))