From 03afd491154f99dca81e9a42e81b45ee9eb16a74 Mon Sep 17 00:00:00 2001 From: imperosol Date: Sun, 20 Oct 2024 11:06:49 +0200 Subject: [PATCH 1/3] make the mail text only --- .../counter/account_dump_warning_mail.jinja | 63 ++++++++----------- locale/fr/LC_MESSAGES/django.po | 45 ++++++------- 2 files changed, 49 insertions(+), 59 deletions(-) diff --git a/counter/templates/counter/account_dump_warning_mail.jinja b/counter/templates/counter/account_dump_warning_mail.jinja index 1d7dc8ed..34419f75 100644 --- a/counter/templates/counter/account_dump_warning_mail.jinja +++ b/counter/templates/counter/account_dump_warning_mail.jinja @@ -1,43 +1,32 @@ -

- Bonjour, -

+{% trans %}Hello{% endtrans %}, -

- {%- trans date=last_subscription_date|date(DATETIME_FORMAT) -%} - You received this email because your last subscription to the - Students' association ended on {{ date }}. - {%- endtrans -%} -

+{% trans trimmed date=last_subscription_date|date(DATETIME_FORMAT) -%} + You received this email because your last subscription to the + Students' association ended on {{ date }}. +{%- endtrans %} -

- {%- trans date=dump_date|date(DATETIME_FORMAT), amount=balance -%} - In accordance with the Internal Regulations, the balance of any - inactive AE account for more than 2 years automatically goes back - to the AE. - The money present on your account will therefore be recovered in full - on {{ date }}, for a total of {{ amount }} €. - {%- endtrans -%} -

+{% trans trimmed date=dump_date|date(DATETIME_FORMAT), amount=balance -%} + In accordance with the Internal Regulations, the balance of any + inactive AE account for more than 2 years automatically goes back + to the AE. + The money present on your account will therefore be recovered in full + on {{ date }}, for a total of {{ amount }} €. +{%- endtrans %} -

- {%- trans -%}However, if your subscription is renewed by this date, - your right to keep the money in your AE account will be renewed.{%- endtrans -%} -

+{% trans trimmed -%} + However, if your subscription is renewed by this date, + your right to keep the money in your AE account will be renewed. +{%- endtrans %} -{% if balance >= 10 %} -

- {%- trans -%}You can also request a refund by sending an email to - ae@utbm.fr - before the aforementioned date.{%- endtrans -%} -

-{% endif %} +{% if balance >= 10 -%} + {% trans trimmed -%} + You can also request a refund by sending an email to ae@utbm.fr + before the aforementioned date. + {%- endtrans %} +{%- endif %} -

- {% trans %}Sincerely{% endtrans %}, -

+{% trans %}Sincerely{% endtrans %}, -

- L'association des étudiants de l'UTBM
- 6, Boulevard Anatole France
- 90000 Belfort -

+L'association des étudiants de l'UTBM +6, Boulevard Anatole France +90000 Belfort diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index e548dfba..54408c09 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-16 01:51+0200\n" +"POT-Creation-Date: 2024-10-20 11:06+0200\n" "PO-Revision-Date: 2016-07-18\n" "Last-Translator: Maréchal \n" @@ -3883,48 +3883,49 @@ msgstr "uid" msgid "student cards" msgstr "cartes étudiante" -#: counter/templates/counter/account_dump_warning_mail.jinja:6 +#: counter/templates/counter/account_dump_warning_mail.jinja:1 +msgid "Hello" +msgstr "Bonjour" + +#: counter/templates/counter/account_dump_warning_mail.jinja:3 #, python-format msgid "" -"You received this email because your last subscription to the\n" -" Students' association ended on %(date)s." +"You received this email because your last subscription to the Students' " +"association ended on %(date)s." msgstr "" "Vous recevez ce mail car votre dernière cotisation à l'assocation des " "étudiants de l'UTBM s'est achevée le %(date)s." -#: counter/templates/counter/account_dump_warning_mail.jinja:11 +#: counter/templates/counter/account_dump_warning_mail.jinja:6 #, python-format msgid "" -"In accordance with the Internal Regulations, the balance of any\n" -" inactive AE account for more than 2 years automatically goes back\n" -" to the AE.\n" -" The money present on your account will therefore be recovered in full\n" -" on %(date)s, for a total of %(amount)s €." +"In accordance with the Internal Regulations, the balance of any inactive AE " +"account for more than 2 years automatically goes back to the AE. The money " +"present on your account will therefore be recovered in full on %(date)s, for " +"a total of %(amount)s €." msgstr "" "Conformément au Règlement intérieur, le solde de tout compte AE inactif " "depuis plus de 2 ans revient de droit à l'AE. L'argent présent sur votre " "compte sera donc récupéré en totalité le %(date)s, pour un total de " "%(amount)s €. " -#: counter/templates/counter/account_dump_warning_mail.jinja:19 +#: counter/templates/counter/account_dump_warning_mail.jinja:12 msgid "" -"However, if your subscription is renewed by this date,\n" -" your right to keep the money in your AE account will be renewed." +"However, if your subscription is renewed by this date, your right to keep " +"the money in your AE account will be renewed." msgstr "" "Cependant, si votre cotisation est renouvelée d'ici cette date, votre droit " "à conserver l'argent de votre compte AE sera renouvelé." -#: counter/templates/counter/account_dump_warning_mail.jinja:25 +#: counter/templates/counter/account_dump_warning_mail.jinja:16 msgid "" -"You can also request a refund by sending an email to\n" -" ae@utbm.fr\n" -" before the aforementioned date." +"You can also request a refund by sending an email to ae@utbm.fr before the " +"aforementioned date." msgstr "" "Vous pouvez également effectuer une demande de remboursement par mail à " -"l'adresse ae@utbm.fr avant la date " -"susmentionnée." +"l'adresse ae@utbm.fr avant la date susmentionnée." -#: counter/templates/counter/account_dump_warning_mail.jinja:32 +#: counter/templates/counter/account_dump_warning_mail.jinja:20 msgid "Sincerely" msgstr "Cordialement" @@ -3997,7 +3998,7 @@ msgstr "Ce n'est pas un UID de carte étudiante valide" #: counter/templates/counter/invoices_call.jinja:16 #: launderette/templates/launderette/launderette_admin.jinja:35 #: launderette/templates/launderette/launderette_click.jinja:13 -#: sas/templates/sas/picture.jinja:167 +#: sas/templates/sas/picture.jinja:166 #: subscription/templates/subscription/stats.jinja:20 msgid "Go" msgstr "Valider" @@ -5384,7 +5385,7 @@ msgstr "Image précédente" msgid "People" msgstr "Personne(s)" -#: sas/templates/sas/picture.jinja:165 +#: sas/templates/sas/picture.jinja:164 msgid "Identify users on pictures" msgstr "Identifiez les utilisateurs sur les photos" From 9675b6372c6347a901f229e13edef5d6d2160b29 Mon Sep 17 00:00:00 2001 From: imperosol Date: Sun, 20 Oct 2024 12:19:00 +0200 Subject: [PATCH 2/3] add flags to the dump warning mail command --- .../management/commands/dump_warning_mail.py | 32 ++++++++++++++++++- locale/fr/LC_MESSAGES/django.po | 4 +-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/counter/management/commands/dump_warning_mail.py b/counter/management/commands/dump_warning_mail.py index 2b8fbfdd..9b966494 100644 --- a/counter/management/commands/dump_warning_mail.py +++ b/counter/management/commands/dump_warning_mail.py @@ -1,4 +1,5 @@ import logging +import time from smtplib import SMTPException from django.conf import settings @@ -25,9 +26,34 @@ class Command(BaseCommand): self.logger.setLevel(logging.INFO) super().__init__(*args, **kwargs) + def add_arguments(self, parser): + parser.add_argument( + "--dry-run", + action="store_true", + help="Do not send the mails, just display the number of users concerned", + ) + parser.add_argument( + "-d", + "--delay", + type=float, + default=0, + help="Delay in seconds between each mail sent", + ) + def handle(self, *args, **options): - users = list(self._get_users()) + users: list[User] = list(self._get_users()) self.stdout.write(f"{len(users)} users will be warned of their account dump") + if options["verbosity"] > 1: + self.stdout.write("Users concerned:\n") + self.stdout.write( + "\n".join( + f" - {user.get_display_name()} ({user.email}) : " + f"{user.customer.amount} €" + for user in users + ) + ) + if options["dry_run"]: + return dumps = [] for user in users: is_success = self._send_mail(user) @@ -38,6 +64,10 @@ class Command(BaseCommand): warning_mail_error=not is_success, ) ) + if options["delay"]: + # avoid spamming the mail server too much + time.sleep(options["delay"]) + AccountDump.objects.bulk_create(dumps) self.stdout.write("Finished !") diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 54408c09..cc150a82 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-20 11:06+0200\n" +"POT-Creation-Date: 2024-10-20 12:20+0200\n" "PO-Revision-Date: 2016-07-18\n" "Last-Translator: Maréchal \n" @@ -3629,7 +3629,7 @@ msgstr "Produit parent" msgid "Buying groups" msgstr "Groupes d'achat" -#: counter/management/commands/dump_warning_mail.py:82 +#: counter/management/commands/dump_warning_mail.py:112 msgid "Clearing of your AE account" msgstr "Vidange de votre compte AE" From 662b4b5c53c67bf4611a950bb39e5bfcd38584ac Mon Sep 17 00:00:00 2001 From: imperosol Date: Sun, 20 Oct 2024 12:45:37 +0200 Subject: [PATCH 3/3] precise that dumped users can still subscribe --- .../counter/account_dump_warning_mail.jinja | 8 ++++++++ locale/fr/LC_MESSAGES/django.po | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/counter/templates/counter/account_dump_warning_mail.jinja b/counter/templates/counter/account_dump_warning_mail.jinja index 34419f75..b1374fc0 100644 --- a/counter/templates/counter/account_dump_warning_mail.jinja +++ b/counter/templates/counter/account_dump_warning_mail.jinja @@ -25,6 +25,14 @@ {%- endtrans %} {%- endif %} +{% trans trimmed -%} + Whatever you decide, you won't be expelled from the association, + and you won't lose your rights. + You will always be able to renew your subscription later. + If you don't renew your subscription, there will be no consequences + other than the loss of the money currently in your AE account. +{%- endtrans %} + {% trans %}Sincerely{% endtrans %}, L'association des étudiants de l'UTBM diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index cc150a82..71d08fe5 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-20 12:20+0200\n" +"POT-Creation-Date: 2024-10-20 12:42+0200\n" "PO-Revision-Date: 2016-07-18\n" "Last-Translator: Maréchal \n" @@ -3629,7 +3629,7 @@ msgstr "Produit parent" msgid "Buying groups" msgstr "Groupes d'achat" -#: counter/management/commands/dump_warning_mail.py:112 +#: counter/management/commands/dump_warning_mail.py:113 msgid "Clearing of your AE account" msgstr "Vidange de votre compte AE" @@ -3926,6 +3926,18 @@ msgstr "" "l'adresse ae@utbm.fr avant la date susmentionnée." #: counter/templates/counter/account_dump_warning_mail.jinja:20 +msgid "" +"Whatever you decide, you won't be expelled from the association, and you " +"won't lose your rights. You will always be able to renew your subscription " +"later. If you don't renew your subscription, there will be no consequences " +"other than the loss of the money currently in your AE account." +msgstr "" +"Quel que soit votre décision, vous ne serez pas exclu.e de l'association " +"et vous ne perdrez pas vos droits. Vous serez toujours en mesure de renouveler " +"votre cotisation. Si vous ne renouvelez pas votre cotisation, il n'y aura " +"aucune conséquence autre que le retrait de l'argent de votre compte." + +#: counter/templates/counter/account_dump_warning_mail.jinja:26 msgid "Sincerely" msgstr "Cordialement"