parent
16f16e8a15
commit
10efa96009
12 changed files with 94 additions and 23 deletions
|
@ -288,6 +288,7 @@ class User(BaseModel):
|
|||
last_invalid_login = DateTimeField(default=datetime.utcnow)
|
||||
removed_tag_expiration_s = IntegerField(default=1209600) # Two weeks
|
||||
enabled = BooleanField(default=True)
|
||||
invoice_email_address = CharField(null=True, index=True)
|
||||
|
||||
def delete_instance(self, recursive=False, delete_nullable=False):
|
||||
# If we are deleting a robot account, only execute the subset of queries necessary.
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
"""Add invoice email address to user
|
||||
|
||||
Revision ID: 471caec2cb66
|
||||
Revises: 88e0f440a2f
|
||||
Create Date: 2015-12-28 13:57:17.761334
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '471caec2cb66'
|
||||
down_revision = '88e0f440a2f'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
def upgrade(tables):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('user', sa.Column('invoice_email_address', sa.String(length=255), nullable=True))
|
||||
op.create_index('user_invoice_email_address', 'user', ['invoice_email_address'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(tables):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('user', 'invoice_email_address')
|
||||
### end Alembic commands ###
|
|
@ -125,7 +125,13 @@ def change_username(user_id, new_username):
|
|||
return user
|
||||
|
||||
|
||||
def change_invoice_email(user, invoice_email):
|
||||
def change_invoice_email_address(user, invoice_email_address):
|
||||
# Note: We null out the address if it is an empty string.
|
||||
user.invoice_email_address = invoice_email_address or None
|
||||
user.save()
|
||||
|
||||
|
||||
def change_send_invoice_email(user, invoice_email):
|
||||
user.invoice_email = invoice_email
|
||||
user.save()
|
||||
|
||||
|
|
Reference in a new issue