Beispiel #1
0
def send_abstract_notifications(abstract):
    """Send abstract notification e-mails.

    :param abstract: the abstract that is going to be checked
                     against the event's notification rules
    :return: whether an email has been sent
    """
    sent = False
    for email_tpl in abstract.event.abstract_email_templates:
        matched = False
        for rule in email_tpl.rules:
            if check_rule('abstract-notifications', rule, abstract=abstract, event=abstract.event):
                matched = True
                to_recipients = []
                if email_tpl.include_submitter:
                    to_recipients.append(abstract.submitter.email)
                if email_tpl.include_authors:
                    to_recipients += [author.email for author in abstract.primary_authors]

                cc_recipients = list(email_tpl.extra_cc_emails)
                if email_tpl.include_coauthors:
                    cc_recipients += [author.email for author in abstract.secondary_authors]

                tpl = get_abstract_notification_tpl_module(email_tpl, abstract)
                email = make_email(to_list=to_recipients, cc_list=cc_recipients,
                                   reply_address=email_tpl.reply_to_address, template=tpl)
                send_email(email, abstract.event, 'Abstracts', session.user)
                abstract.email_logs.append(AbstractEmailLogEntry.create_from_email(email, email_tpl=email_tpl,
                                                                                   user=session.user))
                sent = True
        if email_tpl.stop_on_match and matched:
            break
    return sent
Beispiel #2
0
def send_abstract_notifications(abstract):
    """Send abstract notification e-mails.

    :param abstract: the abstract that is going to be checked
                     against the event's notification rules
    """
    for email_tpl in abstract.event_new.abstract_email_templates:
        matched = False
        for rule in email_tpl.rules:
            if check_rule('abstract-notifications', rule, abstract=abstract, event=abstract.event_new):
                matched = True
                to_recipients = []
                if email_tpl.include_submitter:
                    to_recipients.append(abstract.submitter.email)
                if email_tpl.include_authors:
                    to_recipients += [author.email for author in abstract.primary_authors]

                cc_recipients = list(email_tpl.extra_cc_emails)
                if email_tpl.include_coauthors:
                    cc_recipients += [author.email for author in abstract.secondary_authors]

                tpl = get_abstract_notification_tpl_module(email_tpl, abstract)
                email = make_email(to_list=to_recipients, cc_list=cc_recipients,
                                   reply_address=email_tpl.reply_to_address, template=tpl)
                send_email(email, event=abstract.event_new, user=session.user)
                abstract.email_logs.append(AbstractEmailLogEntry.create_from_email(email, email_tpl=email_tpl,
                                                                                   user=session.user))
        if email_tpl.stop_on_match and matched:
            break
Beispiel #3
0
 def _migrate_abstract_email_log(self, abstract, zodb_abstract):
     for old_entry in zodb_abstract._notifLog._entries:
         email_template = self.email_template_map.get(old_entry._tpl)
         email_template_name = email_template.title if email_template else convert_to_unicode(old_entry._tpl._name)
         entry = AbstractEmailLogEntry(email_template=email_template, sent_dt=old_entry._date,
                                       user=self.user_from_legacy(old_entry._responsible),
                                       recipients=[], subject='<not available>', body='<not available>',
                                       data={'_legacy': True, 'template_name': email_template_name or '<unnamed>'})
         abstract.email_logs.append(entry)