當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Group類代碼示例

本文整理匯總了Python中access.models.Group的典型用法代碼示例。如果您正苦於以下問題:Python Group類的具體用法?Python Group怎麽用?Python Group使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Group類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_edit_buttons

    def test_edit_buttons(self):
        """Ensure admin/user edit buttons are shown."""

        def get_links(id):
            """Grab profile, return edit links."""
            url = reverse("users.profile", args=[id])
            r = self.client.get(url)
            return pq(r.content)("#profile-actions a")

        # Anonymous user.
        links = get_links(self.user.id)
        eq_(links.length, 1)
        eq_(links.eq(0).attr("href"), reverse("users.abuse", args=[self.user.id]))

        # Non-admin, someone else's profile.
        self.client.login(username="[email protected]", password="password")
        links = get_links(9945)
        eq_(links.length, 1)
        eq_(links.eq(0).attr("href"), reverse("users.abuse", args=[9945]))

        # Non-admin, own profile.
        links = get_links(self.user.id)
        eq_(links.length, 1)
        eq_(links.eq(0).attr("href"), reverse("users.edit"))

        # Admin, someone else's profile.
        admingroup = Group(rules="Users:Edit")
        admingroup.save()
        GroupUser.objects.create(group=admingroup, user=self.user)
        cache.clear()

        # Admin, own profile.
        links = get_links(self.user.id)
        eq_(links.length, 2)
        eq_(links.eq(0).attr("href"), reverse("users.edit"))
開發者ID:thefourtheye,項目名稱:olympia,代碼行數:35,代碼來源:test_views.py

示例2: test_password_empty

 def test_password_empty(self):
     admingroup = Group(rules="Users:Edit")
     admingroup.save()
     GroupUser.objects.create(group=admingroup, user=self.user)
     homepage = {"username": "jbalogh", "email": "[email protected]", "homepage": "http://cbc.ca", "lang": "en-US"}
     res = self.client.post(self.url, homepage)
     eq_(res.status_code, 302)
開發者ID:thefourtheye,項目名稱:olympia,代碼行數:7,代碼來源:test_views.py

示例3: test_edit_buttons

    def test_edit_buttons(self):
        """Ensure admin/user edit buttons are shown."""

        def get_links(id):
            """Grab profile, return edit links."""
            url = reverse('users.profile', args=[id])
            r = self.client.get(url)
            return PyQuery(r.content)('p.editprofile a')

        # Anonymous user.
        links = get_links(self.user.id)
        eq_(links.length, 0)

        # Non-admin, someone else's profile.
        self.client.login(username='[email protected]', password='foo')
        links = get_links(9945)
        eq_(links.length, 0)

        # Non-admin, own profile.
        links = get_links(self.user.id)
        eq_(links.length, 1)
        eq_(links.eq(0).attr('href'), reverse('users.edit'))

        # Admin, someone else's profile.
        admingroup = Group(rules='Admin:EditAnyUser')
        admingroup.save()
        GroupUser.objects.create(group=admingroup, user=self.user_profile)
        cache.clear()
開發者ID:fligtar,項目名稱:zamboni,代碼行數:28,代碼來源:test_views.py

示例4: test_my_account_menu

    def test_my_account_menu(self):
        def get_homepage():
            response = self.client.get('/', follow=True)
            return PyQuery(response.content)

        # Logged out
        doc = get_homepage()
        eq_(doc('#aux-nav .account').length, 0)
        eq_(doc('#aux-nav .tools').length, 0)

        # Logged in, regular user = one tools link
        self.client.login(username='[email protected]', password='password')
        doc = get_homepage()
        eq_(doc('#aux-nav .account').length, 1)
        eq_(doc('#aux-nav ul.tools').length, 0)
        eq_(doc('#aux-nav p.tools').length, 1)

        # Logged in, admin = multiple links
        admingroup = Group(rules='Admin:*')
        admingroup.save()
        GroupUser.objects.create(group=admingroup, user_id=4043307)
        cache.clear()

        doc = get_homepage()
        eq_(doc('#aux-nav .account').length, 1)
        eq_(doc('#aux-nav ul.tools').length, 1)
        eq_(doc('#aux-nav p.tools').length, 0)
開發者ID:jaliste,項目名稱:zamboni,代碼行數:27,代碼來源:test_views.py

示例5: test_password_empty

 def test_password_empty(self):
     admingroup = Group(rules='Users:Edit')
     admingroup.save()
     GroupUser.objects.create(group=admingroup, user=self.user)
     homepage = {'username': 'jbalogh', 'email': '[email protected]',
                 'homepage': 'http://cbc.ca'}
     res = self.client.post(self.url, homepage)
     eq_(res.status_code, 302)
開發者ID:dimonov,項目名稱:zamboni,代碼行數:8,代碼來源:test_views.py


注:本文中的access.models.Group類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。