mirror of
https://github.com/simple-login/app.git
synced 2025-10-08 22:37:46 +08:00
Add LifetimeCoupon model and User.lifetime column
This commit is contained in:
parent
026fe4addd
commit
98d2882719
2 changed files with 47 additions and 1 deletions
|
@ -119,6 +119,9 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
db.Boolean, nullable=False, default=False, server_default="0"
|
db.Boolean, nullable=False, default=False, server_default="0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# some users could have lifetime premium
|
||||||
|
lifetime = db.Column(db.Boolean, default=False, nullable=False, server_default="0")
|
||||||
|
|
||||||
profile_picture = db.relationship(File)
|
profile_picture = db.relationship(File)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -225,7 +228,6 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
else:
|
else:
|
||||||
return sub
|
return sub
|
||||||
|
|
||||||
|
|
||||||
def verified_custom_domains(self):
|
def verified_custom_domains(self):
|
||||||
return CustomDomain.query.filter_by(user_id=self.id, verified=True).all()
|
return CustomDomain.query.filter_by(user_id=self.id, verified=True).all()
|
||||||
|
|
||||||
|
@ -715,3 +717,8 @@ class CustomDomain(db.Model, ModelMixin):
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Custom Domain {self.domain}>"
|
return f"<Custom Domain {self.domain}>"
|
||||||
|
|
||||||
|
|
||||||
|
class LifetimeCoupon(db.Model, ModelMixin):
|
||||||
|
code = db.Column(db.String(128), nullable=False, unique=True)
|
||||||
|
nb_used = db.Column(db.Integer, nullable=False)
|
||||||
|
|
39
migrations/versions/2020_010120_d29cca963221_.py
Normal file
39
migrations/versions/2020_010120_d29cca963221_.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: d29cca963221
|
||||||
|
Revises: 01f808f15b2e
|
||||||
|
Create Date: 2020-01-01 20:01:51.861329
|
||||||
|
|
||||||
|
"""
|
||||||
|
import sqlalchemy_utils
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'd29cca963221'
|
||||||
|
down_revision = '01f808f15b2e'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('lifetime_coupon',
|
||||||
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||||
|
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
|
||||||
|
sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
|
||||||
|
sa.Column('code', sa.String(length=128), nullable=False),
|
||||||
|
sa.Column('nb_used', sa.Integer(), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id'),
|
||||||
|
sa.UniqueConstraint('code')
|
||||||
|
)
|
||||||
|
op.add_column('users', sa.Column('lifetime', sa.Boolean(), server_default='0', nullable=False))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('users', 'lifetime')
|
||||||
|
op.drop_table('lifetime_coupon')
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Add table
Reference in a new issue