예제 #1
0
    def mail_log(self):
        body = self.body + self.get_recent_log()
        subject = self.subject + self.get_error_summary()
        # Ignore the normal email queueing / spam-prevention system because the
        # addressees are devs, and they can customize the deluge themselves.
        email = Email.create(to_address=self.to_addresses,
                             subject=subject,
                             body=body)
        email.put()
        # We want to send this immediately, not in batches.
        email.deliver()

        self.last_email = self.now
        return (subject, body)
예제 #2
0
    def create_email(self):
        """Create an email to match the content of the notification if user
        has not set their notification preferences to disable emails.
        """
        recipient = self.key.parent().get()

        # The default is to send an email, unless the user has disabled
        if recipient.notification_option.get('email', None) == 'no':
            return None

        return Email.create(
            to_address=recipient.email,
            subject=self.subject,
            template='notification.html',
            template_data={
                'subject': self.subject,
                'body': self.body,
                'link': self.link
            },
        )