Exemplo n.º 1
0
    def test_inlines(self):
        user = self._create_user("randomuser",
                                 is_staff=True,
                                 add_default_permissions=True)
        current_user = self.get_superuser()
        page = create_page("page_b",
                           "nav_playground.html",
                           "en",
                           created_by=current_user)
        data = {
            'page': page.pk,
            'grant_on': ACCESS_PAGE_AND_CHILDREN,
            'can_view': 'True',
            'user': user.pk,
            'group': '',
        }
        form = ViewRestrictionInlineAdminForm(data=data, files=None)
        self.assertTrue(form.is_valid())
        data = {
            'page': page.pk,
            'grant_on': ACCESS_PAGE_AND_CHILDREN,
            'can_view': 'True',
            'group': ''
        }
        form = GlobalPagePermissionAdminForm(data=data, files=None)
        self.assertFalse(form.is_valid())

        data = {
            'page': page.pk,
            'grant_on': ACCESS_PAGE_AND_CHILDREN,
            'can_view': 'True',
            'user': user.pk,
        }
        form = GlobalPagePermissionAdminForm(data=data, files=None)
        self.assertTrue(form.is_valid())
Exemplo n.º 2
0
    def test_inlines(self):
        user = self._create_user("randomuser", is_staff=True, add_default_permissions=True)
        page = create_page("page_b", "nav_playground.html", "en",
                           created_by=self.get_superuser())
        data = {
            'page': page.pk,
            'grant_on': ACCESS_PAGE_AND_CHILDREN,
            'can_view': 'True',
            'user': '',
            'group': '',
        }
        set_current_user(self.get_superuser())
        form = ViewRestrictionInlineAdminForm(data=data, files=None)
        self.assertTrue(form.is_valid())
        data = {
            'page': page.pk,
            'grant_on': ACCESS_PAGE_AND_CHILDREN,
            'can_view': 'True',
            'user': '',
            'group': ''
        }
        form = GlobalPagePermissionAdminForm(data=data, files=None)
        self.assertFalse(form.is_valid())

        data = {
            'page': page.pk,
            'grant_on': ACCESS_PAGE_AND_CHILDREN,
            'can_view': 'True',
            'user': user.pk,

        }
        form = GlobalPagePermissionAdminForm(data=data, files=None)
        self.assertTrue(form.is_valid())