本文整理汇总了Python中kbforums.events.NewPostEvent.is_notifying方法的典型用法代码示例。如果您正苦于以下问题:Python NewPostEvent.is_notifying方法的具体用法?Python NewPostEvent.is_notifying怎么用?Python NewPostEvent.is_notifying使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kbforums.events.NewPostEvent
的用法示例。
在下文中一共展示了NewPostEvent.is_notifying方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_watch_thread
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def test_watch_thread(self):
"""Watch then unwatch a thread."""
self.client.login(username='rrosario', password='testpass')
user = User.objects.get(username='rrosario')
t = Thread.objects.filter()[0]
post(self.client, 'wiki.discuss.watch_thread', {'watch': 'yes'},
args=[t.document.slug, t.id])
assert NewPostEvent.is_notifying(user, t)
# NewThreadEvent is not notifying.
assert not NewThreadEvent.is_notifying(user, t.document)
post(self.client, 'wiki.discuss.watch_thread', {'watch': 'no'},
args=[t.document.slug, t.id])
assert not NewPostEvent.is_notifying(user, t)
示例2: _toggle_watch_thread_as
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def _toggle_watch_thread_as(self, username, thread, turn_on=True):
"""Watch a thread and return it."""
self.client.login(username=username, password='testpass')
user = User.objects.get(username=username)
watch = 'yes' if turn_on else 'no'
post(self.client, 'wiki.discuss.watch_thread', {'watch': watch},
args=[thread.document.slug, thread.id])
# Watch exists or not, depending on watch.
if turn_on:
assert NewPostEvent.is_notifying(user, thread), (
'NewPostEvent should be notifying.')
else:
assert not NewPostEvent.is_notifying(user, thread), (
'NewPostEvent should not be notifying.')
return thread
示例3: test_watch_thread
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def test_watch_thread(self):
"""Watch then unwatch a thread."""
u = user(save=True)
self.client.login(username=u.username, password='testpass')
t = thread(save=True)
post(self.client, 'wiki.discuss.watch_thread', {'watch': 'yes'},
args=[t.document.slug, t.id])
assert NewPostEvent.is_notifying(u, t)
# NewThreadEvent is not notifying.
assert not NewThreadEvent.is_notifying(u, t.document)
post(self.client, 'wiki.discuss.watch_thread', {'watch': 'no'},
args=[t.document.slug, t.id])
assert not NewPostEvent.is_notifying(u, t)
示例4: posts
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def posts(request, document_slug, thread_id, form=None, reply_preview=None):
"""View all the posts in a thread."""
doc = get_document(document_slug, request)
thread = get_object_or_404(Thread, pk=thread_id, document=doc)
posts_ = paginate(request, thread.post_set.all(),
kbforums.POSTS_PER_PAGE)
if not form:
form = ReplyForm()
feed_urls = ((reverse('wiki.discuss.posts.feed',
kwargs={'document_slug': document_slug,
'thread_id': thread_id}),
PostsFeed().title(thread)),)
is_watching_thread = (request.user.is_authenticated() and
NewPostEvent.is_notifying(request.user, thread))
return jingo.render(request, 'kbforums/posts.html',
{'document': doc, 'thread': thread,
'posts': posts_, 'form': form,
'reply_preview': reply_preview,
'is_watching_thread': is_watching_thread,
'feeds': feed_urls})
示例5: test_autowatch_new_thread
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def test_autowatch_new_thread(self, get_current):
"""Creating a new thread should email responses"""
get_current.return_value.domain = 'testserver'
d = document(save=True)
u = user(save=True)
self.client.login(username=u.username, password='testpass')
s = Setting.objects.create(user=u, name='kbforums_watch_new_thread',
value='False')
data = {'title': 'a title', 'content': 'a post'}
post(self.client, 'wiki.discuss.new_thread', data, args=[d.slug])
t1 = thread(document=d, save=True)
assert not NewPostEvent.is_notifying(u, t1), (
'NewPostEvent should not be notifying.')
s.value = 'True'
s.save()
post(self.client, 'wiki.discuss.new_thread', data, args=[d.slug])
t2 = Thread.uncached.all().order_by('-id')[0]
assert NewPostEvent.is_notifying(u, t2), (
'NewPostEvent should be notifying')
示例6: test_autowatch_reply
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def test_autowatch_reply(self, get_current):
get_current.return_value.domain = 'testserver'
user = User.objects.get(username='jsocol')
t1, t2 = Thread.objects.filter(is_locked=False)[0:2]
assert not NewPostEvent.is_notifying(user, t1)
assert not NewPostEvent.is_notifying(user, t2)
self.client.login(username='jsocol', password='testpass')
s = Setting.objects.create(user=user,
name='kbforums_watch_after_reply',
value='True')
data = {'content': 'some content'}
post(self.client, 'wiki.discuss.reply', data,
args=[t1.document.slug, t1.pk])
assert NewPostEvent.is_notifying(user, t1)
s.value = 'False'
s.save()
post(self.client, 'wiki.discuss.reply', data,
args=[t2.document.slug, t2.pk])
assert not NewPostEvent.is_notifying(user, t2)
示例7: _toggle_watch_kbforum_as
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def _toggle_watch_kbforum_as(self, username, turn_on=True, document_id=1):
"""Watch a discussion forum and return it."""
document = Document.objects.get(pk=document_id)
self.client.login(username=username, password='testpass')
user = User.objects.get(username=username)
watch = 'yes' if turn_on else 'no'
post(self.client, 'wiki.discuss.watch_forum', {'watch': watch},
args=[document.slug])
# Watch exists or not, depending on watch.
if turn_on:
assert NewThreadEvent.is_notifying(user, document), (
'NewThreadEvent should be notifying.')
else:
assert not NewPostEvent.is_notifying(user, document), (
'NewThreadEvent should not be notifying.')
return document
示例8: test_watch_forum
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def test_watch_forum(self):
"""Watch then unwatch a forum."""
self.client.login(username='rrosario', password='testpass')
user = User.objects.get(username='rrosario')
d = Document.objects.filter()[0]
post(self.client, 'wiki.discuss.watch_forum', {'watch': 'yes'},
args=[d.slug])
assert NewThreadEvent.is_notifying(user, d)
# NewPostEvent is not notifying.
p = d.thread_set.all()[0].post_set.all()[0]
assert not NewPostEvent.is_notifying(user, p)
post(self.client, 'wiki.discuss.watch_forum', {'watch': 'no'},
args=[d.slug])
assert not NewThreadEvent.is_notifying(user, d)
示例9: test_watch_forum
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def test_watch_forum(self):
"""Watch then unwatch a forum."""
u = user(save=True)
self.client.login(username=u.username, password='testpass')
d = document(save=True)
post(self.client, 'wiki.discuss.watch_forum', {'watch': 'yes'},
args=[d.slug])
assert NewThreadEvent.is_notifying(u, d)
# NewPostEvent is not notifying.
t = thread(document=d, save=True)
p = t.new_post(creator=t.creator, content='test')
#p = d.thread_set.all()[0].post_set.all()[0]
assert not NewPostEvent.is_notifying(u, p)
post(self.client, 'wiki.discuss.watch_forum', {'watch': 'no'},
args=[d.slug])
assert not NewThreadEvent.is_notifying(u, d)
示例10: posts
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def posts(request, document_slug, thread_id, form=None, post_preview=None):
"""View all the posts in a thread."""
doc = get_document(document_slug, request)
thread = get_object_or_404(Thread, pk=thread_id, document=doc)
posts_ = thread.post_set.all()
count = posts_.count()
if count:
last_post = posts_[count - 1]
else:
last_post = None
posts_ = paginate(request, posts_, kbforums.POSTS_PER_PAGE)
if not form:
form = ReplyForm()
feed_urls = (
(
reverse("wiki.discuss.posts.feed", kwargs={"document_slug": document_slug, "thread_id": thread_id}),
PostsFeed().title(thread),
),
)
is_watching_thread = request.user.is_authenticated() and NewPostEvent.is_notifying(request.user, thread)
return jingo.render(
request,
"kbforums/posts.html",
{
"document": doc,
"thread": thread,
"posts": posts_,
"form": form,
"count": count,
"last_post": last_post,
"post_preview": post_preview,
"is_watching_thread": is_watching_thread,
"feeds": feed_urls,
},
)
示例11: test_delete_removes_watches
# 需要导入模块: from kbforums.events import NewPostEvent [as 别名]
# 或者: from kbforums.events.NewPostEvent import is_notifying [as 别名]
def test_delete_removes_watches(self):
t = Thread.objects.get(pk=1)
NewPostEvent.notify('[email protected]', t)
assert NewPostEvent.is_notifying('[email protected]', t)
t.delete()
assert not NewPostEvent.is_notifying('[email protected]', t)