Exemple #1
0
def prepare_new_conflict_resolution_email_to_affected_user(issue):
    created_by = issue.created_by
    conversation = Conversation.objects.get_for_target(issue)
    voting = issue.latest_voting()
    user = issue.affected_user

    reply_to_name = created_by.display_name

    local_part = make_local_part(conversation, user)
    reply_to = formataddr(
        (reply_to_name, '{}@{}'.format(local_part,
                                       settings.SPARKPOST_RELAY_DOMAIN)))
    from_email = formataddr(
        (created_by.display_name, settings.DEFAULT_FROM_EMAIL))

    this_issue_url = issue_url(issue)

    return prepare_email(
        template='new_conflict_resolution_affected_user',
        from_email=from_email,
        user=user,
        tz=issue.group.timezone,
        reply_to=[reply_to],
        context={
            'created_by': created_by,
            'topic': issue.topic_rendered(),
            'conversation_url': this_issue_url,
            'issue_url': this_issue_url,
            'expires_at': voting.expires_at,
            'group': issue.group,
        },
        stats_category='new_conflict_resolution',
    )
Exemple #2
0
def prepare_issue_message_notification(user, messages):
    issue = target_from_messages(messages)
    with translation.override(language_for_user(user)):
        return prepare_message_notification(
            user,
            messages,
            group=issue.group,
            conversation_name=_('New message in conflict resolution in %(group_name)s') % {
                'group_name': issue.group.name,
            },
            conversation_url=issue_url(issue),
            stats_category='issue_message'
        )
Exemple #3
0
def prepare_conflict_resolution_continued_email_to_affected_user(issue):
    voting = issue.latest_voting()
    user = issue.affected_user

    this_issue_url = issue_url(issue)

    return prepare_email(
        template='conflict_resolution_continued_affected_user',
        user=user,
        tz=issue.group.timezone,
        context={
            'issue_url': this_issue_url,
            'expires_at': voting.expires_at,
        })
Exemple #4
0
def prepare_conflict_resolution_continued_email(user, issue):
    affected_user = issue.affected_user
    voting = issue.latest_voting()

    unsubscribe_url = conflict_resolution_unsubscribe_url(user, issue)
    this_issue_url = issue_url(issue)

    return prepare_email(template='conflict_resolution_continued',
                         user=user,
                         tz=issue.group.timezone,
                         context={
                             'affected_user': affected_user,
                             'unsubscribe_url': unsubscribe_url,
                             'issue_url': this_issue_url,
                             'expires_at': voting.expires_at,
                         })
Exemple #5
0
def prepare_issue_message_notification(user, messages):
    first_message = messages[0]
    conversation = first_message.conversation
    author = first_message.author
    reply_to_name = author.display_name
    issue = conversation.target

    language = user.language

    if not translation.check_for_language(language):
        language = 'en'

    with translation.override(language):
        conversation_name = _(
            'New message in conflict resolution in %(group_name)s') % {
                'group_name': issue.group.name,
            }

        from_text = author_names(messages)

        local_part = make_local_part(conversation, user)
        reply_to = formataddr(
            (reply_to_name, '{}@{}'.format(local_part,
                                           settings.SPARKPOST_RELAY_DOMAIN)))
        from_email = formataddr((from_text, settings.DEFAULT_FROM_EMAIL))

        unsubscribe_url = conversation_unsubscribe_url(
            user, group=issue.group, conversation=conversation)

        return prepare_email(
            template='conversation_message_notification',
            from_email=from_email,
            user=user,
            tz=issue.group.timezone,
            reply_to=[reply_to],
            unsubscribe_url=unsubscribe_url,
            context={
                'messages': messages,
                'conversation_name': conversation_name,
                'conversation_url': issue_url(issue),
                'mute_url': unsubscribe_url,
            },
            stats_category='issue_message',
        )