diff --git a/app/dashboard/__init__.py b/app/dashboard/__init__.py index 8363aa5d..ec7db995 100644 --- a/app/dashboard/__init__.py +++ b/app/dashboard/__init__.py @@ -25,4 +25,5 @@ from .views import ( contact_detail, setup_done, batch_import, + extend_subscription, ) diff --git a/app/dashboard/templates/dashboard/extend_subscription.html b/app/dashboard/templates/dashboard/extend_subscription.html new file mode 100644 index 00000000..5b861a20 --- /dev/null +++ b/app/dashboard/templates/dashboard/extend_subscription.html @@ -0,0 +1,36 @@ +{% extends 'default.html' %} + +{% set active_page = "dashboard" %} + +{% block title %} + Extend Subscription +{% endblock %} + +{% block default_content %} +
+
+

Extend Subscription

+ +

+ Your subscription is expired on {{ coinbase_subscription.end_at.format("YYYY-MM-DD") }} +

+ +
+ + Extend for 1 yearly - $30 + + +
+ +
+ Your subscription will be extended when the payment is confirmed and we'll send you a confirmation email.
+ Please note that it can take up to 1h for processing a cryptocurrency payment. +
+ +
+
+ + +{% endblock %} diff --git a/app/dashboard/views/extend_subscription.py b/app/dashboard/views/extend_subscription.py new file mode 100644 index 00000000..e10920aa --- /dev/null +++ b/app/dashboard/views/extend_subscription.py @@ -0,0 +1,24 @@ +from flask import render_template, flash, redirect, url_for +from flask_login import login_required, current_user + +from app.config import COINBASE_CHECKOUT_ID +from app.dashboard.base import dashboard_bp +from app.models import CoinbaseSubscription + + +@dashboard_bp.route("/extend_subscription", methods=["GET", "POST"]) +@login_required +def extend_subscription_route(): + coinbase_subscription = CoinbaseSubscription.get_by(user_id=current_user.id) + # this page is only for user who has an active coinbase subscription + if not coinbase_subscription or not coinbase_subscription.is_active(): + flash("Unknown error, redirect to home page", "error") + return redirect(url_for("dashboard.index")) + + coinbase_url = "https://commerce.coinbase.com/checkout/" + COINBASE_CHECKOUT_ID + + return render_template( + "dashboard/extend_subscription.html", + coinbase_subscription=coinbase_subscription, + coinbase_url=coinbase_url, + )