From a1ba371f411669cf2dc1e889ec42685b1205123c Mon Sep 17 00:00:00 2001 From: alice Date: Tue, 14 Sep 2021 22:30:03 +0200 Subject: [PATCH] warn on renewal issues --- lambdainst/models.py | 9 +++ lambdainst/views.py | 10 ---- locale/fr/LC_MESSAGES/django.po | 98 ++++++++++++++++--------------- templates/lambdainst/account.html | 11 +++- 4 files changed, 68 insertions(+), 60 deletions(-) diff --git a/lambdainst/models.py b/lambdainst/models.py index 145c034..b963f17 100644 --- a/lambdainst/models.py +++ b/lambdainst/models.py @@ -1,7 +1,9 @@ import random +from datetime import timedelta from django.db import models, IntegrityError from django.contrib.auth.models import User from django.utils.translation import ugettext as _ +from django.utils import timezone from django_lcore.core import ( LcoreUserProfileMethods, setup_sync_hooks, @@ -63,6 +65,13 @@ 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 517b624..02539e7 100644 --- a/lambdainst/views.py +++ b/lambdainst/views.py @@ -182,14 +182,6 @@ def discourse_login(request): def index(request): 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: """Clever hack to get the price in templates with {{price.3}} with 3 an arbitrary number of months @@ -203,7 +195,6 @@ def index(request): context = dict( title=_("Account"), ref_url=ref_url, - twitter_link=twitter_url + urlencode(twitter_args), subscription=request.user.vpnuser.get_subscription(), backends=sorted(ACTIVE_BACKENDS.values(), key=lambda x: x.backend_display_name), subscr_backends=sorted( @@ -211,7 +202,6 @@ def index(request): key=lambda x: x.backend_id, ), default_backend="paypal", - hcaptcha_site_key=project_settings.HCAPTCHA_SITE_KEY, price=price_fn(), user_motd=site_config.MOTD_USER, ) diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index bb92702..377831f 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: unnamed project\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-14 18:16+0000\n" -"PO-Revision-Date: 2021-09-14 20:17+0200\n" +"POT-Creation-Date: 2021-09-14 20:19+0000\n" +"PO-Revision-Date: 2021-09-14 22:21+0200\n" "Last-Translator: alice \n" "Language-Team: French \n" "Language: fr\n" @@ -99,11 +99,11 @@ msgstr "E-Mail" msgid "Passwords are not the same" msgstr "Les mots de passe de correspondent pas" -#: lambdainst/models.py:23 +#: lambdainst/models.py:25 msgid "VPN User" msgstr "VPN User" -#: lambdainst/models.py:24 +#: lambdainst/models.py:26 msgid "VPN Users" msgstr "VPN Users" @@ -194,47 +194,43 @@ msgstr "" msgid "Invalid captcha. Please try again" msgstr "Captcha invalide. Veuillez ré-essayer" -#: lambdainst/views.py:187 -msgid "Awesome VPN! 3€ per month, with a free 7 days trial!" -msgstr "" - -#: lambdainst/views.py:204 +#: lambdainst/views.py:196 msgid "Account" msgstr "Compte" -#: lambdainst/views.py:388 +#: lambdainst/views.py:379 msgid "Invalid password" msgstr "Mot de passe invalide" -#: lambdainst/views.py:395 +#: lambdainst/views.py:386 msgid "OK! Email address changed." msgstr "OK! L'adresse a été changée." -#: lambdainst/views.py:398 +#: lambdainst/views.py:389 msgid "OK! Email address unset." msgstr "OK! L'adresse a été éffacée." -#: lambdainst/views.py:407 +#: lambdainst/views.py:398 msgid "Password and confirmation do not match" msgstr "Le mot de passe et la confirmation ne correspondent pas" -#: lambdainst/views.py:410 +#: lambdainst/views.py:401 msgid "OK! Password changed." msgstr "Votre mot de passe a bien été changé." -#: lambdainst/views.py:430 +#: lambdainst/views.py:421 msgid "OK! Your account has been deactivated." 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" msgstr "Options" -#: lambdainst/views.py:450 +#: lambdainst/views.py:441 msgid "Config" msgstr "Config" -#: lambdainst/views.py:482 templates/layout.html:43 +#: lambdainst/views.py:473 templates/layout.html:43 msgid "Servers" msgstr "Serveurs" @@ -481,83 +477,93 @@ msgstr "ACTIF" msgid "INACTIVE" msgstr "INACTIF" -#: templates/lambdainst/account.html:34 templates/lambdainst/account.html:68 +#: templates/lambdainst/account.html:34 templates/lambdainst/account.html:73 msgid "Subscription" msgstr "Abonnement" #: templates/lambdainst/account.html:37 #, python-format +msgid "" +"FAILING since %(since)s. (%(backend)s)
Please cancel and " +"subscribe again if you need to switch to another payment method." +msgstr "" +"ERREUR depuis %(since)s. (%(backend)s)
\n" +"Veuillez annuler et vous réabonner pour changer de méthode ou carte de " +"paiement." + +#: templates/lambdainst/account.html:42 +#, python-format msgid "ACTIVE. Renews on %(until)s via %(backend)s." msgstr "ACTIF. Renouvellement: %(until)s via %(backend)s" -#: templates/lambdainst/account.html:40 +#: templates/lambdainst/account.html:45 msgid "cancel" msgstr "annuler" -#: templates/lambdainst/account.html:48 +#: templates/lambdainst/account.html:53 msgid "Expiration" msgstr "Expiration" -#: templates/lambdainst/account.html:52 +#: templates/lambdainst/account.html:57 #, python-format msgid "(%(left)s left)" msgstr "(%(left)s restant)" -#: templates/lambdainst/account.html:76 +#: templates/lambdainst/account.html:81 msgid "Pay every" msgstr "Payer tous les" -#: templates/lambdainst/account.html:78 templates/lambdainst/account.html:79 -#: templates/lambdainst/account.html:80 templates/lambdainst/account.html:117 -#: templates/lambdainst/account.html:118 templates/lambdainst/account.html:119 +#: templates/lambdainst/account.html:83 templates/lambdainst/account.html:84 +#: templates/lambdainst/account.html:85 templates/lambdainst/account.html:122 +#: templates/lambdainst/account.html:123 templates/lambdainst/account.html:124 msgid "months" msgstr "mois" -#: templates/lambdainst/account.html:85 templates/lambdainst/account.html:124 +#: templates/lambdainst/account.html:90 templates/lambdainst/account.html:129 msgid "by" msgstr "par" -#: templates/lambdainst/account.html:97 +#: templates/lambdainst/account.html:102 msgid "Subscribe" msgstr "S'abonner" -#: templates/lambdainst/account.html:99 +#: templates/lambdainst/account.html:104 msgid "You can cancel the recurring payment at any time." 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" msgstr "Paiement ponctuel" -#: templates/lambdainst/account.html:114 +#: templates/lambdainst/account.html:119 msgid "Add" msgstr "Ajouter" -#: templates/lambdainst/account.html:116 +#: templates/lambdainst/account.html:121 msgid "month" msgstr "mois" -#: templates/lambdainst/account.html:136 +#: templates/lambdainst/account.html:141 msgid "Buy Now" msgstr "Payer" -#: templates/lambdainst/account.html:138 +#: templates/lambdainst/account.html:143 msgid "If you still have time, the first payment will be delayed." msgstr "S'il vous reste du temps, le premier paiement sera reporté." -#: templates/lambdainst/account.html:145 +#: templates/lambdainst/account.html:150 msgid "Coupon" msgstr "Coupon" -#: templates/lambdainst/account.html:152 +#: templates/lambdainst/account.html:157 msgid "Code" msgstr "Code" -#: templates/lambdainst/account.html:158 +#: templates/lambdainst/account.html:163 msgid "Use" msgstr "Utiliser" -#: templates/lambdainst/account.html:160 +#: templates/lambdainst/account.html:165 msgid "" "Our coupons are alphanumeric codes that give you a fixed duration of VPN " "access." @@ -565,11 +571,11 @@ msgstr "" "Nos coupons sont des codes alphanumériques qui donnent une durée fixe " "d'accès au VPN." -#: templates/lambdainst/account.html:161 +#: templates/lambdainst/account.html:166 msgid "They can be single or multi use." msgstr "À usage unique ou multiple." -#: templates/lambdainst/account.html:173 +#: templates/lambdainst/account.html:178 msgid "" "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." @@ -577,7 +583,7 @@ msgstr "" "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." -#: templates/lambdainst/account.html:178 +#: templates/lambdainst/account.html:183 msgid "" "Every subscription through this link will grant you 1 month of VPN " "access:" @@ -665,7 +671,6 @@ msgid "Enable IPv6?" msgstr "Activer l'IPv6?" #: templates/lambdainst/config.html:59 templates/lambdainst/wireguard.html:129 -#| msgid "Download {} v{}" msgid "Download" 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." #: templates/lambdainst/wireguard.html:132 -#| msgid "Code" msgid "QR Code" msgstr "Code QR" @@ -1062,8 +1066,8 @@ msgid "" "We already cover many common questions and problems in our Knowledge Base. Take a look if you have any question." msgstr "" -"Nous couvrons de nombreuses questions et problèmes dans notre F.A.Q." +"Nous couvrons de nombreuses questions et problèmes dans notre F.A.Q." #: templates/pages/help.html:29 msgid "" @@ -1071,8 +1075,8 @@ msgid "" "\"/tickets/\">Tickets for technical or billing issues." msgstr "" "Si vous devez nous contacter, le moyen le plus rapide est les tickets pour les questions technique en rapport à " -"votre compte." +"\">les tickets pour les questions technique en rapport à votre " +"compte." #: templates/pages/help.html:35 msgid "" diff --git a/templates/lambdainst/account.html b/templates/lambdainst/account.html index 2a75ccc..313eb7d 100644 --- a/templates/lambdainst/account.html +++ b/templates/lambdainst/account.html @@ -24,16 +24,21 @@ {% trans "Status" %} {% if user.vpnuser.is_paid %} - {% trans "ACTIVE" %} + {% trans "ACTIVE" %} {% else %} - {% trans "INACTIVE" %} + {% trans "INACTIVE" %} {% endif %} {% trans "Subscription" %} - {% 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 %} + FAILING since {{since}}. ({{backend}})
+ 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 %} ACTIVE. Renews on {{until}} via {{backend}}. {% endblocktrans %}