예제 #1
0
파일: tasks.py 프로젝트: sgarrity/kitsune
def build_answer_notification(answer):
    ct = ContentType.objects.get_for_model(answer.question)

    subject = _('New answer to: %s') % answer.question.title
    t = loader.get_template('questions/email/new_answer.ltxt')
    c = {'answer': answer.content, 'author': answer.creator.username,
         'question_title': answer.question.title,
         'host': Site.objects.get_current().domain,
         'answer_url': answer.get_absolute_url()}
    content = t.render(Context(c))
    exclude = (answer.creator.email,)

    send_notification.delay(ct, answer.question.pk, subject,
                            content, exclude, 'reply')
예제 #2
0
파일: tasks.py 프로젝트: MechanisM/kitsune
def build_thread_notification(post):
    forum_ct = ContentType.objects.get_for_model(post.thread.forum)

    subject = _('New thread in %s forum: %s') % (post.thread.forum.name,
                                                 post.thread.title)
    t = loader.get_template('forums/email/new_thread.ltxt')
    c = {'post': post.content, 'author': post.author.username,
         'host': Site.objects.get_current().domain,
         'thread_title': post.thread.title,
         'post_url': post.thread.get_absolute_url()}
    content = t.render(Context(c))
    exclude = (post.thread.creator.email,)

    # Send to forum watchers
    send_notification.delay(forum_ct.id, post.thread.forum.id, subject,
                            content, exclude, 'post')
예제 #3
0
파일: tasks.py 프로젝트: sgarrity/kitsune
def build_solution_notification(question):
    """Send emails to everyone watching the question--except the asker."""
    ct = ContentType.objects.get_for_model(question)
    # Cache solution.question as a workaround for replication lag (bug 585029)
    question.solution.question = question

    subject = _('Solution to: %s') % question.title
    t = loader.get_template('questions/email/solution.ltxt')
    c = {'solution': question.solution.content,
         'author': question.creator.username,
         'question_title': question.title,
         'host': Site.objects.get_current().domain,
         'solution_url': question.solution.get_absolute_url()}
    content = t.render(Context(c))
    exclude = (question.creator.email,)

    send_notification.delay(ct, question.pk, subject, content,
                            exclude, 'solution')
예제 #4
0
파일: tasks.py 프로젝트: MechanisM/kitsune
def build_reply_notification(post):
    thread_ct = ContentType.objects.get_for_model(post.thread)
    forum_ct = ContentType.objects.get_for_model(post.thread.forum)

    subject = _('Reply to: %s') % post.thread.title
    t = loader.get_template('forums/email/new_post.ltxt')
    c = {'post': post.content, 'author': post.author.username,
         'host': Site.objects.get_current().domain,
         'thread_title': post.thread.title,
         'post_url': post.get_absolute_url()}
    content = t.render(Context(c))
    exclude = (post.author.email,)

    # Send to thread watchers
    send_notification.delay(thread_ct.id, post.thread.id, subject,
                            content, exclude, 'reply')
    # And forum watchers
    send_notification.delay(forum_ct.id, post.thread.forum.id, subject,
                            content, exclude, 'post')
예제 #5
0
파일: tasks.py 프로젝트: MechanisM/kitsune
def _send_notification(revision, document, subject, template, url, event_type,
                       locale=''):
    subject = subject.format(title=document.title, creator=revision.creator,
                             locale=document.locale)
    t = loader.get_template(template)
    c = {'document_title': document.title,
         'creator': revision.creator,
         'url': url,
         'host': Site.objects.get_current().domain}
    content = t.render(Context(c))
    exclude = revision.creator.email,
    ct = ContentType.objects.get_for_model(document)
    if event_type == 'ready_for_review' or event_type == 'approved':
        id = None
    else:
        id = document.id

    send_notification.delay(ct, id, subject, content, exclude,
                            event_type, locale)