Changeset - 372fc482a2fc
[Not reviewed]
0 1 0
Lance Edgar (lance) - 2 months ago 2024-08-26 15:22:39
lance@edbob.org
fix: inherit from wuttjamaican for `EmailHandler`
1 file changed with 13 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rattail/mail.py
Show inline comments
 
@@ -39,6 +39,8 @@ from mako.template import Template
 
from mako.lookup import TemplateLookup
 
from mako.exceptions import TopLevelLookupException
 

	
 
from wuttjamaican.email import EmailHandler as WuttaEmailHandler
 

	
 
from rattail import exceptions
 
from rattail.core import UNSPECIFIED
 
from rattail.files import resource_path
 
@@ -77,15 +79,14 @@ def send_email(config, key, data={}, attachments=[],
 
        log.debug("skipping email of type '%s' per config", key)
 

	
 

	
 
class EmailHandler(object):
 
class EmailHandler(WuttaEmailHandler):
 
    """
 
    Base class and default implementation for email handlers.
 
    """
 

	
 
    def __init__(self, config):
 
        self.config = config
 
        self.app = config.get_app()
 
        self.enum = self.config.get_enum()
 
    def __init__(self, *args, **kwargs):
 
        super().__init__(*args, **kwargs)
 
        self.enum = self.app.enum
 

	
 
        # only assign model attribute if db libs are installed
 
        try:
 
@@ -317,6 +318,12 @@ class EmailHandler(object):
 
        context['localtime'] = localtime
 
        return context
 

	
 
    def sending_is_enabled(self):
 
        """ """
 
        # TODO: our default is true but wuttjamaican's is false
 
        return self.config.get_bool('rattail.mail.send_emails',
 
                                    default=True)
 

	
 
    def deliver_message(self, email, msg, recipients=UNSPECIFIED):
 
        """
 
        Deliver an email message using the given SMTP configuration.
 
@@ -357,7 +364,7 @@ class EmailHandler(object):
 
        if self.config.getbool('rattail.mail', 'send_feedback_only', usedb=False, default=False):
 
            send = email.key == 'user_feedback'
 
        else:
 
            send = self.config.getbool('rattail.mail', 'send_emails', usedb=False, default=True)
 
            send = self.sending_is_enabled()
 

	
 
        if send:
 

	
0 comments (0 inline, 0 general)