From 439b619eb468778178c055ca76ced658e8428227 Mon Sep 17 00:00:00 2001 From: streltsov Date: Wed, 14 Sep 2016 12:26:16 +0300 Subject: [PATCH] getting provider fix --- dbmail/backends/mail.py | 4 +++- dbmail/backends/push.py | 1 - dbmail/backends/sms.py | 1 - dbmail/defaults.py | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dbmail/backends/mail.py b/dbmail/backends/mail.py index 069fb3c..7c6da64 100644 --- a/dbmail/backends/mail.py +++ b/dbmail/backends/mail.py @@ -26,6 +26,8 @@ class Sender(object): + provider = defaults.MAIL_PROVIDER + def __init__(self, slug, recipient, *args, **kwargs): self._slug = slug @@ -35,7 +37,7 @@ def __init__(self, slug, recipient, *args, **kwargs): self._user = kwargs.pop('user', None) self._language = kwargs.pop('language', None) self._backend = kwargs.pop('backend') - self._provider = kwargs.pop('provider', None) + self._provider = kwargs.pop('provider', self.provider) self._signals_kw = kwargs.pop('signals_kwargs', {}) self._template = self._get_template() diff --git a/dbmail/backends/push.py b/dbmail/backends/push.py index f99b652..037b1c5 100644 --- a/dbmail/backends/push.py +++ b/dbmail/backends/push.py @@ -28,7 +28,6 @@ def _send(self): if self._from_email: options['app'] = self._from_email - self._provider = self._provider or self.provider module = import_module(self._provider) for address in self._recipient_list: diff --git a/dbmail/backends/sms.py b/dbmail/backends/sms.py index 9b70ef2..83ceecf 100644 --- a/dbmail/backends/sms.py +++ b/dbmail/backends/sms.py @@ -28,7 +28,6 @@ def _get_recipient_list(self, recipient): return self._email_to_list(recipient) def _send(self): - self._provider = self._provider or self.provider module = import_module(self._provider) message = clean_html(self._message) for phone in self._recipient_list: diff --git a/dbmail/defaults.py b/dbmail/defaults.py index ef76558..b97afb9 100644 --- a/dbmail/defaults.py +++ b/dbmail/defaults.py @@ -106,6 +106,8 @@ def get_settings(key, default): 'DB_MAILER_TTS_PROVIDER', 'dbmail.providers.nexmo.tts') PUSH_PROVIDER = get_settings( 'DB_MAILER_PUSH_PROVIDER', 'dbmail.providers.prowl.push') +MAIL_PROVIDER = get_settings('DB_MAILER_MAIL_PROVIDER', None) + SAFARI_PUSH_PATH = get_settings( 'DB_MAILER_SAFARI_PUSH_PATH', settings.STATIC_ROOT or '.')