From 77baf60ca464900b32fecd1929ae3d8629231fe9 Mon Sep 17 00:00:00 2001 From: Son NK Date: Sun, 23 Feb 2020 17:02:49 +0700 Subject: [PATCH] Show user current plan in settings --- .../templates/dashboard/setting.html | 29 ++++++++++++------- app/dashboard/views/setting.py | 3 ++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/dashboard/templates/dashboard/setting.html b/app/dashboard/templates/dashboard/setting.html index c2813bd1..01df04ae 100644 --- a/app/dashboard/templates/dashboard/setting.html +++ b/app/dashboard/templates/dashboard/setting.html @@ -145,20 +145,27 @@ - {% if current_user.get_subscription() %} -
-
-
Billing -
- Manage your current subscription. -
-
+
+
+
Current Plan
+ + {% if current_user.get_subscription() %} + You are on the {{ current_user.get_subscription().plan_name() }} plan.
- Manage Billing + Manage Subscription -
+ {% elif manual_sub %} + You are on the Premium plan. The plan ends {{ manual_sub.end_at | dt }}. + {% elif current_user.lifetime %} + You have the lifetime licence. + {% elif current_user.in_trial() %} + You are in the trial period. The trial ends {{ current_user.trial_end | dt }}. + {% else %} + You are on the Free plan. + {% endif %}
- {% endif %} +
+
diff --git a/app/dashboard/views/setting.py b/app/dashboard/views/setting.py index 632b7bd1..22f0fdd4 100644 --- a/app/dashboard/views/setting.py +++ b/app/dashboard/views/setting.py @@ -26,6 +26,7 @@ from app.models import ( CustomDomain, Client, AliasGeneratorEnum, + ManualSubscription, ) from app.utils import random_string @@ -183,6 +184,7 @@ def setting(): headers={"Content-Disposition": "attachment;filename=data.json"}, ) + manual_sub = ManualSubscription.get_by(user_id=current_user.id) return render_template( "dashboard/setting.html", form=form, @@ -191,6 +193,7 @@ def setting(): change_email_form=change_email_form, pending_email=pending_email, AliasGeneratorEnum=AliasGeneratorEnum, + manual_sub=manual_sub, )