diff --git a/lambdainst/models.py b/lambdainst/models.py
index ace9ef1..0b566d8 100644
--- a/lambdainst/models.py
+++ b/lambdainst/models.py
@@ -65,13 +65,6 @@ class VPNUser(models.Model, BaseSubUser, LcoreUserProfileMethods):
self.referrer_used = True
self.save()
- @property
- def subscr_is_failing(self):
- margin = timedelta(hours=24)
- if self.expiration < timezone.now() + margin:
- return True
- return False
-
def lcore_sync(self):
if VPN_AUTH_STORAGE == "inst":
return
diff --git a/lambdainst/views.py b/lambdainst/views.py
index ff501d7..2add3d5 100644
--- a/lambdainst/views.py
+++ b/lambdainst/views.py
@@ -195,7 +195,8 @@ def index(request):
context = dict(
title=_("Account"),
ref_url=ref_url,
- subscription=request.user.vpnuser.get_subscription(),
+ active_subscription=request.user.vpnuser.get_active_subscription(),
+ last_subscription=request.user.vpnuser.get_last_subscription(),
backends=sorted(ACTIVE_BACKENDS.values(), key=lambda x: x.backend_display_name),
subscr_backends=sorted(
(b for b in ACTIVE_BACKENDS.values() if b.backend_has_recurring),
diff --git a/templates/lambdainst/account.html b/templates/lambdainst/account.html
index 3569f40..71f0e41 100644
--- a/templates/lambdainst/account.html
+++ b/templates/lambdainst/account.html
@@ -33,23 +33,26 @@
{% trans "Subscription" %} |
- {% if subscription.status == 'active' and request.user.vpnuser.subscr_is_failing %}
- {% blocktrans trimmed with since=subscription.next_renew|default:user.vpnuser.expiration|date:'Y-m-d' backend=subscription.backend.backend_verbose_name %}
- FAILING since {{since}}. ({{backend}})
- Please cancel and subscribe again if you need to switch to another payment method.
- {% endblocktrans %}
- ({% trans "cancel" %})
- {% elif subscription.status == 'active' %}
- {% blocktrans trimmed with until=subscription.next_renew|default:user.vpnuser.expiration|date:'Y-m-d' backend=subscription.backend.backend_verbose_name %}
+ {% if active_subscription %}
+ {% blocktrans trimmed with until=active_subscription.next_renew|default:user.vpnuser.expiration|date:'Y-m-d' backend=active_subscription.backend.backend_verbose_name %}
ACTIVE. Renews on {{until}} via {{backend}}.
{% endblocktrans %}
({% trans "cancel" %})
+ {% elif last_subscription %}
+ {% if last_subscription.status == 'cancelled' %}
+ {% trans "CANCELLED. You can subscribe again below." %}
+ {% elif last_subscription.status == 'error' %}
+ {% trans "Last payment failed, likely because your card expired." %}
+ {% trans "You can update your subscription below." %}
+ {% elif last_subscription.status == 'new' %}
+ {% trans "Pending" %}
+ {% endif %}
{% else %}
-
{% endif %}
|
- {% if not subscription or subscription.status != 'active' %}
+ {% if not active_subscription %}
{% trans "Expiration" %} |
@@ -66,7 +69,7 @@
- {% if not subscription %}
+ {% if not active_subscription %}
|