Exemple #1
0
def send_email_to_admins(sender, **kwargs):
    """Send a copy of the message to admins"""
    instance = kwargs.get('instance')
    admin_emails = get_admin_emails()
    if admin_emails:
        subject = _("New message from") + " " + instance.email
        message = render_to_string('storybase_action/sitecontactmessage_email.txt',
                                   { 'message': instance })
        send_mail(subject, message, instance.email, admin_emails)
Exemple #2
0
def send_email_to_admins(sender, **kwargs):
    """Send a copy of the message to admins"""
    from django.template.loader import render_to_string 
    from django.core.mail import send_mail

    instance = kwargs.get('instance')
    admin_emails = get_admin_emails()
    if admin_emails:
        subject = _("New message from") + " " + instance.email
        message = render_to_string('storybase_messaging/sitecontactmessage_email.txt',
                                   { 'message': instance })
        send_mail(subject, message, instance.email, admin_emails)
Exemple #3
0
def send_email_to_admins(sender, **kwargs):
    """Send a copy of the message to admins"""
    from django.template.loader import render_to_string
    from django.core.mail import send_mail

    instance = kwargs.get('instance')
    admin_emails = get_admin_emails()
    if admin_emails:
        subject = _("New message from") + " " + instance.email
        message = render_to_string(
            'storybase_messaging/sitecontactmessage_email.txt',
            {'message': instance})
        send_mail(subject, message, instance.email, admin_emails)
Exemple #4
0
 def test_get_admin_emails(self):
     """Test get_admin_emails() returns a list of administrator emails"""
     admin1 = User.objects.create(username='******', password='******',
                                  email='*****@*****.**')
     admin1.groups.add(self.admin_group)
     admin1.save()
     admin2 = User.objects.create(username='******', password='******',
                                  email='*****@*****.**')
     admin2.groups.add(self.admin_group)
     admin2.save()
     nonadmin = User.objects.create(username='******', 
                                    password='******',
                                    email='*****@*****.**')
     admin_emails = get_admin_emails()
     self.assertEqual(len(admin_emails), 2)
     self.assertIn(admin1.email, admin_emails)
     self.assertIn(admin2.email, admin_emails)
Exemple #5
0
 def test_get_admin_emails_fallback(self):
     """
     Tests that superuser emails are defined if there are no users in
     the admin group
     """
     admin1 = User.objects.create(username='******', password='******',
                                  email='*****@*****.**',
                                  is_superuser=True)
     admin2 = User.objects.create(username='******', password='******',
                                  email='*****@*****.**',
                                  is_superuser=True)
     nonadmin = User.objects.create(username='******', 
                                    password='******',
                                    email='*****@*****.**')
     admin_emails = get_admin_emails()
     self.assertEqual(len(admin_emails), 2)
     self.assertIn(admin1.email, admin_emails)
     self.assertIn(admin2.email, admin_emails)