当前位置: 首页>>代码示例>>Python>>正文


Python QuestionSolvedEvent.is_notifying方法代码示例

本文整理汇总了Python中questions.events.QuestionSolvedEvent.is_notifying方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionSolvedEvent.is_notifying方法的具体用法?Python QuestionSolvedEvent.is_notifying怎么用?Python QuestionSolvedEvent.is_notifying使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在questions.events.QuestionSolvedEvent的用法示例。


在下文中一共展示了QuestionSolvedEvent.is_notifying方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _answers_data

# 需要导入模块: from questions.events import QuestionSolvedEvent [as 别名]
# 或者: from questions.events.QuestionSolvedEvent import is_notifying [as 别名]
def _answers_data(request, question_id, form=None, watch_form=None,
                  answer_preview=None):
    """Return a map of the minimal info necessary to draw an answers page."""
    question = get_object_or_404(Question, pk=question_id)
    answers_ = question.answers.all()
    if not request.MOBILE:
        answers_ = paginate(request, answers_,
                            per_page=constants.ANSWERS_PER_PAGE)
    feed_urls = ((reverse('questions.answers.feed',
                          kwargs={'question_id': question_id}),
                  AnswersFeed().title(question)),)
    frequencies = dict(FREQUENCY_CHOICES)

    is_watching_question = (
        request.user.is_authenticated() and (
        QuestionReplyEvent.is_notifying(request.user, question) or
        QuestionSolvedEvent.is_notifying(request.user, question)))
    return {'question': question,
            'answers': answers_,
            'form': form or AnswerForm(),
            'answer_preview': answer_preview,
            'watch_form': watch_form or _init_watch_form(request, 'reply'),
            'feeds': feed_urls,
            'frequencies': frequencies,
            'is_watching_question': is_watching_question,
            'can_tag': request.user.has_perm('questions.tag_question'),
            'can_create_tags': request.user.has_perm('taggit.add_tag')}
开发者ID:victorneo,项目名称:kitsune,代码行数:29,代码来源:views.py

示例2: _watch_question

# 需要导入模块: from questions.events import QuestionSolvedEvent [as 别名]
# 或者: from questions.events.QuestionSolvedEvent import is_notifying [as 别名]
    def _watch_question(self):
        """Helper to watch a question."""
        question = Question.objects.all()[0]
        self.client.login(username='pcraciunoiu', password='testpass')
        user = User.objects.get(username='pcraciunoiu')

        # Make sure it isn't watching yet.
        assert not QuestionSolvedEvent.is_notifying(user, question), (
            '%s should not be notifying.' % QuestionSolvedEvent.__name__)

        post(self.client, 'questions.watch', {}, args=[question.id])

        assert QuestionSolvedEvent.is_notifying(user, question), (
            '%s should be notifying.' % QuestionSolvedEvent.__name__)

        return question
开发者ID:strogo,项目名称:kitsune,代码行数:18,代码来源:test_notifications.py

示例3: _answers_data

# 需要导入模块: from questions.events import QuestionSolvedEvent [as 别名]
# 或者: from questions.events.QuestionSolvedEvent import is_notifying [as 别名]
def _answers_data(request, question_id, form=None, watch_form=None, answer_preview=None):
    """Return a map of the minimal info necessary to draw an answers page."""
    question = get_object_or_404(Question, pk=question_id)
    answers_ = paginate(request, question.answers.all(), per_page=constants.ANSWERS_PER_PAGE)
    vocab = [t.name for t in Tag.objects.all()]  # TODO: Fetch only name.
    feed_urls = (
        (reverse("questions.answers.feed", kwargs={"question_id": question_id}), AnswersFeed().title(question)),
    )
    frequencies = dict(FREQUENCY_CHOICES)

    is_watching_question = request.user.is_authenticated() and (
        QuestionReplyEvent.is_notifying(request.user, question)
        or QuestionSolvedEvent.is_notifying(request.user, question)
    )
    return {
        "question": question,
        "answers": answers_,
        "form": form or AnswerForm(),
        "answer_preview": answer_preview,
        "watch_form": watch_form or _init_watch_form(request, "reply"),
        "feeds": feed_urls,
        "tag_vocab": json.dumps(vocab),
        "frequencies": frequencies,
        "is_watching_question": is_watching_question,
        "can_tag": request.user.has_perm("questions.tag_question"),
        "can_create_tags": request.user.has_perm("taggit.add_tag"),
    }
开发者ID:fox2mike,项目名称:kitsune,代码行数:29,代码来源:views.py

示例4: test_watch_solution

# 需要导入模块: from questions.events import QuestionSolvedEvent [as 别名]
# 或者: from questions.events.QuestionSolvedEvent import is_notifying [as 别名]
    def test_watch_solution(self, get_current):
        """Watch a question for solution."""
        self.client.logout()
        get_current.return_value.domain = "testserver"

        post(self.client, "questions.watch", {"email": "[email protected]", "event_type": "solution"}, args=[self.question.id])
        assert QuestionSolvedEvent.is_notifying("[email protected]", self.question), "Watch was not created"

        attrs_eq(mail.outbox[0], to=["[email protected]"], subject="Please confirm your email address")
        assert "questions/confirm/" in mail.outbox[0].body
        assert "Solution found" in mail.outbox[0].body

        # Now activate the watch.
        w = Watch.objects.get()
        get(self.client, "questions.activate_watch", args=[w.id, w.secret])
        assert Watch.objects.get().is_active
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:18,代码来源:test_templates.py

示例5: test_watch_solution

# 需要导入模块: from questions.events import QuestionSolvedEvent [as 别名]
# 或者: from questions.events.QuestionSolvedEvent import is_notifying [as 别名]
    def test_watch_solution(self, get_current):
        """Watch a question for solution."""
        self.client.logout()
        get_current.return_value.domain = 'testserver'

        post(self.client, 'questions.watch',
             {'email': '[email protected]', 'event_type': 'solution'},
             args=[self.question.id])
        assert QuestionSolvedEvent.is_notifying('[email protected]', self.question), (
               'Watch was not created')

        attrs_eq(mail.outbox[0], to=['[email protected]'],
                 subject='Please confirm your email address')
        assert 'questions/confirm/' in mail.outbox[0].body
        assert 'Solution found' in mail.outbox[0].body

        # Now activate the watch.
        w = Watch.objects.get()
        get(self.client, 'questions.activate_watch', args=[w.id, w.secret])
        assert Watch.objects.get().is_active
开发者ID:jledbetter,项目名称:kitsune,代码行数:22,代码来源:test_templates.py


注:本文中的questions.events.QuestionSolvedEvent.is_notifying方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。