Esempio n. 1
0
 def test_setting_is_false(self, mock_config):
     """
     Tests the emails_enabled function when the Constance config is
     False.
     """
     mock_config.EMAIL_NOTIFICATIONS_ENABLED = False
     self.assertFalse(emails_enabled())
Esempio n. 2
0
 def test_setting_does_not_exist(self, mock_config):
     """
     Tests the emails_enabled function when the Constance config
     doesn't exist.
     """
     del mock_config.EMAIL_NOTIFICATIONS_ENABLED
     self.assertEqual(emails_enabled(), True)
Esempio n. 3
0
def send_comment_notification(sender, instance, created, **kwargs):
    """Email relevant users when a new |Comment| is saved."""

    # email relevant users if a comment is created
    if created and emails_enabled():
        for user in instance.get_other_contributors():
            email_message = compose_comment_email(instance, user)
            try:
                email_message.send()
            except smtplib.SMTPAuthenticationError as error:
                _LOGGER.error(
                    'An error occurred when sending an '
                    'email notification: %s', error)