save mail on database error

This commit is contained in:
Adrian Amaglio 2020-05-17 12:56:36 +02:00
parent 7de511ddd8
commit 4009a34728

View File

@ -111,11 +111,11 @@ def submission ():
except IndexError as e: except IndexError as e:
save_mail (token, form['mail'], from_address, subject, content) save_mail (token, form['mail'], from_address, subject, content)
response.status = 400 response.status = 400
return 'Le formulaire est introuvable' return 'Le formulaire est introuvable. Le mail a été sauvegardé et sera traité à la main.'
except pymongo.errors.ServerSelectionTimeoutError as e: except pymongo.errors.ServerSelectionTimeoutError as e:
save_mail (token, form['mail'], from_address, subject, content) save_mail (token, form['mail'], from_address, subject, content)
response.status = 500 response.status = 500
return 'La base de donnée nest pas accessible' return 'La base de donnée nest pas accessible. Votre message a été enregistré, il sera remis manuellement à son destinataire.'
try: try:
subject_fields = fill_fields(request, get_fields(form['subject'])) subject_fields = fill_fields(request, get_fields(form['subject']))