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


Python ForumReadTrackFactory.create方法代码示例

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


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

示例1: test_can_determine_unread_forums

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def test_can_determine_unread_forums(self):
        # Setup
        def get_rendered(topics, user):
            request = self.get_request()
            request.user = user
            ForumPermissionMiddleware().process_request(request)
            t = Template(self.loadstatement + '{% get_unread_topics topics request.user as unread_topics %}')
            c = Context({'topics': topics, 'request': request})
            rendered = t.render(c)

            return c, rendered

        # Run & check
        context, rendered = get_rendered(self.forum_2.topics.all(), self.u2)
        assert rendered == ''
        assert set(context['unread_topics']) == set(self.forum_2.topics.all())

        # forum_2 topics are now read
        TopicReadTrackFactory.create(topic=self.forum_2_topic, user=self.u2)
        context, rendered = get_rendered(self.forum_2.topics.all(), self.u2)
        assert rendered == ''
        assert not len(context['unread_topics'])

        # A new post is created with a pre-existing topic track
        PostFactory.create(topic=self.forum_2_topic, poster=self.u1)
        context, rendered = get_rendered(self.forum_2.topics.all(), self.u2)
        assert rendered == ''
        assert set(context['unread_topics']) == set(self.forum_2.topics.all())

        # A new post is created with a pre-existing forum track
        ForumReadTrackFactory.create(forum=self.forum_1, user=self.u2)
        PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        context, rendered = get_rendered(self.forum_1.topics.all(), self.u2)
        assert rendered == ''
        assert set(context['unread_topics']) == set(self.forum_1.topics.all())
开发者ID:DrJackilD,项目名称:django-machina,代码行数:37,代码来源:test_tracking_tags.py

示例2: setup

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def setup(self):
        # Create a basic user
        self.user = UserFactory.create()

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.cat = create_category_forum()
        self.top_level_forum = create_forum()
        self.other_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(forum=self.top_level_forum, poster=self.user)
        self.first_post = PostFactory.create(topic=self.topic, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_reply_to_topics', self.user, self.top_level_forum)
        assign_perm('can_edit_own_posts', self.user, self.top_level_forum)
        assign_perm('can_delete_own_posts', self.user, self.top_level_forum)
        assign_perm('can_lock_topics', self.user, self.top_level_forum)
开发者ID:harish211,项目名称:django-machina,代码行数:28,代码来源:test_forms.py

示例3: setup

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(
            forum=self.top_level_forum, poster=self.user,
            status=Topic.TOPIC_LOCKED)
        self.first_post = PostFactory.create(topic=self.topic, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user, approved=False)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_approve_posts', self.user, self.top_level_forum)
开发者ID:ashwin31,项目名称:django-machina,代码行数:21,代码来源:test_views.py

示例4: setup

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def setup(self):
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()

        self.top_level_cat_1 = create_category_forum()
        self.top_level_cat_2 = create_category_forum()

        self.forum_1 = create_forum(parent=self.top_level_cat_1)
        self.forum_2 = create_forum(parent=self.top_level_cat_1)
        self.forum_2_child_1 = create_link_forum(parent=self.forum_2)
        self.forum_2_child_2 = create_forum(parent=self.forum_2)
        self.forum_3 = create_forum(parent=self.top_level_cat_1)

        self.forum_4 = create_forum(parent=self.top_level_cat_2)

        self.topic = create_topic(forum=self.forum_2, poster=self.u1)
        PostFactory.create(topic=self.topic, poster=self.u1)

        # Initially u2 read the previously created topic
        ForumReadTrackFactory.create(forum=self.forum_2, user=self.u2)
开发者ID:DrJackilD,项目名称:django-machina,代码行数:22,代码来源:test_managers.py

示例5: setup

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(
            forum=self.top_level_forum, poster=self.user,
            status=Topic.STATUS_CHOICES.topic_locked)
        self.first_post = PostFactory.create(topic=self.topic, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_approve_posts', self.user, self.top_level_forum)
开发者ID:harish211,项目名称:django-machina,代码行数:22,代码来源:test_views.py

示例6: setup

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(forum=self.top_level_forum, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Creates a poll and two options
        self.poll = TopicPollFactory.create(topic=self.topic)
        self.option_1 = TopicPollOptionFactory.create(poll=self.poll)
        self.option_2 = TopicPollOptionFactory.create(poll=self.poll)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_vote_in_polls', self.user, self.top_level_forum)
开发者ID:ellmetha,项目名称:django-machina,代码行数:24,代码来源:test_views.py

示例7: setup

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def setup(self):
        # Add some users
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.g1 = GroupFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)
        self.user.groups.add(self.g1)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Tracking handler
        self.tracks_handler = TrackingHandler()

        self.top_level_cat_1 = create_category_forum()
        self.top_level_cat_2 = create_category_forum()

        self.forum_1 = create_forum(parent=self.top_level_cat_1)
        self.forum_2 = create_forum(parent=self.top_level_cat_1)
        self.forum_2_child_1 = create_forum(parent=self.forum_2)
        self.forum_3 = create_forum(parent=self.top_level_cat_1)

        self.forum_4 = create_forum(parent=self.top_level_cat_2)

        self.topic = create_topic(forum=self.forum_2, poster=self.u1)
        PostFactory.create(topic=self.topic, poster=self.u1)

        # Initially u2 and user read the previously created topic
        ForumReadTrackFactory.create(forum=self.forum_2, user=self.u2)
        ForumReadTrackFactory.create(forum=self.forum_2, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.g1, self.top_level_cat_1)
        assign_perm('can_read_forum', self.g1, self.top_level_cat_2)
        assign_perm('can_read_forum', self.g1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_2)
        assign_perm('can_read_forum', self.g1, self.forum_2_child_1)
        assign_perm('can_read_forum', self.g1, self.forum_4)
开发者ID:squamous,项目名称:django-machina,代码行数:41,代码来源:test_views.py

示例8: setup

# 需要导入模块: from machina.test.factories import ForumReadTrackFactory [as 别名]
# 或者: from machina.test.factories.ForumReadTrackFactory import create [as 别名]
    def setup(self):
        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level forum
        self.top_level_forum = create_forum()

        # Set up a topic and some posts
        self.topic = create_topic(forum=self.top_level_forum, poster=self.user)
        self.post = PostFactory.create(topic=self.topic, poster=self.user)

        # Set up an attachment
        f = open(settings.MEDIA_ROOT + '/attachment.jpg', 'rb')
        self.attachment_file = File(f)
        self.attachment = AttachmentFactory.create(
            post=self.post, file=self.attachment_file)

        # Mark the forum as read
        ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.user, self.top_level_forum)
        assign_perm('can_download_file', self.user, self.top_level_forum)

        yield

        # teardown
        # --

        self.attachment_file.close()
        attachments = Attachment.objects.all()
        for attachment in attachments:
            try:
                attachment.file.delete()
            except:
                pass
开发者ID:ashwin31,项目名称:django-machina,代码行数:38,代码来源:test_views.py


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