Changeset - e50961288e80
[Not reviewed]
0 1 0
Lance Edgar (lance) - 20 months ago 2023-02-17 13:21:42
lance@edbob.org
Avoid/delay import in case SQLAlchemy not installed
1 file changed with 4 insertions and 7 deletions:
0 comments (0 inline, 0 general)
rattail/emails.py
Show inline comments
 
@@ -21,35 +21,32 @@
 
#
 
################################################################################
 
"""
 
Common email config objects
 
"""
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
import datetime
 
import sys
 
import socket
 
from traceback import format_exception
 

	
 
import six
 

	
 
from rattail.mail import Email
 
from rattail.util import load_object
 
from rattail.core import Object
 
from rattail.time import make_utc, localtime
 
from rattail.problems import ProblemReport, get_problem_report_handler
 

	
 

	
 
class ProblemReportEmail(Email):
 
    """
 
    Base class for all "problem report" emails
 
    """
 
    abstract = True
 

	
 
    def obtain_sample_data(self, request):
 
        from rattail.problems import ProblemReport, get_problem_report_handler
 

	
 
        data = self.sample_data(request)
 
        handler = get_problem_report_handler(self.config)
 

	
 
        if 'report' not in data:
 
            reports = handler.get_all_problem_reports()
 
            email_key = self.__class__.__name__
 
@@ -242,13 +239,13 @@ class ImporterEmail(Email):
 
                'Widget': (
 
                    [],                             # created
 
                    [(obj, local_data, host_data)], # updated
 
                    [],                             # deleted
 
                ),
 
            },
 
            'render_record': lambda x: six.text_type(x),
 
            'render_record': lambda x: str(x),
 
            'max_display': 15,
 
        }
 

	
 

	
 
class rattail_export_rattail_updates(ImporterEmail):
 
    """
 
@@ -389,13 +386,13 @@ class trainwreck_problems_missing_dbs(ProblemReportEmail):
 
    it's actually needed.
 
    """
 
    default_subject = "Trainwreck missing DB"
 
    abstract = False
 

	
 
    def sample_data(self, request):
 
        next_year = six.text_type(self.app.today().year + 1)
 
        next_year = str(self.app.today().year + 1)
 
        return {
 
            'problems': [next_year],
 
        }
 

	
 

	
 
class upgrade_failure(Email):
0 comments (0 inline, 0 general)