Add support for custom billing invoice email address

Fixes #782
This commit is contained in:
Joseph Schorr 2015-12-28 13:59:50 -05:00
parent 16f16e8a15
commit 10efa96009
12 changed files with 94 additions and 23 deletions

View file

@ -44,6 +44,7 @@ def org_view(o, teams):
if is_admin:
view['invoice_email'] = o.invoice_email
view['invoice_email_address'] = o.invoice_email_address
return view
@ -119,6 +120,10 @@ class Organization(ApiResource):
'type': 'boolean',
'description': 'Whether the organization desires to receive emails for invoices',
},
'invoice_email_address': {
'type': 'string',
'description': 'The email address at which to receive invoices',
},
'tag_expiration': {
'type': 'integer',
'maximum': 2592000,
@ -159,7 +164,13 @@ class Organization(ApiResource):
org_data = request.get_json()
if 'invoice_email' in org_data:
logger.debug('Changing invoice_email for organization: %s', org.username)
model.user.change_invoice_email(org, org_data['invoice_email'])
model.user.change_send_invoice_email(org, org_data['invoice_email'])
if ('invoice_email_address' in org_data and
org_data['invoice_email_address'] != org.invoice_email_address):
new_email = org_data['invoice_email_address']
logger.debug('Changing invoice email address for organization: %s', org.username)
model.user.change_invoice_email_address(org, new_email)
if 'email' in org_data and org_data['email'] != org.email:
new_email = org_data['email']