Exemple #1
0
    subscription = QuestionSubscription(question=question,
                                        user=question.author)
    subscription.save()

    new_subscribers = User.objects.filter(
        Q(subscription_settings__all_questions=True)
        | Q(subscription_settings__all_questions_watched_tags=True,
            marked_tags__name__in=question.tagnames.split(' '),
            tag_selections__reason='good'))

    for user in new_subscribers:
        create_subscription_if_not_exists(question, user)


AskAction.hook(question_posted)


def answer_posted(action, new):
    answer = action.node
    question = answer.question

    logging.error("Answer posted: %s" % str(answer.is_notifiable))

    if not answer.is_notifiable or not question.is_notifiable:
        return

    subscribers = question.subscribers.filter(
        subscription_settings__enable_notifications=True,
        subscription_settings__notify_answers=True,
        subscription_settings__subscribed_questions='i').exclude(
Exemple #2
0
    room.speak(unicode(message))


def full_app_url(url):
    return APP_URL + url


def question_posted(action, new):
    if not enabled():
        return
    question = action.node
    speak(_('New question: %(headline)s - %(url)s' % {
            'headline': question.headline,
            'url': full_app_url(question.get_absolute_url())
            }))


def answer_posted(action, new):
    if not enabled():
        return
    answer = action.node
    question = answer.question
    speak(_('New answer posted for question: %(headline)s - %(url)s' % {
        'headline': question.headline,
        'url': full_app_url(question.get_absolute_url())
        }))


AskAction.hook(question_posted)
AnswerAction.hook(answer_posted)
Exemple #3
0
    send_template_email(subscribers, "notifications/newquestion.html", {'question': question})

    if question.author.subscription_settings.questions_asked:
        subscription = QuestionSubscription(question=question, user=question.author)
        subscription.save()

    new_subscribers = User.objects.filter(
            Q(subscription_settings__all_questions=True) |
            Q(subscription_settings__all_questions_watched_tags=True,
                    marked_tags__name__in=question.tagnames.split(' '),
                    tag_selections__reason='good'))

    for user in new_subscribers:
        create_subscription_if_not_exists(question, user)

AskAction.hook(question_posted)


def answer_posted(action, new):
    answer = action.node
    question = answer.question

    subscribers = question.subscribers.filter(
            subscription_settings__enable_notifications=True,
            subscription_settings__notify_answers=True,
            subscription_settings__subscribed_questions='i'
    ).exclude(id=answer.author.id).distinct()

    subscribers = filter_subscribers(subscribers)

    send_template_email(subscribers, "notifications/newanswer.html", {'answer': answer})