improve message on renew failure

master
alice 3 years ago
parent 7bae01ec2a
commit f19a6ee685

@ -65,13 +65,6 @@ class VPNUser(models.Model, BaseSubUser, LcoreUserProfileMethods):
self.referrer_used = True self.referrer_used = True
self.save() 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): def lcore_sync(self):
if VPN_AUTH_STORAGE == "inst": if VPN_AUTH_STORAGE == "inst":
return return

@ -195,7 +195,8 @@ def index(request):
context = dict( context = dict(
title=_("Account"), title=_("Account"),
ref_url=ref_url, 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), backends=sorted(ACTIVE_BACKENDS.values(), key=lambda x: x.backend_display_name),
subscr_backends=sorted( subscr_backends=sorted(
(b for b in ACTIVE_BACKENDS.values() if b.backend_has_recurring), (b for b in ACTIVE_BACKENDS.values() if b.backend_has_recurring),

@ -33,23 +33,26 @@
<tr> <tr>
<td>{% trans "Subscription" %}</td> <td>{% trans "Subscription" %}</td>
<td> <td>
{% if subscription.status == 'active' and request.user.vpnuser.subscr_is_failing %} {% if active_subscription %}
{% blocktrans trimmed with since=subscription.next_renew|default:user.vpnuser.expiration|date:'Y-m-d' backend=subscription.backend.backend_verbose_name %} {% blocktrans trimmed with until=active_subscription.next_renew|default:user.vpnuser.expiration|date:'Y-m-d' backend=active_subscription.backend.backend_verbose_name %}
<b>FAILING</b> since {{since}}. ({{backend}})<br />
Please cancel and subscribe again if you need to switch to another payment method.
{% endblocktrans %}
(<a href="{% url 'payments:cancel_subscr' %}">{% trans "cancel" %}</a>)
{% 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 %}
<b>ACTIVE</b>. Renews on {{until}} via {{backend}}. <b>ACTIVE</b>. Renews on {{until}} via {{backend}}.
{% endblocktrans %} {% endblocktrans %}
(<a href="{% url 'payments:cancel_subscr' %}">{% trans "cancel" %}</a>) (<a href="{% url 'payments:cancel_subscr' %}">{% trans "cancel" %}</a>)
{% elif last_subscription %}
{% if last_subscription.status == 'cancelled' %}
{% trans "<b>CANCELLED</b>. You can subscribe again below." %}
{% elif last_subscription.status == 'error' %}
{% trans "<b>Last payment failed</b>, likely because your card expired." %}
{% trans "You can update your subscription below." %}
{% elif last_subscription.status == 'new' %}
{% trans "Pending" %}
{% endif %}
{% else %} {% else %}
- -
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% if not subscription or subscription.status != 'active' %} {% if not active_subscription %}
<tr> <tr>
<td>{% trans "Expiration" %}</td> <td>{% trans "Expiration" %}</td>
<td> <td>
@ -66,7 +69,7 @@
</div> </div>
{% if not subscription %} {% if not active_subscription %}
<div class="content-box account-fund"> <div class="content-box account-fund">
<div class="account-payment-box account-payment-tabs"> <div class="account-payment-box account-payment-tabs">
<div class="account-payment-tab"> <div class="account-payment-tab">

Loading…
Cancel
Save