示例#1
0
文件: mail.py 项目: yrgdplstv/v2v
def mail_target_participants(participant_cls, target, subject,
                             excluded_emails=[], template=None, **kwargs):
    """Send a message to participants of a given target."""
    participants = participant_cls.objects.filter(
        content_type=ContentType.objects.get_for_model(target),
        object_id=target.pk,
    )
    participants = [p for p in participants if p.email not in excluded_emails]
    messages = _get_messages(participants, template, **kwargs)
    mail_multiple_personalized(subject, messages,
                               from_email=get_target_email_address(target))
示例#2
0
文件: mail.py 项目: ebrelsford/v2v
def mail_facilitators(target, subject, excluded_emails=[],
                      template='organize/notifications/facilitators_text.txt',
                      **kwargs):
    """Sends a message to facilitators."""
    facilitators = settings.FACILITATORS['global']
    facilitators = [f for f in facilitators if f not in excluded_emails]

    messages = _get_facilitator_messages(facilitators, target, template,
                                         **kwargs)
    mail_multiple_personalized(subject, messages, fail_silently=False,
                               from_email=get_target_email_address(target))
示例#3
0
文件: mail.py 项目: yrgdplstv/v2v
def mass_mailing(subject, message, objects, template_name, **kwargs):
    messages = {}
    for obj in objects:
        # message gets sent once to each unique email address, thanks to dict
        messages[obj.email] = render_to_string(template_name, {
            'site': Site.objects.get_current(),
            'target': obj.content_object,
            'message': message,
            'obj': obj,
        })

    mail_multiple_personalized(subject, messages, **kwargs)
示例#4
0
def mail_facilitators(target,
                      subject,
                      excluded_emails=[],
                      template='organize/notifications/facilitators_text.txt',
                      **kwargs):
    """Sends a message to facilitators."""
    facilitators = settings.FACILITATORS['global']
    facilitators = [f for f in facilitators if f not in excluded_emails]

    messages = _get_facilitator_messages(facilitators, target, template,
                                         **kwargs)
    mail_multiple_personalized(subject,
                               messages,
                               fail_silently=False,
                               from_email=get_target_email_address(target))