diff --git a/migrations/versions/48074e6225c6_add_subscription_stripe_ended_at.py b/migrations/versions/48074e6225c6_add_subscription_stripe_ended_at.py new file mode 100644 index 00000000..37868d5c --- /dev/null +++ b/migrations/versions/48074e6225c6_add_subscription_stripe_ended_at.py @@ -0,0 +1,25 @@ +"""add subscription stripe_ended_at + +Revision ID: 48074e6225c6 +Revises: 207556b3039b +Create Date: 2024-02-11 17:21:19.287478 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "48074e6225c6" +down_revision = "207556b3039b" +branch_labels = None +depends_on = None + + +def upgrade(): + with op.batch_alter_table("subscription", schema=None) as batch_op: + batch_op.add_column(sa.Column("stripe_ended_at", sa.Integer(), nullable=True)) + + +def downgrade(): + pass diff --git a/subscribie/blueprints/admin/subscription.py b/subscribie/blueprints/admin/subscription.py index 66275181..06857c60 100644 --- a/subscribie/blueprints/admin/subscription.py +++ b/subscribie/blueprints/admin/subscription.py @@ -24,7 +24,9 @@ def update_stripe_subscription_statuses(app): stripe.api_key = get_stripe_secret_key() connect_account = get_stripe_connect_account() if stripe.api_key is None: - log.warning("Stripe api key not set refusing to update subscription statuses") # noqa: E501 + log.warning( + "Stripe api key not set refusing to update subscription statuses" + ) # noqa: E501 if connect_account is None: log.warning( "Stripe connect account not set. Refusing to update subscription statuses" # noqa: E501 @@ -53,6 +55,9 @@ def update_stripe_subscription_statuses(app): ) subscription.stripe_status = stripeSubscription.status + # Update stripeSubscription.ended_at if stripe subscription has ended # noqa: E501 + if stripeSubscription.ended_at is not None: + subscription.stripe_ended_at = stripeSubscription.ended_at log.info(subscription.stripe_status) log.info(subscription.stripe_subscription_id) database.session.commit() diff --git a/subscribie/blueprints/admin/templates/admin/subscribers.html b/subscribie/blueprints/admin/templates/admin/subscribers.html index 9953cc5e..bdcca11a 100644 --- a/subscribie/blueprints/admin/templates/admin/subscribers.html +++ b/subscribie/blueprints/admin/templates/admin/subscribers.html @@ -136,6 +136,11 @@