Rename the function, and provide the "domain" context for url linking in the emails

This commit is contained in:
2011-09-30 10:00:54 +01:00
parent 8318942e7e
commit c6c397dab0

View File

@@ -2,14 +2,14 @@ from django.conf import settings
from django.core.mail import EmailMultiAlternatives from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template from django.template.loader import get_template
from django.template import Context from django.template import Context
from django.contrib.sites.models import Site
def send_group_mail(request, to_email, subject, email_text_template, email_html_template): def send_group_email(request, to_email, subject, email_text_template, email_html_template):
"""Sends a email to a group of people using a standard layout""" """Sends a email to a group of people using a standard layout"""
# Mail the admins to inform them of a new request # Mail the admins to inform them of a new request
ctx = Context({'request': obj}) ctx = Context({'request': request, 'domain': Site.objects.get_current().domain})
to_email = group.admins.values_list('email', flat=True)
msg = EmailMultiAlternatives(subject, get_template(email_text_template).render(ctx), getattr(settings, 'DEFAULT_FROM_EMAIL', 'auth@pleaseignore.com'), to_email) msg = EmailMultiAlternatives(subject, get_template(email_text_template).render(ctx), getattr(settings, 'DEFAULT_FROM_EMAIL', 'auth@pleaseignore.com'), to_email)
msg.attach_alternative(get_template(email_html_template).render(ctx), 'text/html') msg.attach_alternative(get_template(email_html_template).render(ctx), 'text/html')
mag.send(fail_silently=True) msg.send(fail_silently=True)