diff --git a/ihatemoney/messages.pot b/ihatemoney/messages.pot
index dcf16b30..9569d055 100644
--- a/ihatemoney/messages.pot
+++ b/ihatemoney/messages.pot
@@ -157,13 +157,24 @@ msgstr ""
msgid "You have just created '%(project)s' to share your expenses"
msgstr ""
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr ""
@@ -192,6 +203,12 @@ msgstr ""
msgid "Your invitations have been sent"
msgstr ""
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
diff --git a/ihatemoney/run.py b/ihatemoney/run.py
index e084e5bc..15e295b8 100644
--- a/ihatemoney/run.py
+++ b/ihatemoney/run.py
@@ -6,6 +6,7 @@ from flask import Flask, g, render_template, request, session
from flask_babel import Babel, format_currency
from flask_mail import Mail
from flask_migrate import Migrate, stamp, upgrade
+from jinja2 import contextfilter
from werkzeug.middleware.proxy_fix import ProxyFix
from ihatemoney import default_settings
@@ -155,7 +156,10 @@ def create_app(
# Undocumented currencyformat filter from flask_babel is forwarding to Babel format_currency
# We overwrite it to remove the currency sign ¤ when there is no currency
- def currencyformat_nc(number, currency, *args, **kwargs):
+ @contextfilter
+ def currency(context, number, currency=None, *args, **kwargs):
+ if currency is None:
+ currency = context.get("g").project.default_currency
"""
Same as flask_babel.Babel.currencyformat, but without the "no currency ¤" sign
when there is no currency.
@@ -167,7 +171,7 @@ def create_app(
**kwargs
).strip()
- app.jinja_env.filters["currencyformat_nc"] = currencyformat_nc
+ app.jinja_env.filters["currency"] = currency
@babel.localeselector
def get_locale():
diff --git a/ihatemoney/templates/home.html b/ihatemoney/templates/home.html
index 4af6a80a..c13c4244 100644
--- a/ihatemoney/templates/home.html
+++ b/ihatemoney/templates/home.html
@@ -91,7 +91,7 @@
{% endblock %}
{% block js %}
$('#creation-form #password').tooltip({
- title: '{{ _("This access code will be sent to your friends. It is stored as-is by the server, so don\\'t reuse a personal password!")}}',
+ title: '{{ _("Don't reuse a personal password. Make an access code and send it to your friends")}}',
trigger: 'focus',
placement: 'right'
});
diff --git a/ihatemoney/templates/list_bills.html b/ihatemoney/templates/list_bills.html
index 1f4235bb..487e70eb 100644
--- a/ihatemoney/templates/list_bills.html
+++ b/ihatemoney/templates/list_bills.html
@@ -1,7 +1,7 @@
{% extends "sidebar_table_layout.html" %}
{%- macro bill_amount(bill, currency=bill.original_currency, amount=bill.amount) %}
- {{ amount|currencyformat_nc(currency) }} ({{ _("%(amount)s each", amount=bill.pay_each_default(amount)|currencyformat_nc(currency)) }})
+ {{ amount|currency(currency) }} ({{ _("%(amount)s each", amount=bill.pay_each_default(amount)|currency(currency)) }})
{% endmacro -%}
{% block title %} - {{ g.project.name }}{% endblock %}
diff --git a/ihatemoney/templates/settle_bills.html b/ihatemoney/templates/settle_bills.html
index a9b0dbc2..601156c6 100644
--- a/ihatemoney/templates/settle_bills.html
+++ b/ihatemoney/templates/settle_bills.html
@@ -15,7 +15,7 @@
{{ bill.ower }} |
{{ bill.receiver }} |
- {{ bill.amount|currencyformat_nc(g.project.default_currency) }} |
+ {{ bill.amount|currency }} |
{% endfor %}
diff --git a/ihatemoney/templates/sidebar_table_layout.html b/ihatemoney/templates/sidebar_table_layout.html
index d616e684..b25a3d68 100644
--- a/ihatemoney/templates/sidebar_table_layout.html
+++ b/ihatemoney/templates/sidebar_table_layout.html
@@ -37,7 +37,7 @@
{%- endif %}
{%- endif %}
- {% if balance[member.id] | round(2) > 0 %}+{% endif %}{{ balance[member.id]|currencyformat_nc(g.project.default_currency) }}
+ {% if balance[member.id] | round(2) > 0 %}+{% endif %}{{ balance[member.id]|currency }}
|
{%- endfor %}
diff --git a/ihatemoney/templates/statistics.html b/ihatemoney/templates/statistics.html
index 3b0a9dd5..9e7a10de 100644
--- a/ihatemoney/templates/statistics.html
+++ b/ihatemoney/templates/statistics.html
@@ -15,8 +15,8 @@
{% for stat in members_stats|sort(attribute='member.name') %}
{{ stat.member.name }} |
- {{ stat.paid|currencyformat_nc(g.project.default_currency) }} |
- {{ stat.spent|currencyformat_nc(g.project.default_currency) }} |
+ {{ stat.paid|currency }} |
+ {{ stat.spent|currency }} |
{% endfor %}
@@ -28,7 +28,7 @@
{% for month in months %}
{{ _(month.strftime("%B")) }} {{ month.year }} |
- {{ monthly_stats[month.year][month.month]|currencyformat_nc(g.project.default_currency) }} |
+ {{ monthly_stats[month.year][month.month]|currency }} |
{% endfor %}
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py
index 4cdf3164..dc6c4558 100644
--- a/ihatemoney/tests/tests.py
+++ b/ihatemoney/tests/tests.py
@@ -5,6 +5,8 @@ import io
import json
import os
import re
+import smtplib
+import socket
from time import sleep
import unittest
from unittest.mock import MagicMock, patch
@@ -51,10 +53,10 @@ class BaseTestCase(TestCase):
follow_redirects=True,
)
- def post_project(self, name):
+ def post_project(self, name, follow_redirects=True):
"""Create a fake project"""
# create the project
- self.client.post(
+ return self.client.post(
"/create",
data={
"name": name,
@@ -63,6 +65,7 @@ class BaseTestCase(TestCase):
"contact_email": f"{name}@notmyidea.org",
"default_currency": "USD",
},
+ follow_redirects=follow_redirects,
)
def create_project(self, name):
@@ -141,10 +144,15 @@ class BudgetTestCase(IhatemoneyTestCase):
self.login("raclette")
self.post_project("raclette")
- self.client.post(
- "/raclette/invite", data={"emails": "zorglub@notmyidea.org"}
+ resp = self.client.post(
+ "/raclette/invite",
+ data={"emails": "zorglub@notmyidea.org"},
+ follow_redirects=True,
)
+ # success notification
+ self.assertIn("Your invitations have been sent", resp.data.decode("utf-8"))
+
self.assertEqual(len(outbox), 2)
self.assertEqual(outbox[0].recipients, ["raclette@notmyidea.org"])
self.assertEqual(outbox[1].recipients, ["zorglub@notmyidea.org"])
@@ -225,7 +233,15 @@ class BudgetTestCase(IhatemoneyTestCase):
self.create_project("raclette")
# Get password resetting link from mail
with self.app.mail.record_messages() as outbox:
- self.client.post("/password-reminder", data={"id": "raclette"})
+ resp = self.client.post(
+ "/password-reminder", data={"id": "raclette"}, follow_redirects=True
+ )
+ # Check that we are redirected to the right page
+ self.assertIn(
+ "A link to reset your password has been sent to you",
+ resp.data.decode("utf-8"),
+ )
+ # Check that an email was sent
self.assertEqual(len(outbox), 1)
url_start = outbox[0].body.find("You can reset it here: ") + 23
url_end = outbox[0].body.find(".\n", url_start)
@@ -250,17 +266,26 @@ class BudgetTestCase(IhatemoneyTestCase):
def test_project_creation(self):
with self.app.test_client() as c:
- # add a valid project
- c.post(
- "/create",
- data={
- "name": "The fabulous raclette party",
- "id": "raclette",
- "password": "party",
- "contact_email": "raclette@notmyidea.org",
- "default_currency": "USD",
- },
- )
+ with self.app.mail.record_messages() as outbox:
+ # add a valid project
+ resp = c.post(
+ "/create",
+ data={
+ "name": "The fabulous raclette party",
+ "id": "raclette",
+ "password": "party",
+ "contact_email": "raclette@notmyidea.org",
+ "default_currency": "USD",
+ },
+ follow_redirects=True,
+ )
+ # an email is sent to the owner with a reminder of the password
+ self.assertEqual(len(outbox), 1)
+ self.assertEqual(outbox[0].recipients, ["raclette@notmyidea.org"])
+ self.assertIn(
+ "A reminder email has just been sent to you",
+ resp.data.decode("utf-8"),
+ )
# session is updated
self.assertTrue(session["raclette"])
@@ -2265,6 +2290,78 @@ class ModelsTestCase(IhatemoneyTestCase):
self.assertEqual(bill.pay_each(), pay_each_expected)
+class EmailFailureTestCase(IhatemoneyTestCase):
+ def test_creation_email_failure_smtp(self):
+ self.login("raclette")
+ with patch.object(
+ self.app.mail, "send", MagicMock(side_effect=smtplib.SMTPException)
+ ):
+ resp = self.post_project("raclette")
+ # Check that an error message is displayed
+ self.assertIn(
+ "We tried to send you an reminder email, but there was an error",
+ resp.data.decode("utf-8"),
+ )
+ # Check that we were redirected to the home page anyway
+ self.assertIn(
+ 'You probably want to %s<\/em>' % string
diff --git a/ihatemoney/translations/cs/LC_MESSAGES/messages.po b/ihatemoney/translations/cs/LC_MESSAGES/messages.po
index bb137ee3..96703ac6 100644
--- a/ihatemoney/translations/cs/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/cs/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language: cs\n"
@@ -12,7 +12,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -173,13 +173,24 @@ msgstr ""
msgid "You have just created '%(project)s' to share your expenses"
msgstr ""
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr ""
@@ -208,6 +219,12 @@ msgstr ""
msgid "Your invitations have been sent"
msgstr ""
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
@@ -757,3 +774,6 @@ msgstr ""
#~ msgid "each"
#~ msgstr ""
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/de/LC_MESSAGES/messages.po b/ihatemoney/translations/de/LC_MESSAGES/messages.po
index 502793b0..74eed894 100644
--- a/ihatemoney/translations/de/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/de/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2020-02-12 10:50+0000\n"
"Last-Translator: flolilo \n"
"Language: de\n"
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -182,13 +182,24 @@ msgstr ""
"Du hast gerade das Projekt '%(project)s' erstellt, um deine Ausgaben zu "
"teilen"
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Kein Token zur Verfügung gestellt"
@@ -217,6 +228,12 @@ msgstr "Du wurdest eingeladen, deine Ausgaben für %(project)s zu teilen"
msgid "Your invitations have been sent"
msgstr "Deine Einladungen wurden versendet"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
@@ -785,3 +802,6 @@ msgstr ""
#~ msgid "each"
#~ msgstr "alles"
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/el/LC_MESSAGES/messages.po b/ihatemoney/translations/el/LC_MESSAGES/messages.po
index 23fc2ee5..df8c2ae3 100644
--- a/ihatemoney/translations/el/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/el/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language: el\n"
@@ -12,7 +12,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -173,13 +173,24 @@ msgstr ""
msgid "You have just created '%(project)s' to share your expenses"
msgstr ""
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr ""
@@ -208,6 +219,12 @@ msgstr ""
msgid "Your invitations have been sent"
msgstr ""
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
@@ -757,3 +774,6 @@ msgstr ""
#~ msgid "each"
#~ msgstr ""
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/es_419/LC_MESSAGES/messages.po b/ihatemoney/translations/es_419/LC_MESSAGES/messages.po
index b8d6c30c..b446ff8b 100644
--- a/ihatemoney/translations/es_419/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/es_419/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2020-05-03 15:20+0000\n"
"Last-Translator: Fabian Rodriguez \n"
"Language: es_419\n"
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -182,13 +182,24 @@ msgstr "Este código privado no es el correcto"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Acabas de crear '%(project)s' para compartir tus gastos"
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "No se proporciono ningún token"
@@ -217,6 +228,12 @@ msgstr "Usted ha sido invitado a compartir sus gastos para %(project)s"
msgid "Your invitations have been sent"
msgstr "Sus invitaciones han sido enviadas"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr "Se añadieron %(member)s"
@@ -806,3 +823,6 @@ msgstr "Período"
#~ msgid "each"
#~ msgstr "Cada"
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/fr/LC_MESSAGES/messages.po b/ihatemoney/translations/fr/LC_MESSAGES/messages.po
index 79faf70c..7ac363da 100644
--- a/ihatemoney/translations/fr/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/fr/LC_MESSAGES/messages.po
@@ -7,18 +7,17 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2020-05-15 20:41+0000\n"
"Last-Translator: Glandos \n"
-"Language-Team: French \n"
"Language: fr\n"
+"Language-Team: French \n"
+"Plural-Forms: nplurals=2; plural=n > 1\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=n > 1;\n"
-"X-Generator: Weblate 4.1-dev\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -185,13 +184,24 @@ msgstr "Le code que vous avez entré n’est pas correct"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Vous venez de créer « %(project)s » pour partager vos dépenses"
-msgid "Error while sending reminder email"
-msgstr "Erreur lors de l’envoi du courriel de rappel"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
+msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr "L’identifiant de ce projet est %(project)s"
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Aucun token n’a été fourni"
@@ -220,6 +230,12 @@ msgstr "Vous avez été invité à partager vos dépenses pour %(project)s"
msgid "Your invitations have been sent"
msgstr "Vos invitations ont bien été envoyées"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr "%(member)s a été ajouté"
@@ -1019,3 +1035,7 @@ msgstr "Période"
#~ msgid "each"
#~ msgstr "chacun"
+
+#~ msgid "Error while sending reminder email"
+#~ msgstr "Erreur lors de l’envoi du courriel de rappel"
+
diff --git a/ihatemoney/translations/id/LC_MESSAGES/messages.po b/ihatemoney/translations/id/LC_MESSAGES/messages.po
index 543d9821..cff90b3d 100644
--- a/ihatemoney/translations/id/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/id/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2019-11-16 10:04+0000\n"
"Last-Translator: Muhammad Fauzi \n"
"Language: id\n"
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -178,13 +178,24 @@ msgstr "Kode pribadi ini tidak benar"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Anda baru saja membuat %(project)s untuk membagikan harga Anda"
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Belum ada token diberikan"
@@ -213,6 +224,12 @@ msgstr "Anda telah diundang untuk membagikan harga Anda untuk %(project)s"
msgid "Your invitations have been sent"
msgstr "Undangan Anda telah dikirim"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
@@ -785,3 +802,6 @@ msgstr ""
#~ msgid "each"
#~ msgstr "setiap"
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/it/LC_MESSAGES/messages.po b/ihatemoney/translations/it/LC_MESSAGES/messages.po
index f4f76fc5..d537b6d3 100644
--- a/ihatemoney/translations/it/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/it/LC_MESSAGES/messages.po
@@ -1,3 +1,4 @@
+
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
@@ -8,12 +9,13 @@ msgstr ""
"Language-Team: Italian \n"
"Language: it\n"
+"Language-Team: Italian \n"
+"Plural-Forms: nplurals=2; plural=n != 1\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.1-dev\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -167,12 +169,13 @@ msgstr "Troppi tentativi di accesso non riusciti. Riprova più tardi."
#, python-format
msgid "This admin password is not the right one. Only %(num)d attempts left."
msgstr ""
-"Questa password di amministrazione non è corretta. Solo %(num)d tentativi "
-"rimasti."
+"Questa password di amministrazione non è corretta. Solo %(num)d tentativi"
+" rimasti."
msgid "You either provided a bad token or no project identifier."
msgstr ""
-"Hai fornito un token invalido o l'identificatore del progetto non è valido."
+"Hai fornito un token invalido o l'identificatore del progetto non è "
+"valido."
msgid "This private code is not the right one"
msgstr "Questo codice privato non è quello corretto"
@@ -181,13 +184,24 @@ msgstr "Questo codice privato non è quello corretto"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Hai appena creato '%(project)s' per condividere le tue spese"
-msgid "Error while sending reminder email"
-msgstr "Errore durante l'invio dell'email di promemoria"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
+msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr "L'identificatore del progetto è %(project)s"
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Nessun token fornito"
@@ -216,6 +230,12 @@ msgstr "Sei stato invitato a condividere le tue spese per %(project)s"
msgid "Your invitations have been sent"
msgstr "I tuoi inviti sono stati spediti"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr "%(member)s è stato aggiunto"
@@ -804,3 +824,7 @@ msgstr "Periodo"
#~ msgid "each"
#~ msgstr ""
+
+#~ msgid "Error while sending reminder email"
+#~ msgstr "Errore durante l'invio dell'email di promemoria"
+
diff --git a/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.po b/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.po
index 899bc0e4..d8223b30 100644
--- a/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2019-11-12 09:04+0000\n"
"Last-Translator: Allan Nordhøy \n"
"Language: nb_NO\n"
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -182,13 +182,24 @@ msgstr "Denne private koden er ikke rett"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Du har akkurat opprettet \"%(project)s\" for å dele dine utgifter"
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Inget symbol angitt"
@@ -221,6 +232,12 @@ msgstr ""
msgid "Your invitations have been sent"
msgstr "Invitasjonene dine har blitt sendt"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
@@ -916,3 +933,6 @@ msgstr ""
#~ msgid "each"
#~ msgstr "hver"
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/nl/LC_MESSAGES/messages.po b/ihatemoney/translations/nl/LC_MESSAGES/messages.po
index d80861b7..c0917c95 100644
--- a/ihatemoney/translations/nl/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/nl/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2019-10-07 22:56+0000\n"
"Last-Translator: Heimen Stoffels \n"
"Language: nl\n"
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -176,13 +176,24 @@ msgstr ""
"Je hebt zojuist het project '%(project)s' aangemaakt om je uitgaven te "
"verdelen"
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Geen toegangssleutel opgegeven"
@@ -211,6 +222,12 @@ msgstr "Je bent uitgenodigd om je uitgaven te delen met %(project)s"
msgid "Your invitations have been sent"
msgstr "Je uitnodigingen zijn verstuurd"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
@@ -774,3 +791,6 @@ msgstr ""
#~ msgid "each"
#~ msgstr "per persoon"
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/pl/LC_MESSAGES/messages.po b/ihatemoney/translations/pl/LC_MESSAGES/messages.po
index f2709cff..aa2d19b2 100644
--- a/ihatemoney/translations/pl/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/pl/LC_MESSAGES/messages.po
@@ -1,20 +1,20 @@
+
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2020-05-13 15:41+0000\n"
"Last-Translator: Szylu \n"
-"Language-Team: Polish \n"
"Language: pl\n"
+"Language-Team: Polish \n"
+"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && "
+"(n%100<10 || n%100>=20) ? 1 : 2\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
-"|| n%100>=20) ? 1 : 2;\n"
-"X-Generator: Weblate 4.1-dev\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -179,13 +179,24 @@ msgstr "Ten prywatny kod jest niewłaściwy"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Właśnie utworzyłeś „%(project)s”, aby podzielić się wydatkami"
-msgid "Error while sending reminder email"
-msgstr "Błąd podczas wysyłania wiadomości e-mail z przypomnieniem"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
+msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr "Identyfikator projektu to %(project)s"
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Nie podano tokena"
@@ -214,6 +225,12 @@ msgstr "Zostałeś zaproszony do podzielenia się swoimi wydatkami w %(project)s
msgid "Your invitations have been sent"
msgstr "Twoje zaproszenia zostały wysłane"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr "%(member)s został dodany"
@@ -799,3 +816,7 @@ msgstr "Okres"
#~ msgid "each"
#~ msgstr "każdy"
+
+#~ msgid "Error while sending reminder email"
+#~ msgstr "Błąd podczas wysyłania wiadomości e-mail z przypomnieniem"
+
diff --git a/ihatemoney/translations/ru/LC_MESSAGES/messages.po b/ihatemoney/translations/ru/LC_MESSAGES/messages.po
index a1cd5907..7daaa261 100644
--- a/ihatemoney/translations/ru/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/ru/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2020-04-28 07:11+0000\n"
"Last-Translator: Vsevolod \n"
"Language: ru\n"
@@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -181,13 +181,24 @@ msgstr "Этот приватный код не подходит"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Вы только что создали '%(project)s' , чтобы разделить расходы"
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Не предоставлен токен"
@@ -216,6 +227,12 @@ msgstr "Вас пригласили разделить расходы в про
msgid "Your invitations have been sent"
msgstr "Ваш код приглашения был отправлен"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr "%(member)s был добавлен"
@@ -795,3 +812,6 @@ msgstr "Период"
#~ msgid "each"
#~ msgstr "каждый"
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/tr/LC_MESSAGES/messages.po b/ihatemoney/translations/tr/LC_MESSAGES/messages.po
index 6343b8a1..04fbbf75 100644
--- a/ihatemoney/translations/tr/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/tr/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2019-08-07 13:24+0000\n"
"Last-Translator: Mesut Akcan \n"
"Language: tr\n"
@@ -13,7 +13,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -178,13 +178,24 @@ msgstr ""
msgid "You have just created '%(project)s' to share your expenses"
msgstr ""
-msgid "Error while sending reminder email"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr ""
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr ""
@@ -213,6 +224,12 @@ msgstr ""
msgid "Your invitations have been sent"
msgstr ""
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr ""
@@ -762,3 +779,6 @@ msgstr ""
#~ msgid "each"
#~ msgstr ""
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/uk/LC_MESSAGES/messages.po b/ihatemoney/translations/uk/LC_MESSAGES/messages.po
index 78147282..98e4f5d7 100644
--- a/ihatemoney/translations/uk/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/uk/LC_MESSAGES/messages.po
@@ -177,13 +177,24 @@ msgstr "Цей приватний код не підходить"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "Ви щойно створили '%(project)s', щоб поділитися витратами"
-msgid "Error while sending reminder email"
-msgstr "Помилка під час надсилання нагадування електронною поштою"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
+msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr "Ідентифікатор проєкту %(project)s"
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "Не надано токен"
@@ -212,6 +223,12 @@ msgstr "Вас запросили поділитися своїми витрат
msgid "Your invitations have been sent"
msgstr "Ваші запрошення відправленні"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr "%(member)s додано"
@@ -760,3 +777,7 @@ msgstr ""
#~ msgid "each"
#~ msgstr ""
+
+#~ msgid "Error while sending reminder email"
+#~ msgstr ""
+
diff --git a/ihatemoney/translations/zh_HANS-CN/LC_MESSAGES/messages.po b/ihatemoney/translations/zh_HANS-CN/LC_MESSAGES/messages.po
index 9409c512..d78604c0 100644
--- a/ihatemoney/translations/zh_HANS-CN/LC_MESSAGES/messages.po
+++ b/ihatemoney/translations/zh_HANS-CN/LC_MESSAGES/messages.po
@@ -1,19 +1,20 @@
+
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-09 21:41+0200\n"
+"POT-Creation-Date: 2020-05-18 15:11+0200\n"
"PO-Revision-Date: 2020-05-13 15:41+0000\n"
"Last-Translator: Muge Niu \n"
-"Language-Team: Chinese (Simplified) \n"
-"Language: zh_HANS-CN\n"
+"Language: zh_HANS_CN\n"
+"Language-Team: Chinese (Simplified) "
+""
+"\n"
+"Plural-Forms: nplurals=1; plural=0\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.1-dev\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
msgid ""
"Not a valid amount or expression. Only numbers and + - * / operators are "
@@ -174,13 +175,24 @@ msgstr "专用码不正确"
msgid "You have just created '%(project)s' to share your expenses"
msgstr "你新建了一个‘%(project)s'来分担你的花费"
-msgid "Error while sending reminder email"
-msgstr "发送提醒邮件时出错"
+msgid "A reminder email has just been sent to you"
+msgstr ""
+
+msgid ""
+"We tried to send you an reminder email, but there was an error. You can "
+"still use the project normally."
+msgstr ""
#, python-format
msgid "The project identifier is %(project)s"
msgstr "项目的标识符是%(project)s"
+msgid ""
+"Sorry, there was an error while sending you an email with password reset "
+"instructions. Please check the email configuration of the server or "
+"contact the administrator."
+msgstr ""
+
msgid "No token provided"
msgstr "没有符号"
@@ -209,6 +221,12 @@ msgstr "你被邀请进入 %(project)s来分担你的花费"
msgid "Your invitations have been sent"
msgstr "你的申请已发出"
+msgid ""
+"Sorry, there was an error while trying to send the invitation emails. "
+"Please check the email configuration of the server or contact the "
+"administrator."
+msgstr ""
+
#, python-format
msgid "%(member)s has been added"
msgstr "已添加%(member)s"
@@ -771,3 +789,7 @@ msgstr "期间"
#~ msgid "each"
#~ msgstr "每一个·"
+
+#~ msgid "Error while sending reminder email"
+#~ msgstr "发送提醒邮件时出错"
+
diff --git a/ihatemoney/utils.py b/ihatemoney/utils.py
index 175b7621..adced8f7 100644
--- a/ihatemoney/utils.py
+++ b/ihatemoney/utils.py
@@ -7,6 +7,8 @@ from json import JSONEncoder, dumps
import operator
import os
import re
+import smtplib
+import socket
from babel import Locale
from babel.numbers import get_currency_name, get_currency_symbol
@@ -28,6 +30,22 @@ def slugify(value):
return re.sub(r"[-\s]+", "-", value)
+def send_email(mail_message):
+ """Send an email using Flask-Mail, with proper error handling.
+
+ Return True if everything went well, and False if there was an error.
+ """
+ # Since Python 3.4, SMTPException and socket.error are actually
+ # identical, but this was not the case before. Also, it is more clear
+ # to check for both.
+ try:
+ current_app.mail.send(mail_message)
+ except (smtplib.SMTPException, socket.error):
+ return False
+ # Email was sent successfully
+ return True
+
+
class Redirect303(HTTPException, RoutingException):
"""Raise if the map requests a redirect. This is for example the case if
diff --git a/ihatemoney/web.py b/ihatemoney/web.py
index ae124ac5..65757201 100644
--- a/ihatemoney/web.py
+++ b/ihatemoney/web.py
@@ -12,7 +12,6 @@ from datetime import datetime
from functools import wraps
import json
import os
-from smtplib import SMTPRecipientsRefused
from dateutil.parser import parse
from dateutil.relativedelta import relativedelta
@@ -60,6 +59,7 @@ from ihatemoney.utils import (
list_of_dicts2json,
render_localized_template,
same_bill,
+ send_email,
)
main = Blueprint("main", __name__)
@@ -308,11 +308,21 @@ def create_project():
msg = Message(
message_title, body=message_body, recipients=[project.contact_email]
)
- try:
- current_app.mail.send(msg)
- except SMTPRecipientsRefused:
- flash(_("Error while sending reminder email"), category="danger")
-
+ success = send_email(msg)
+ if success:
+ flash(
+ _("A reminder email has just been sent to you"), category="success"
+ )
+ else:
+ # Display the error as a simple "info" alert, because it's
+ # not critical and doesn't prevent using the project.
+ flash(
+ _(
+ "We tried to send you an reminder email, but there was an error. "
+ "You can still use the project normally."
+ ),
+ category="info",
+ )
# redirect the user to the next step (invite)
flash(_("The project identifier is %(project)s", project=project.id))
return redirect(url_for(".list_bills", project_id=project.id))
@@ -328,17 +338,25 @@ def remind_password():
# get the project
project = Project.query.get(form.id.data)
# send a link to reset the password
- current_app.mail.send(
- Message(
- "password recovery",
- body=render_localized_template(
- "password_reminder", project=project
- ),
- recipients=[project.contact_email],
- )
+ remind_message = Message(
+ "password recovery",
+ body=render_localized_template("password_reminder", project=project),
+ recipients=[project.contact_email],
)
- return redirect(url_for(".password_reminder_sent"))
-
+ success = send_email(remind_message)
+ if success:
+ return redirect(url_for(".password_reminder_sent"))
+ else:
+ flash(
+ _(
+ "Sorry, there was an error while sending you an email "
+ "with password reset instructions. "
+ "Please check the email configuration of the server "
+ "or contact the administrator."
+ ),
+ category="danger",
+ )
+ # Fall-through: we stay on the same page and display the form again
return render_template("password_reminder.html", form=form)
@@ -585,10 +603,20 @@ def invite():
body=message_body,
recipients=[email.strip() for email in form.emails.data.split(",")],
)
- current_app.mail.send(msg)
- flash(_("Your invitations have been sent"))
- return redirect(url_for(".list_bills"))
-
+ success = send_email(msg)
+ if success:
+ flash(_("Your invitations have been sent"), category="success")
+ return redirect(url_for(".list_bills"))
+ else:
+ flash(
+ _(
+ "Sorry, there was an error while trying to send the invitation emails. "
+ "Please check the email configuration of the server "
+ "or contact the administrator."
+ ),
+ category="danger",
+ )
+ # Fall-through: we stay on the same page and display the form again
return render_template("send_invites.html", form=form)