warn on renewal issues

master
alice 3 years ago
parent 85f9b2832f
commit a1ba371f41

@ -1,7 +1,9 @@
import random import random
from datetime import timedelta
from django.db import models, IntegrityError from django.db import models, IntegrityError
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils import timezone
from django_lcore.core import ( from django_lcore.core import (
LcoreUserProfileMethods, LcoreUserProfileMethods,
setup_sync_hooks, setup_sync_hooks,
@ -63,6 +65,13 @@ 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

@ -182,14 +182,6 @@ def discourse_login(request):
def index(request): def index(request):
ref_url = project_settings.ROOT_URL + "?ref=" + str(request.user.id) ref_url = project_settings.ROOT_URL + "?ref=" + str(request.user.id)
twitter_url = "https://twitter.com/intent/tweet?"
twitter_args = {
"text": _("Awesome VPN! 3€ per month, with a free 7 days trial!"),
"via": "CCrypto_VPN",
"url": ref_url,
"related": "CCrypto_VPN,CCrypto_org",
}
class price_fn: class price_fn:
"""Clever hack to get the price in templates with {{price.3}} with """Clever hack to get the price in templates with {{price.3}} with
3 an arbitrary number of months 3 an arbitrary number of months
@ -203,7 +195,6 @@ def index(request):
context = dict( context = dict(
title=_("Account"), title=_("Account"),
ref_url=ref_url, ref_url=ref_url,
twitter_link=twitter_url + urlencode(twitter_args),
subscription=request.user.vpnuser.get_subscription(), subscription=request.user.vpnuser.get_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(
@ -211,7 +202,6 @@ def index(request):
key=lambda x: x.backend_id, key=lambda x: x.backend_id,
), ),
default_backend="paypal", default_backend="paypal",
hcaptcha_site_key=project_settings.HCAPTCHA_SITE_KEY,
price=price_fn(), price=price_fn(),
user_motd=site_config.MOTD_USER, user_motd=site_config.MOTD_USER,
) )

@ -5,8 +5,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: unnamed project\n" "Project-Id-Version: unnamed project\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-14 18:16+0000\n" "POT-Creation-Date: 2021-09-14 20:19+0000\n"
"PO-Revision-Date: 2021-09-14 20:17+0200\n" "PO-Revision-Date: 2021-09-14 22:21+0200\n"
"Last-Translator: alice <alice@ccrypto.org>\n" "Last-Translator: alice <alice@ccrypto.org>\n"
"Language-Team: French <alice@ccrypto.org>\n" "Language-Team: French <alice@ccrypto.org>\n"
"Language: fr\n" "Language: fr\n"
@ -99,11 +99,11 @@ msgstr "E-Mail"
msgid "Passwords are not the same" msgid "Passwords are not the same"
msgstr "Les mots de passe de correspondent pas" msgstr "Les mots de passe de correspondent pas"
#: lambdainst/models.py:23 #: lambdainst/models.py:25
msgid "VPN User" msgid "VPN User"
msgstr "VPN User" msgstr "VPN User"
#: lambdainst/models.py:24 #: lambdainst/models.py:26
msgid "VPN Users" msgid "VPN Users"
msgstr "VPN Users" msgstr "VPN Users"
@ -194,47 +194,43 @@ msgstr ""
msgid "Invalid captcha. Please try again" msgid "Invalid captcha. Please try again"
msgstr "Captcha invalide. Veuillez ré-essayer" msgstr "Captcha invalide. Veuillez ré-essayer"
#: lambdainst/views.py:187 #: lambdainst/views.py:196
msgid "Awesome VPN! 3€ per month, with a free 7 days trial!"
msgstr ""
#: lambdainst/views.py:204
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
#: lambdainst/views.py:388 #: lambdainst/views.py:379
msgid "Invalid password" msgid "Invalid password"
msgstr "Mot de passe invalide" msgstr "Mot de passe invalide"
#: lambdainst/views.py:395 #: lambdainst/views.py:386
msgid "OK! Email address changed." msgid "OK! Email address changed."
msgstr "OK! L'adresse a été changée." msgstr "OK! L'adresse a été changée."
#: lambdainst/views.py:398 #: lambdainst/views.py:389
msgid "OK! Email address unset." msgid "OK! Email address unset."
msgstr "OK! L'adresse a été éffacée." msgstr "OK! L'adresse a été éffacée."
#: lambdainst/views.py:407 #: lambdainst/views.py:398
msgid "Password and confirmation do not match" msgid "Password and confirmation do not match"
msgstr "Le mot de passe et la confirmation ne correspondent pas" msgstr "Le mot de passe et la confirmation ne correspondent pas"
#: lambdainst/views.py:410 #: lambdainst/views.py:401
msgid "OK! Password changed." msgid "OK! Password changed."
msgstr "Votre mot de passe a bien été changé." msgstr "Votre mot de passe a bien été changé."
#: lambdainst/views.py:430 #: lambdainst/views.py:421
msgid "OK! Your account has been deactivated." msgid "OK! Your account has been deactivated."
msgstr "Votre compte a bien été désactivé." msgstr "Votre compte a bien été désactivé."
#: lambdainst/views.py:437 templates/account_layout.html:34 #: lambdainst/views.py:428 templates/account_layout.html:34
msgid "Settings" msgid "Settings"
msgstr "Options" msgstr "Options"
#: lambdainst/views.py:450 #: lambdainst/views.py:441
msgid "Config" msgid "Config"
msgstr "Config" msgstr "Config"
#: lambdainst/views.py:482 templates/layout.html:43 #: lambdainst/views.py:473 templates/layout.html:43
msgid "Servers" msgid "Servers"
msgstr "Serveurs" msgstr "Serveurs"
@ -481,83 +477,93 @@ msgstr "ACTIF"
msgid "INACTIVE" msgid "INACTIVE"
msgstr "INACTIF" msgstr "INACTIF"
#: templates/lambdainst/account.html:34 templates/lambdainst/account.html:68 #: templates/lambdainst/account.html:34 templates/lambdainst/account.html:73
msgid "Subscription" msgid "Subscription"
msgstr "Abonnement" msgstr "Abonnement"
#: templates/lambdainst/account.html:37 #: templates/lambdainst/account.html:37
#, python-format #, python-format
msgid ""
"<b>FAILING</b> since %(since)s. (%(backend)s)<br /> Please cancel and "
"subscribe again if you need to switch to another payment method."
msgstr ""
"<b>ERREUR</b> depuis %(since)s. (%(backend)s)<br />\n"
"Veuillez annuler et vous réabonner pour changer de méthode ou carte de "
"paiement."
#: templates/lambdainst/account.html:42
#, python-format
msgid "<b>ACTIVE</b>. Renews on %(until)s via %(backend)s." msgid "<b>ACTIVE</b>. Renews on %(until)s via %(backend)s."
msgstr "<b>ACTIF</b>. Renouvellement: %(until)s via %(backend)s" msgstr "<b>ACTIF</b>. Renouvellement: %(until)s via %(backend)s"
#: templates/lambdainst/account.html:40 #: templates/lambdainst/account.html:45
msgid "cancel" msgid "cancel"
msgstr "annuler" msgstr "annuler"
#: templates/lambdainst/account.html:48 #: templates/lambdainst/account.html:53
msgid "Expiration" msgid "Expiration"
msgstr "Expiration" msgstr "Expiration"
#: templates/lambdainst/account.html:52 #: templates/lambdainst/account.html:57
#, python-format #, python-format
msgid "(%(left)s left)" msgid "(%(left)s left)"
msgstr "(%(left)s restant)" msgstr "(%(left)s restant)"
#: templates/lambdainst/account.html:76 #: templates/lambdainst/account.html:81
msgid "Pay every" msgid "Pay every"
msgstr "Payer tous les" msgstr "Payer tous les"
#: templates/lambdainst/account.html:78 templates/lambdainst/account.html:79 #: templates/lambdainst/account.html:83 templates/lambdainst/account.html:84
#: templates/lambdainst/account.html:80 templates/lambdainst/account.html:117 #: templates/lambdainst/account.html:85 templates/lambdainst/account.html:122
#: templates/lambdainst/account.html:118 templates/lambdainst/account.html:119 #: templates/lambdainst/account.html:123 templates/lambdainst/account.html:124
msgid "months" msgid "months"
msgstr "mois" msgstr "mois"
#: templates/lambdainst/account.html:85 templates/lambdainst/account.html:124 #: templates/lambdainst/account.html:90 templates/lambdainst/account.html:129
msgid "by" msgid "by"
msgstr "par" msgstr "par"
#: templates/lambdainst/account.html:97 #: templates/lambdainst/account.html:102
msgid "Subscribe" msgid "Subscribe"
msgstr "S'abonner" msgstr "S'abonner"
#: templates/lambdainst/account.html:99 #: templates/lambdainst/account.html:104
msgid "You can cancel the recurring payment at any time." msgid "You can cancel the recurring payment at any time."
msgstr "Vous pouvez annuler le paiement récurrent à n'importe quel moment." msgstr "Vous pouvez annuler le paiement récurrent à n'importe quel moment."
#: templates/lambdainst/account.html:106 #: templates/lambdainst/account.html:111
msgid "One-time payment" msgid "One-time payment"
msgstr "Paiement ponctuel" msgstr "Paiement ponctuel"
#: templates/lambdainst/account.html:114 #: templates/lambdainst/account.html:119
msgid "Add" msgid "Add"
msgstr "Ajouter" msgstr "Ajouter"
#: templates/lambdainst/account.html:116 #: templates/lambdainst/account.html:121
msgid "month" msgid "month"
msgstr "mois" msgstr "mois"
#: templates/lambdainst/account.html:136 #: templates/lambdainst/account.html:141
msgid "Buy Now" msgid "Buy Now"
msgstr "Payer" msgstr "Payer"
#: templates/lambdainst/account.html:138 #: templates/lambdainst/account.html:143
msgid "If you still have time, the first payment will be delayed." msgid "If you still have time, the first payment will be delayed."
msgstr "S'il vous reste du temps, le premier paiement sera reporté." msgstr "S'il vous reste du temps, le premier paiement sera reporté."
#: templates/lambdainst/account.html:145 #: templates/lambdainst/account.html:150
msgid "Coupon" msgid "Coupon"
msgstr "Coupon" msgstr "Coupon"
#: templates/lambdainst/account.html:152 #: templates/lambdainst/account.html:157
msgid "Code" msgid "Code"
msgstr "Code" msgstr "Code"
#: templates/lambdainst/account.html:158 #: templates/lambdainst/account.html:163
msgid "Use" msgid "Use"
msgstr "Utiliser" msgstr "Utiliser"
#: templates/lambdainst/account.html:160 #: templates/lambdainst/account.html:165
msgid "" msgid ""
"Our coupons are alphanumeric codes that give you a fixed duration of VPN " "Our coupons are alphanumeric codes that give you a fixed duration of VPN "
"access." "access."
@ -565,11 +571,11 @@ msgstr ""
"Nos coupons sont des codes alphanumériques qui donnent une durée fixe " "Nos coupons sont des codes alphanumériques qui donnent une durée fixe "
"d'accès au VPN." "d'accès au VPN."
#: templates/lambdainst/account.html:161 #: templates/lambdainst/account.html:166
msgid "They can be single or multi use." msgid "They can be single or multi use."
msgstr "À usage unique ou multiple." msgstr "À usage unique ou multiple."
#: templates/lambdainst/account.html:173 #: templates/lambdainst/account.html:178
msgid "" msgid ""
"Please recommend us to your friends and on social media! We do not advertise " "Please recommend us to your friends and on social media! We do not advertise "
"and rely on you to help us grow and improve our services." "and rely on you to help us grow and improve our services."
@ -577,7 +583,7 @@ msgstr ""
"Recommandez-nous à vos amis et sur les réseaux sociaux! Nous ne faisons pas " "Recommandez-nous à vos amis et sur les réseaux sociaux! Nous ne faisons pas "
"de publicité et comptons sur vous pour nous aider à améliorer nos services." "de publicité et comptons sur vous pour nous aider à améliorer nos services."
#: templates/lambdainst/account.html:178 #: templates/lambdainst/account.html:183
msgid "" msgid ""
"Every subscription through this link will grant you 1&nbsp;month of VPN " "Every subscription through this link will grant you 1&nbsp;month of VPN "
"access:" "access:"
@ -665,7 +671,6 @@ msgid "Enable IPv6?"
msgstr "Activer l'IPv6?" msgstr "Activer l'IPv6?"
#: templates/lambdainst/config.html:59 templates/lambdainst/wireguard.html:129 #: templates/lambdainst/config.html:59 templates/lambdainst/wireguard.html:129
#| msgid "Download {} v{}"
msgid "Download" msgid "Download"
msgstr "Télécharger" msgstr "Télécharger"
@ -873,7 +878,6 @@ msgid "You can try an alternative server port if 51820 is blocked."
msgstr "Essayez un port alternatif si 51820 est bloqué pour vous." msgstr "Essayez un port alternatif si 51820 est bloqué pour vous."
#: templates/lambdainst/wireguard.html:132 #: templates/lambdainst/wireguard.html:132
#| msgid "Code"
msgid "QR Code" msgid "QR Code"
msgstr "Code QR" msgstr "Code QR"
@ -1062,8 +1066,8 @@ msgid ""
"We already cover many common questions and problems in our <a href=\"/kb/" "We already cover many common questions and problems in our <a href=\"/kb/"
"\"><em>Knowledge Base</em></a>. Take a look if you have any question." "\"><em>Knowledge Base</em></a>. Take a look if you have any question."
msgstr "" msgstr ""
"Nous couvrons de nombreuses questions et problèmes dans notre <a href=" "Nous couvrons de nombreuses questions et problèmes dans notre <a href=\"/kb/"
"\"/kb/\"><em>F.A.Q.</em></a>" "\"><em>F.A.Q.</em></a>"
#: templates/pages/help.html:29 #: templates/pages/help.html:29
msgid "" msgid ""
@ -1071,8 +1075,8 @@ msgid ""
"\"/tickets/\"><em>Tickets</em></a> for technical or billing issues." "\"/tickets/\"><em>Tickets</em></a> for technical or billing issues."
msgstr "" msgstr ""
"Si vous devez nous contacter, le moyen le plus rapide est <a href=\"/tickets/" "Si vous devez nous contacter, le moyen le plus rapide est <a href=\"/tickets/"
"\"><em>les tickets</em></a> pour les questions technique en rapport à " "\"><em>les tickets</em></a> pour les questions technique en rapport à votre "
"votre compte." "compte."
#: templates/pages/help.html:35 #: templates/pages/help.html:35
msgid "" msgid ""

@ -33,7 +33,12 @@
<tr> <tr>
<td>{% trans "Subscription" %}</td> <td>{% trans "Subscription" %}</td>
<td> <td>
{% if subscription.status == 'active' %} {% 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 %}
<b>FAILING</b> since {{since}}. ({{backend}})<br />
Please cancel and subscribe again if you need to switch to another payment method.
{% endblocktrans %}
{% 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 %} {% 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 %}

Loading…
Cancel
Save