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


Python QuestionReplyEvent.is_notifying方法代码示例

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


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

示例1: test_no_notification_on_update

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
    def test_no_notification_on_update(self):
        """Saving an existing question does not watch it."""

        q = Question.objects.get(pk=1)
        assert not QuestionReplyEvent.is_notifying(q.creator, q)

        q.save()
        assert not QuestionReplyEvent.is_notifying(q.creator, q)
开发者ID:Akamad007,项目名称:kitsune,代码行数:10,代码来源:test_models.py

示例2: _answers_data

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent 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

示例3: _answers_data

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent 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_notification_created

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
    def test_notification_created(self):
        """Creating a new question auto-watches it for answers."""

        u = User.objects.get(pk=118533)
        q = Question(creator=u, title='foo', content='bar')
        q.save()

        assert QuestionReplyEvent.is_notifying(u, q)
开发者ID:Akamad007,项目名称:kitsune,代码行数:10,代码来源:test_models.py

示例5: test_watch_replies_logged_in

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
 def test_watch_replies_logged_in(self):
     """Watch a question for replies (logged in)."""
     self.client.login(username='rrosario', password='testpass')
     user = User.objects.get(username='rrosario')
     post(self.client, 'questions.watch',
          {'event_type': 'reply'},
          args=[self.question.id])
     assert QuestionReplyEvent.is_notifying(user, self.question), (
            'Watch was not created')
开发者ID:jledbetter,项目名称:kitsune,代码行数:11,代码来源:test_templates.py

示例6: test_unwatch

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
 def test_unwatch(self):
     """Unwatch a question."""
     # First watch question.
     self.test_watch_replies_logged_in()
     # Then unwatch it.
     self.client.login(username="rrosario", password="testpass")
     user = User.objects.get(username="rrosario")
     post(self.client, "questions.unwatch", args=[self.question.id])
     assert not QuestionReplyEvent.is_notifying(user, self.question), "Watch was not destroyed"
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:11,代码来源:test_templates.py

示例7: test_autowatch_reply

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
    def test_autowatch_reply(self, get_current):
        get_current.return_value.domain = 'testserver'

        user = User.objects.get(username='timw')
        t1, t2 = Question.objects.filter(is_locked=False)[0:2]
        assert not QuestionReplyEvent.is_notifying(user, t1)
        assert not QuestionReplyEvent.is_notifying(user, t2)

        self.client.login(username='timw', password='testpass')
        s = Setting.objects.create(user=user, name='questions_watch_after_reply',
                                   value='True')
        data = {'content': 'some content'}
        post(self.client, 'questions.reply', data, args=[t1.id])
        assert QuestionReplyEvent.is_notifying(user, t1)

        s.value = 'False'
        s.save()
        post(self.client, 'questions.reply', data, args=[t2.id])
        assert not QuestionReplyEvent.is_notifying(user, t2)
开发者ID:readevalprint,项目名称:kitsune,代码行数:21,代码来源:test_notifications.py

示例8: test_watch_replies_smtp_error

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
    def test_watch_replies_smtp_error(self, emailmessage_send):
        """Watch a question for replies and fail to send email."""
        emailmessage_send.side_effect = emailmessage_raise_smtp
        self.client.logout()

        r = post(
            self.client, "questions.watch", {"email": "[email protected]", "event_type": "reply"}, args=[self.question.id]
        )
        assert not QuestionReplyEvent.is_notifying("[email protected]", self.question), "Watch was created"
        self.assertContains(r, "Could not send a message to that email")
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:12,代码来源:test_templates.py

示例9: test_watch_replies_smtp_error

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
    def test_watch_replies_smtp_error(self, emailmessage_send):
        """Watch a question for replies and fail to send email."""
        emailmessage_send.side_effect = emailmessage_raise_smtp
        self.client.logout()

        r = post(self.client, 'questions.watch',
                 {'email': '[email protected]', 'event_type': 'reply'},
                 args=[self.question.id])
        assert not QuestionReplyEvent.is_notifying(
            '[email protected]', self.question), 'Watch was created'
        self.assertContains(r, 'Could not send a message to that email')
开发者ID:jledbetter,项目名称:kitsune,代码行数:13,代码来源:test_templates.py

示例10: test_watch_replies

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

        post(self.client, "questions.watch", {"email": "[email protected]", "event_type": "reply"}, args=[self.question.id])
        assert QuestionReplyEvent.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 "New answers" 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

示例11: test_watch_replies

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

        post(self.client, 'questions.watch',
             {'email': '[email protected]', 'event_type': 'reply'},
             args=[self.question.id])
        assert QuestionReplyEvent.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 'New answers' 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

示例12: test_watch_replies_logged_in

# 需要导入模块: from questions.events import QuestionReplyEvent [as 别名]
# 或者: from questions.events.QuestionReplyEvent import is_notifying [as 别名]
 def test_watch_replies_logged_in(self):
     """Watch a question for replies (logged in)."""
     self.client.login(username="rrosario", password="testpass")
     user = User.objects.get(username="rrosario")
     post(self.client, "questions.watch", {"event_type": "reply"}, args=[self.question.id])
     assert QuestionReplyEvent.is_notifying(user, self.question), "Watch was not created"
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:8,代码来源:test_templates.py


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