Beispiel #1
0
def email_digest(recipient_ids, uid, event, user, node, timestamp, **context):
    """ Render the email message from context vars and store in the
        NotificationDigest objects created for each subscribed user.
    """
    template = event + '.html.mako'
    context['user'] = user
    node_lineage_ids = get_node_lineage(node) if node else []

    for user_id in recipient_ids:
        recipient = website_models.User.load(user_id)
        context['localized_timestamp'] = localize_timestamp(
            timestamp, recipient)
        message = mails.render_message(template, **context)

        if user._id != recipient._id:
            digest = NotificationDigest(timestamp=timestamp,
                                        event=event,
                                        user_id=recipient._id,
                                        message=message,
                                        node_lineage=node_lineage_ids)
            digest.save()
Beispiel #2
0
def email_digest(recipient_ids, uid, event, user, node, timestamp, **context):
    """ Render the email message from context vars and store in the
        NotificationDigest objects created for each subscribed user.
    """
    template = event + '.html.mako'
    context['user'] = user
    node_lineage_ids = get_node_lineage(node) if node else []

    for user_id in recipient_ids:
        recipient = website_models.User.load(user_id)
        context['localized_timestamp'] = localize_timestamp(timestamp, recipient)
        message = mails.render_message(template, **context)

        if user._id != recipient._id:
            digest = NotificationDigest(
                timestamp=timestamp,
                event=event,
                user_id=recipient._id,
                message=message,
                node_lineage=node_lineage_ids
            )
            digest.save()
Beispiel #3
0
def email_digest(subscribed_user_ids, uid, event, **context):
    """ Render the email message from context vars and store in the
        NotificationDigest objects created for each subscribed user.
    """
    template = event + '.html.mako'

    node = website_models.Node.load(uid)
    node_lineage_ids = get_node_lineage(node) if node else []

    for user_id in subscribed_user_ids:
        user = website_models.User.load(user_id)
        context['localized_timestamp'] = localize_timestamp(
            context.get('timestamp'), user)
        message = mails.render_message(template, **context)

        if context.get('commenter')._id != user._id:
            digest = NotificationDigest(timestamp=context.get('timestamp'),
                                        event=event,
                                        user_id=user._id,
                                        message=message,
                                        node_lineage=node_lineage_ids)
            digest.save()
Beispiel #4
0
def email_digest(subscribed_user_ids, uid, event, **context):
    """ Render the email message from context vars and store in the
        NotificationDigest objects created for each subscribed user.
    """
    template = event + '.html.mako'

    node = website_models.Node.load(uid)
    node_lineage_ids = get_node_lineage(node) if node else []

    for user_id in subscribed_user_ids:
        user = website_models.User.load(user_id)
        context['localized_timestamp'] = localize_timestamp(context.get('timestamp'), user)
        message = mails.render_message(template, **context)

        if context.get('commenter')._id != user._id:
            digest = NotificationDigest(
                timestamp=context.get('timestamp'),
                event=event,
                user_id=user._id,
                message=message,
                node_lineage=node_lineage_ids
            )
            digest.save()
Beispiel #5
0
def store_emails(recipient_ids, notification_type, event, user, node,
                 timestamp, **context):
    """Store notification emails

    Emails are sent via celery beat as digests
    :param recipient_ids: List of user ids to send mail to.
    :param notification_type: from constants.Notification_types
    :param event: event that triggered notification
    :param user: user who triggered the notification
    :param node: instance of Node
    :param timestamp: time event happened
    :param context:
    :return: --
    """
    if notification_type == 'none':
        return

    template = event + '.html.mako'
    context['user'] = user
    node_lineage_ids = get_node_lineage(node) if node else []

    for user_id in recipient_ids:
        if user_id == user._id:
            continue
        recipient = website_models.User.load(user_id)
        context['localized_timestamp'] = localize_timestamp(
            timestamp, recipient)
        message = mails.render_message(template, **context)

        digest = NotificationDigest(timestamp=timestamp,
                                    send_type=notification_type,
                                    event=event,
                                    user_id=user_id,
                                    message=message,
                                    node_lineage=node_lineage_ids)
        digest.save()
Beispiel #6
0
def store_emails(recipient_ids, notification_type, event, user, node, timestamp, **context):
    """Store notification emails

    Emails are sent via celery beat as digests
    :param recipient_ids: List of user ids to send mail to.
    :param notification_type: from constants.Notification_types
    :param event: event that triggered notification
    :param user: user who triggered the notification
    :param node: instance of Node
    :param timestamp: time event happened
    :param context:
    :return: --
    """
    if notification_type == 'none':
        return

    template = event + '.html.mako'
    context['user'] = user
    node_lineage_ids = get_node_lineage(node) if node else []

    for user_id in recipient_ids:
        if user_id == user._id:
            continue
        recipient = website_models.User.load(user_id)
        context['localized_timestamp'] = localize_timestamp(timestamp, recipient)
        message = mails.render_message(template, **context)

        digest = NotificationDigest(
            timestamp=timestamp,
            send_type=notification_type,
            event=event,
            user_id=user_id,
            message=message,
            node_lineage=node_lineage_ids
        )
        digest.save()