From f707f6bdd6171e09a0241b379a233074a12a17bd Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Tue, 6 Nov 2018 11:19:02 -0200 Subject: [PATCH] =?UTF-8?q?faz=20teste=20de=20conex=C3=A3o=20de=20email=20?= =?UTF-8?q?apenas=20no=20in=C3=ADcio=20do=20sapl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/context_processors.py | 2 +- sapl/utils.py | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sapl/context_processors.py b/sapl/context_processors.py index c0aa7a1bf..ad1a33d9b 100644 --- a/sapl/context_processors.py +++ b/sapl/context_processors.py @@ -17,7 +17,7 @@ def parliament_info(request): def mail_service_configured(request): - if not mail_service_configured_utils(): + if not mail_service_configured_utils(request): logger = logging.getLogger(__name__) logger.warning(_('Servidor de email não configurado.')) return {'mail_service_configured': False} diff --git a/sapl/utils.py b/sapl/utils.py index 9bd3002f4..77e1cec2d 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -773,13 +773,16 @@ def remover_acentos(string): def mail_service_configured(request=None): - result = True - try: - connection = get_connection() - connection.open() - except Exception as e: - result = False - print(e) - finally: - connection.close() - return result \ No newline at end of file + + if settings.EMAIL_RUNNING is None: + result = True + try: + connection = get_connection() + connection.open() + except Exception as e: + result = False + finally: + connection.close() + settings.EMAIL_RUNNING = result + + return settings.EMAIL_RUNNING