Пример #1
0
def send_message_to_admins(sender, **kwargs):
    """Send a copy of the message to admins"""
    from django.template.loader import render_to_string

    instance = kwargs.get("instance")
    subject = _("New message from") + " " + instance.email
    message = render_to_string("storybase_messaging/sitecontactmessage_email.txt", {"message": instance})
    send_admin_mail(subject, message, settings.DEFAULT_FROM_EMAIL)
Пример #2
0
def send_message_to_admins(sender, **kwargs):
    """Send a copy of the message to admins"""
    from django.template.loader import render_to_string 

    instance = kwargs.get('instance')
    subject = _("New message from") + " " + instance.email
    message = render_to_string('storybase_messaging/sitecontactmessage_email.txt',
                               { 'message': instance })
    send_admin_mail(subject, message, settings.DEFAULT_FROM_EMAIL)
Пример #3
0
def send_message_to_admins(sender, **kwargs):
    """Send a copy of the message to admins"""
    from django.template.loader import render_to_string 

    instance = kwargs.get('instance')
    subject = _("New message from") + " " + instance.email
    message = render_to_string('storybase_messaging/sitecontactmessage_email.txt',
                               { 'message': instance })
    send_admin_mail(subject, message, instance.email)
Пример #4
0
 def send_create_notification(self, obj=None):
     if obj is None:
         obj = self.object
     admin_url_name = "admin:%s_%s_change" % (obj._meta.app_label,
             obj._meta.object_name.lower())
     admin_url = full_url(reverse(admin_url_name, args=(obj.id,)))
     message = render_to_string('storybase_user/admin_approval_required_email.txt',
             { 'object': obj, 'admin_url': admin_url })
     subject = "New %s %s needs your approval" % (
             obj._meta.object_name, obj.name)
     send_admin_mail(subject, message, settings.DEFAULT_FROM_EMAIL)
     return True 
Пример #5
0
 def send_create_notification(self, obj=None):
     if obj is None:
         obj = self.object
     admin_url_name = "admin:%s_%s_change" % (obj._meta.app_label,
                                              obj._meta.object_name.lower())
     admin_url = full_url(reverse(admin_url_name, args=(obj.id, )))
     message = render_to_string(
         'storybase_user/admin_approval_required_email.txt', {
             'object': obj,
             'admin_url': admin_url
         })
     subject = "New %s %s needs your approval" % (obj._meta.object_name,
                                                  obj.name)
     send_admin_mail(subject, message, settings.DEFAULT_FROM_EMAIL)
     return True
Пример #6
0
    def test_send_admin_mail(self):
        backend = getattr(settings, 'EMAIL_BACKEND', None)
        if backend != 'django.core.mail.backends.locmem.EmailBackend':
            self.fail("You must use the in-memory e-mail backend when "
                      "running this test")

        from_email = "*****@*****.**"
        message_body = "Test message to admins"
        subject = "Test admin email"
        admin = User.objects.create(username='******', 
            password='******', email='*****@*****.**')
        admin.groups.add(self.admin_group)
        admin.save()
        send_admin_mail(subject, message_body, from_email)
            
        from django.core.mail import outbox
        sent_email = outbox[0]
        self.assertEqual(sent_email.from_email, from_email)
        self.assertEqual(sent_email.subject, subject) 
        self.assertIn(admin.email, sent_email.to)
        self.assertIn(message_body, sent_email.body)