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


Python factories.GroupFactory类代码示例

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


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

示例1: setup

    def setup(self):
        self.loadstatement = '{% load forum_permission_tags %}'
        self.request_factory = RequestFactory()

        self.g1 = GroupFactory.create()
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)
        self.moderators = GroupFactory.create()
        self.moderator = UserFactory.create()
        self.moderator.groups.add(self.moderators)
        self.superuser = UserFactory.create(is_superuser=True)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)

        # Set up some topics and posts
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_2_topic = create_topic(forum=self.forum_2, poster=self.u2)
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_2_topic, poster=self.u2)
开发者ID:harish211,项目名称:django-machina,代码行数:29,代码来源:test_permission_tags.py

示例2: test_knows_that_granted_permissions_should_take_precedence_over_the_same_non_granted_permissions

 def test_knows_that_granted_permissions_should_take_precedence_over_the_same_non_granted_permissions(self):  # noqa: E501
     # Setup
     user = UserFactory.create()
     group_all_users = GroupFactory.create()
     group_specific_access = GroupFactory.create()
     user.groups.add(group_all_users)
     user.groups.add(group_specific_access)
     assign_perm('can_read_forum', group_all_users, None)  # global permission
     assign_perm('can_read_forum', group_all_users, self.forum, has_perm=False)
     assign_perm('can_read_forum', group_specific_access, self.forum, has_perm=True)
     checker = ForumPermissionChecker(user)
     # Run & check
     assert checker.has_perm('can_read_forum', self.forum)
开发者ID:ellmetha,项目名称:django-machina,代码行数:13,代码来源:test_checker.py

示例3: setup

    def setup(self):
        # Add some users
        self.u1 = UserFactory.create()
        self.g1 = GroupFactory.create()
        self.u1.groups.add(self.g1)
        self.user.groups.add(self.g1)

        # Permission handler
        self.perm_handler = PermissionHandler()

        self.top_level_cat_1 = 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_3 = create_forum(parent=self.top_level_cat_1)

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

        self.topic_2 = create_topic(forum=self.forum_1, poster=self.user)
        PostFactory.create(topic=self.topic_2, poster=self.user)
        PostFactory.create(topic=self.topic_2, poster=self.u1)

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

        self.topic_4 = create_topic(forum=self.forum_2, poster=self.user)
        PostFactory.create(topic=self.topic_4, poster=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.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_2)
开发者ID:squamous,项目名称:django-machina,代码行数:34,代码来源:test_views.py

示例4: setUp

    def setUp(self):
        self.loadstatement = '{% load forum_tracking_tags %}'
        self.request_factory = RequestFactory()

        # Tracking handler
        self.tracks_handler = TrackingHandler()

        self.g1 = GroupFactory.create()
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)

        # Set up some topics and posts
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_2_topic = create_topic(forum=self.forum_2, poster=self.u1)
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_2_topic, poster=self.u1)

        # Assign some permissions
        assign_perm('can_see_forum', self.g1, self.top_level_cat)
        assign_perm('can_read_forum', self.g1, self.top_level_cat)
        assign_perm('can_see_forum', self.g1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_1)
        assign_perm('can_see_forum', self.g1, self.forum_2)
        assign_perm('can_read_forum', self.g1, self.forum_2)
开发者ID:DrJackilD,项目名称:django-machina,代码行数:33,代码来源:test_tracking_tags.py

示例5: setup

    def setup(self):
        self.u1 = UserFactory.create()
        self.g1 = GroupFactory.create()
        self.u1.groups.add(self.g1)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)
        self.forum_3 = create_link_forum(parent=self.top_level_cat)

        # Set up a top-level forum link
        self.top_level_link = create_link_forum()

        # Set up some topics
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_3_topic = create_topic(forum=self.forum_3, poster=self.u1)
        self.forum_3_topic_2 = create_topic(
            forum=self.forum_3, poster=self.u1, status=Topic.TOPIC_LOCKED)

        # Set up some posts
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_3_topic, poster=self.u1)

        # Assign some permissions
        assign_perm('can_see_forum', self.u1, self.top_level_cat)
        assign_perm('can_see_forum', self.u1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_3)
开发者ID:swcheon,项目名称:django-machina,代码行数:33,代码来源:test_handler.py

示例6: setup

    def setup(self):
        self.loadstatement = '{% load forum_polls_tags %}'
        self.request_factory = RequestFactory()

        self.g1 = GroupFactory.create()
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)
        self.moderators = GroupFactory.create()
        self.moderator = UserFactory.create()
        self.moderator.groups.add(self.moderators)
        self.superuser = UserFactory.create(is_superuser=True)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)

        # Set up some topics and posts
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_2_topic = create_topic(forum=self.forum_2, poster=self.u2)
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_2_topic, poster=self.u2)
        self.poll_1 = TopicPollFactory.create(topic=self.forum_1_topic)
        self.poll_2 = TopicPollFactory.create(topic=self.forum_2_topic)

        # Assign some permissions
        assign_perm('can_see_forum', self.g1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_1)
        assign_perm('can_edit_own_posts', self.g1, self.forum_1)
        assign_perm('can_delete_own_posts', self.g1, self.forum_1)
        assign_perm('can_reply_to_topics', self.g1, self.forum_1)
        assign_perm('can_see_forum', self.moderators, self.forum_1)
        assign_perm('can_read_forum', self.moderators, self.forum_1)
        assign_perm('can_edit_own_posts', self.moderators, self.forum_1)
        assign_perm('can_delete_own_posts', self.moderators, self.forum_1)
        assign_perm('can_edit_posts', self.moderators, self.forum_1)
        assign_perm('can_delete_posts', self.moderators, self.forum_1)
        assign_perm('can_vote_in_polls', self.g1, self.forum_1)
开发者ID:ellmetha,项目名称:django-machina,代码行数:45,代码来源:test_polls_tags.py

示例7: test_knows_that_user_permissions_take_precedence_over_group_permissions

 def test_knows_that_user_permissions_take_precedence_over_group_permissions(self):
     # Setup
     user = UserFactory.create()
     group = GroupFactory.create()
     user.groups.add(group)
     assign_perm('can_read_forum', user, self.forum, has_perm=False)
     assign_perm('can_read_forum', group, self.forum, has_perm=True)
     checker = ForumPermissionChecker(user)
     # Run & check
     assert not checker.has_perm('can_read_forum', self.forum)
开发者ID:ellmetha,项目名称:django-machina,代码行数:10,代码来源:test_checker.py

示例8: test_editpermission_index_view_can_redirect_to_group_permissions_form

 def test_editpermission_index_view_can_redirect_to_group_permissions_form(self):
     # Setup
     group = GroupFactory.create()
     model = self.model
     raw_url = 'admin:{}_{}_editpermission_index'.format(model._meta.app_label, self._get_module_name(model._meta))
     # Run
     url = reverse(raw_url, kwargs={'forum_id': self.top_level_cat.id})
     response = self.client.post(url, {'group': group.id}, follow=True)
     # Check
     editpermissions_group_raw_url = 'admin:{}_{}_editpermission_group'.format(
         model._meta.app_label, self._get_module_name(model._meta))
     editpermissions_group_url = reverse(editpermissions_group_raw_url, kwargs={
         'forum_id': self.top_level_cat.id, 'group_id': self.user.id})
     assert len(response.redirect_chain)
     last_url, status_code = response.redirect_chain[-1]
     assert editpermissions_group_url in last_url
开发者ID:squamous,项目名称:django-machina,代码行数:16,代码来源:test_forum.py

示例9: test_editpermission_index_view_can_copy_permissions_from_another_forum

    def test_editpermission_index_view_can_copy_permissions_from_another_forum(self):
        # Setup
        group = GroupFactory.create()
        model = self.model

        UserForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_see_forum'),
            forum=self.sub_forum_1,
            user=self.user, has_perm=False)
        UserForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_read_forum'),
            forum=self.sub_forum_1,
            user=self.user, has_perm=True)
        UserForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_start_new_topics'),
            forum=self.sub_forum_1,
            user=self.user, has_perm=False)
        GroupForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_start_new_topics'),
            forum=self.sub_forum_1,
            group=group, has_perm=False)

        raw_url = 'admin:{}_{}_editpermission_index'.format(
            model._meta.app_label, self._get_module_name(model._meta))
        # Run
        url = reverse(raw_url, kwargs={'forum_id': self.top_level_cat.id})
        response = self.client.post(url, {'forum': self.sub_forum_1.id})
        # Check
        assert response.status_code == 200
        assert UserForumPermission.objects.filter(
            permission__codename='can_see_forum', forum=self.top_level_cat,
            user=self.user, has_perm=False).exists()
        assert UserForumPermission.objects.filter(
            permission__codename='can_read_forum', forum=self.top_level_cat,
            user=self.user, has_perm=True).exists()
        assert UserForumPermission.objects.filter(
            permission__codename='can_start_new_topics', forum=self.top_level_cat,
            user=self.user, has_perm=False).exists()
        assert GroupForumPermission.objects.filter(
            permission__codename='can_start_new_topics', forum=self.top_level_cat,
            group=group, has_perm=False).exists()
开发者ID:ashwin31,项目名称:django-machina,代码行数:41,代码来源:test_forum.py

示例10: test_editpermission_form_can_update_group_permissions

 def test_editpermission_form_can_update_group_permissions(self):
     # Setup
     group = GroupFactory.create()
     model = self.model
     raw_url = 'admin:{}_{}_editpermission_group'.format(model._meta.app_label, self._get_module_name(model._meta))
     post_data = {
         'can_see_forum': 'granted',
         'can_read_forum': 'not-granted',
         'can_start_new_topics': 'not-set',
         'can_reply_to_topics': 'not-set',
         'can_post_announcements': 'not-set',
         'can_post_stickies': 'not-set',
         'can_delete_own_posts': 'not-set',
         'can_edit_own_posts': 'not-set',
         'can_post_without_approval': 'not-set',
         'can_create_polls': 'not-set',
         'can_vote_in_polls': 'not-set',
         'can_attach_file': 'not-set',
         'can_download_file': 'not-set',
         'can_lock_topics': 'not-set',
         'can_edit_posts': 'not-set',
         'can_delete_posts': 'not-set',
         'can_move_posts': 'not-set',
         'can_approve_posts': 'not-set',
     }
     # Run
     url = reverse(raw_url, kwargs={
         'forum_id': self.top_level_cat.id, 'group_id': group.id})
     response = self.client.post(url, post_data)
     # Check
     assert response.status_code == 200
     granted_perm = GroupForumPermission.objects.filter(
         permission__codename='can_see_forum', has_perm=True,
         group=group, forum=self.top_level_cat)
     assert granted_perm.exists()
     not_granted_perm = GroupForumPermission.objects.filter(
         permission__codename='can_read_forum', has_perm=False,
         group=group, forum=self.top_level_cat)
     assert not_granted_perm.exists()
开发者ID:harish211,项目名称:django-machina,代码行数:39,代码来源:test_forum.py


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