mirror of
https://github.com/simple-login/app.git
synced 2025-02-23 23:34:05 +08:00
Create CoinbaseSubscription model
This commit is contained in:
parent
8527fed69e
commit
9329cf04ad
2 changed files with 59 additions and 0 deletions
|
@ -1434,6 +1434,26 @@ class ManualSubscription(db.Model, ModelMixin):
|
|||
|
||||
user = db.relationship(User)
|
||||
|
||||
class CoinbaseSubscription(db.Model, ModelMixin):
|
||||
"""
|
||||
For subscriptions using Coinbase Commerce
|
||||
"""
|
||||
|
||||
user_id = db.Column(
|
||||
db.ForeignKey(User.id, ondelete="cascade"), nullable=False, unique=True
|
||||
)
|
||||
|
||||
# an reminder is sent several days before the subscription ends
|
||||
end_at = db.Column(ArrowType, nullable=False)
|
||||
|
||||
# the Coinbase code
|
||||
code = db.Column(db.String(64), nullable=True)
|
||||
|
||||
user = db.relationship(User)
|
||||
|
||||
def is_active(self):
|
||||
return self.end_at > arrow.now()
|
||||
|
||||
|
||||
# https://help.apple.com/app-store-connect/#/dev58bda3212
|
||||
_APPLE_GRACE_PERIOD_DAYS = 16
|
||||
|
|
39
migrations/versions/2020_121319_a20aeb9b0eac_.py
Normal file
39
migrations/versions/2020_121319_a20aeb9b0eac_.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: a20aeb9b0eac
|
||||
Revises: 780a8344914b
|
||||
Create Date: 2020-12-13 19:04:46.771429
|
||||
|
||||
"""
|
||||
import sqlalchemy_utils
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a20aeb9b0eac'
|
||||
down_revision = '780a8344914b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('coinbase_subscription',
|
||||
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('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('end_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
|
||||
sa.Column('code', sa.String(length=64), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user_id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('coinbase_subscription')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in a new issue