本文整理汇总了Python中utils.create_topic函数的典型用法代码示例。如果您正苦于以下问题:Python create_topic函数的具体用法?Python create_topic怎么用?Python create_topic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_topic函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
cache.clear()
self.user = utils.create_user()
self.user2 = utils.create_user()
self.category = utils.create_category()
self.topic = utils.create_topic(self.category, user=self.user2)
self.topic2 = utils.create_topic(self.category)
开发者ID:AlienTechs,项目名称:Spirit,代码行数:7,代码来源:tests_user.py
示例2: test_topic_active_view_pinned
def test_topic_active_view_pinned(self):
"""
pinned topics. Only show pinned topics from uncategorized category, even if the category is removed
"""
category = utils.create_category()
# show topic from regular category
topic_a = utils.create_topic(category=category)
# dont show pinned from regular category
topic_b = utils.create_topic(category=category, is_pinned=True)
uncat_category = Category.objects.get(pk=settings.ST_UNCATEGORIZED_CATEGORY_PK)
# dont show pinned and removed
topic_c = utils.create_topic(category=uncat_category, is_pinned=True, is_removed=True)
# show topic from uncategorized category
topic_d = utils.create_topic(category=uncat_category, is_pinned=True)
# show pinned first
Topic.objects.filter(pk=topic_d.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
response = self.client.get(reverse('spirit:topic-active'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_d, topic_a, ]))
# show topic from uncategorized category even if it is removed
Category.objects.filter(pk=uncat_category.pk).update(is_removed=True)
response = self.client.get(reverse('spirit:topic-active'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_d, topic_a, ]))
开发者ID:MGXRace,项目名称:Spirit,代码行数:25,代码来源:tests_topic.py
示例3: test_topic_notification_has_notifications_dont_count_topic_removed_or_no_access
def test_topic_notification_has_notifications_dont_count_topic_removed_or_no_access(self):
"""
dont show private topics if user has no access or is removed
"""
TopicNotification.objects.all().delete()
category = utils.create_category()
category_removed = utils.create_category(is_removed=True)
subcategory = utils.create_category(parent=category_removed)
subcategory_removed = utils.create_category(parent=category, is_removed=True)
topic_a = utils.create_private_topic()
topic_b = utils.create_topic(category=category, is_removed=True)
topic_c = utils.create_topic(category=category_removed)
topic_d = utils.create_topic(category=subcategory)
topic_e = utils.create_topic(category=subcategory_removed)
unread_a = TopicNotification.objects.create(user=self.user, topic=topic_a.topic,
comment=self.comment, is_active=True, action=COMMENT)
unread_b = TopicNotification.objects.create(user=self.user, topic=topic_b,
comment=self.comment, is_active=True, action=COMMENT)
unread_c = TopicNotification.objects.create(user=self.user, topic=topic_c,
comment=self.comment, is_active=True, action=COMMENT)
unread_d = TopicNotification.objects.create(user=self.user, topic=topic_d,
comment=self.comment, is_active=True, action=COMMENT)
unread_e = TopicNotification.objects.create(user=self.user, topic=topic_e,
comment=self.comment, is_active=True, action=COMMENT)
self.assertEqual(len(TopicNotification.objects.filter(user=self.user, is_active=True, is_read=False)), 5)
self.assertFalse(has_topic_notifications(self.user))
开发者ID:AlienTechs,项目名称:Spirit,代码行数:28,代码来源:tests_topic_notification.py
示例4: test_profile_likes_dont_show_removed_or_private
def test_profile_likes_dont_show_removed_or_private(self):
"""
dont show private topics or removed
"""
category = utils.create_category()
category_removed = utils.create_category(is_removed=True)
subcategory = utils.create_category(parent=category_removed)
subcategory_removed = utils.create_category(parent=category, is_removed=True)
topic_a = utils.create_private_topic(user=self.user2)
topic_b = utils.create_topic(category=category, is_removed=True)
topic_c = utils.create_topic(category=category_removed)
topic_d = utils.create_topic(category=subcategory)
topic_e = utils.create_topic(category=subcategory_removed)
comment_a = utils.create_comment(user=self.user2, topic=topic_a.topic)
comment_b = utils.create_comment(user=self.user, topic=topic_b)
comment_c = utils.create_comment(user=self.user, topic=topic_c)
comment_d = utils.create_comment(user=self.user, topic=topic_d)
comment_e = utils.create_comment(user=self.user, topic=topic_e)
like_a = CommentLike.objects.create(user=self.user2, comment=comment_a)
like_b = CommentLike.objects.create(user=self.user2, comment=comment_b)
like_c = CommentLike.objects.create(user=self.user2, comment=comment_c)
like_d = CommentLike.objects.create(user=self.user2, comment=comment_d)
like_e = CommentLike.objects.create(user=self.user2, comment=comment_e)
utils.login(self)
response = self.client.get(reverse("spirit:profile-likes", kwargs={'pk': self.user2.pk,
'slug': self.user2.slug}))
self.assertQuerysetEqual(response.context['comments'], [])
开发者ID:AlienTechs,项目名称:Spirit,代码行数:28,代码来源:tests_user.py
示例5: test_category_detail_subcategory
def test_category_detail_subcategory(self):
"""
should display all topics in subcategory
"""
topic = utils.create_topic(category=self.category_1)
topic2 = utils.create_topic(category=self.subcategory_1, title="topic_subcat1")
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.subcategory_1.pk, }))
self.assertQuerysetEqual(response.context['topics'], [repr(topic2), ])
self.assertQuerysetEqual(response.context['categories'], [])
开发者ID:MGXRace,项目名称:Spirit,代码行数:9,代码来源:tests_category.py
示例6: test_category_detail_view_removed_topics
def test_category_detail_view_removed_topics(self):
"""
should not display removed topics or from other categories
"""
subcategory_removed = utils.create_subcategory(self.category_1, is_removed=True)
topic_removed = utils.create_topic(category=subcategory_removed)
topic_removed2 = utils.create_topic(category=self.category_1, is_removed=True)
topic_bad = utils.create_topic(category=self.category_2)
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk, }))
self.assertQuerysetEqual(response.context['topics'], [])
开发者ID:MGXRace,项目名称:Spirit,代码行数:11,代码来源:tests_category.py
示例7: setUp
def setUp(self):
# TODO: simple backend wont work on django +1.6 coz of a bug on haystack 2.1
#self.connections = haystack.connections
#haystack.connections = haystack.loading.ConnectionHandler(HAYSTACK_TEST)
cache.clear()
self.user = utils.create_user()
self.category = utils.create_category()
self.topic = utils.create_topic(category=self.category, user=self.user, title="spirit search test")
self.topic2 = utils.create_topic(category=self.category, user=self.user, title="foo")
call_command("rebuild_index", interactive=False)
开发者ID:AlienTechs,项目名称:Spirit,代码行数:12,代码来源:tests_search.py
示例8: test_category_detail_view_order
def test_category_detail_view_order(self):
"""
should display all topics order by pinned and last active
"""
topic_a = utils.create_topic(category=self.category_1, is_pinned=True)
topic_b = utils.create_topic(category=self.category_1)
topic_c = utils.create_topic(category=self.category_1, is_pinned=True, is_removed=True)
# show pinned first
Topic.objects.filter(pk=topic_a.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk, }))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_a, topic_b, ]))
开发者ID:MGXRace,项目名称:Spirit,代码行数:12,代码来源:tests_category.py
示例9: test_topic_active_view
def test_topic_active_view(self):
"""
topics ordered by activity
"""
category = utils.create_category()
topic_a = utils.create_topic(category=category)
topic_b = utils.create_topic(category=category, user=self.user, view_count=10)
topic_c = utils.create_topic(category=category)
Topic.objects.filter(pk=topic_a.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
Topic.objects.filter(pk=topic_c.pk).update(last_active=timezone.now() - datetime.timedelta(days=5))
response = self.client.get(reverse('spirit:topic-active'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_b, topic_c, topic_a]))
开发者ID:MGXRace,项目名称:Spirit,代码行数:14,代码来源:tests_topic.py
示例10: test_category_detail_view
def test_category_detail_view(self):
"""
should display all topics in the category and its subcategories
ordered by last active first
"""
topic = utils.create_topic(category=self.category_1)
topic2 = utils.create_topic(category=self.subcategory_1)
topic3 = utils.create_topic(category=self.category_1)
Topic.objects.filter(pk=topic.pk).update(last_active=timezone.now() - datetime.timedelta(days=10))
Topic.objects.filter(pk=topic3.pk).update(last_active=timezone.now() - datetime.timedelta(days=5))
response = self.client.get(reverse('spirit:category-detail', kwargs={'pk': self.category_1.pk, }))
self.assertQuerysetEqual(response.context['topics'], [repr(topic2), repr(topic3), repr(topic)])
开发者ID:MGXRace,项目名称:Spirit,代码行数:14,代码来源:tests_category.py
示例11: test_comment_publish_on_removed_topic_or_category
def test_comment_publish_on_removed_topic_or_category(self):
"""
should not be able to create a comment
"""
# removed category
Category.objects.all().update(is_removed=True)
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
# removed subcategory
Category.objects.all().update(is_removed=False)
subcategory = utils.create_category(parent=self.category, is_removed=True)
topic2 = utils.create_topic(subcategory)
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': topic2.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
# removed topic
Category.objects.all().update(is_removed=False)
Topic.objects.all().update(is_removed=True)
utils.login(self)
form_data = {'comment': 'foobar', }
response = self.client.post(reverse('spirit:comment-publish', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 404)
开发者ID:IronLemon,项目名称:Spirit,代码行数:33,代码来源:tests_comment.py
示例12: test_topic_active_view_dont_show_private_or_removed
def test_topic_active_view_dont_show_private_or_removed(self):
"""
dont show private topics or removed
"""
category = utils.create_category()
category_removed = utils.create_category(is_removed=True)
subcategory = utils.create_category(parent=category_removed)
subcategory_removed = utils.create_category(parent=category, is_removed=True)
topic_a = utils.create_private_topic()
topic_b = utils.create_topic(category=category, is_removed=True)
topic_c = utils.create_topic(category=category_removed)
topic_d = utils.create_topic(category=subcategory)
topic_e = utils.create_topic(category=subcategory_removed)
response = self.client.get(reverse('spirit:topic-active'))
self.assertQuerysetEqual(response.context['topics'], [])
开发者ID:MGXRace,项目名称:Spirit,代码行数:16,代码来源:tests_topic.py
示例13: test_comment_move_signal
def test_comment_move_signal(self):
"""
move comments, emit signal
"""
self._comments = []
def comment_posted_handler(sender, comment, **kwargs):
self._comments.append(comment)
comment_posted.connect(comment_posted_handler)
def comment_moved_handler(sender, comments, topic_from, **kwargs):
self._comment_count = len(comments)
self._topic_from = topic_from
comment_moved.connect(comment_moved_handler)
utils.login(self)
self.user.is_moderator = True
self.user.save()
comment = utils.create_comment(user=self.user, topic=self.topic)
comment2 = utils.create_comment(user=self.user, topic=self.topic)
to_topic = utils.create_topic(self.category)
form_data = {'topic': to_topic.pk,
'comments': [comment.pk, comment2.pk], }
response = self.client.post(reverse('spirit:comment-move', kwargs={'topic_id': self.topic.pk, }),
form_data)
self.assertEqual(response.status_code, 302)
self.assertListEqual(self._comments, [comment2, comment])
self.assertEqual(self._comment_count, 2)
self.assertEqual(repr(self._topic_from), repr(self.topic))
开发者ID:IronLemon,项目名称:Spirit,代码行数:31,代码来源:tests_comment.py
示例14: test_topic_pinned
def test_topic_pinned(self):
"""
Pinned topics
"""
topic_ = utils.create_topic(self.category, is_pinned=True)
utils.login(self)
response = self.client.get(reverse('spirit:admin-topic-pinned'))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_, ]))
开发者ID:MGXRace,项目名称:Spirit,代码行数:8,代码来源:tests_admin.py
示例15: setUp
def setUp(self):
cache.clear()
self.user = utils.create_user()
self.category = utils.create_category()
self.topic = utils.create_topic(category=self.category, user=self.user)
utils.create_comment(topic=self.topic)
utils.create_comment(topic=self.topic)
utils.create_comment(topic=self.topic)
开发者ID:IronLemon,项目名称:Spirit,代码行数:8,代码来源:tests_comment.py
示例16: setUp
def setUp(self):
cache.clear()
self.user = utils.create_user()
self.category = utils.create_category()
self.topic = utils.create_topic(category=self.category, user=self.user)
for _ in xrange(settings.ST_COMMENTS_PER_PAGE * 4): # 4 pages
utils.create_comment(user=self.user, topic=self.topic)
开发者ID:AlienTechs,项目名称:Spirit,代码行数:8,代码来源:tests_comment_bookmark.py
示例17: setUp
def setUp(self):
cache.clear()
self.user = utils.create_user()
self.topic = utils.create_topic(utils.create_category())
for _ in xrange(300):
utils.create_comment(user=self.user, topic=self.topic)
self.queryset = Comment.objects.all()
开发者ID:AlienTechs,项目名称:Spirit,代码行数:9,代码来源:tests_utils_paginator.py
示例18: test_topic_update
def test_topic_update(self):
"""
create update
"""
category = utils.create_category()
topic = utils.create_topic(category)
form_data = {'title': 'foobar', }
form = TopicForm(self.user, data=form_data, instance=topic)
self.assertEqual(form.is_valid(), True)
开发者ID:MGXRace,项目名称:Spirit,代码行数:9,代码来源:tests_topic.py
示例19: test_topic_detail_view
def test_topic_detail_view(self):
"""
should display topic
"""
utils.login(self)
category = utils.create_category()
topic = utils.create_topic(category=category)
response = self.client.get(reverse('spirit:topic-detail', kwargs={'pk': topic.pk, }))
self.assertEqual(response.context['topic'], topic)
开发者ID:MGXRace,项目名称:Spirit,代码行数:9,代码来源:tests_topic.py
示例20: test_profile_topics_order
def test_profile_topics_order(self):
"""
topics ordered by date
"""
Topic.objects.all().delete()
category = utils.create_category()
topic_a = utils.create_topic(category=category, user=self.user2)
topic_b = utils.create_topic(category=category, user=self.user2)
topic_c = utils.create_topic(category=category, user=self.user2)
Topic.objects.filter(pk=topic_a.pk).update(date=timezone.now() - datetime.timedelta(days=10))
Topic.objects.filter(pk=topic_c.pk).update(date=timezone.now() - datetime.timedelta(days=5))
utils.login(self)
response = self.client.get(reverse("spirit:profile-topics", kwargs={'pk': self.user2.pk,
'slug': self.user2.slug}))
self.assertQuerysetEqual(response.context['topics'], map(repr, [topic_b, topic_c, topic_a]))
开发者ID:AlienTechs,项目名称:Spirit,代码行数:18,代码来源:tests_user.py
注:本文中的utils.create_topic函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论