mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
tolerance to smtp error when creating project
This commit is contained in:
parent
04f8470223
commit
c51c02481b
1 changed files with 10 additions and 2 deletions
|
@ -3,6 +3,7 @@ from collections import defaultdict
|
|||
from flask import *
|
||||
from flaskext.mail import Mail, Message
|
||||
from flaskext.babel import get_locale, gettext as _
|
||||
from smtplib import SMTPRecipientsRefused
|
||||
import werkzeug
|
||||
|
||||
# local modules
|
||||
|
@ -142,10 +143,17 @@ def create_project():
|
|||
msg = Message(message_title,
|
||||
body=message_body,
|
||||
recipients=[project.contact_email])
|
||||
mail.send(msg)
|
||||
try:
|
||||
mail.send(msg)
|
||||
except SMTPRecipientsRefused:
|
||||
msg_compl = 'Problem sending mail. '
|
||||
# TODO: destroy the project and cancel instead?
|
||||
else:
|
||||
msg_compl = ''
|
||||
|
||||
# redirect the user to the next step (invite)
|
||||
flash(_("The project identifier is %(project)s", project=project.id))
|
||||
flash(_("%(msg_compl)sThe project identifier is %(project)s",
|
||||
msg_compl=msg_compl, project=project.id))
|
||||
return redirect(url_for(".invite", project_id=project.id))
|
||||
|
||||
return render_template("create_project.html", form=form)
|
||||
|
|
Loading…
Reference in a new issue