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


Python Group.save方法代码示例

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


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

示例1: test_edit_buttons

# 需要导入模块: from access.models import Group [as 别名]
# 或者: from access.models.Group import save [as 别名]
    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,代码行数:37,代码来源:test_views.py

示例2: test_password_empty

# 需要导入模块: from access.models import Group [as 别名]
# 或者: from access.models.Group import save [as 别名]
 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,代码行数:9,代码来源:test_views.py

示例3: test_edit_buttons

# 需要导入模块: from access.models import Group [as 别名]
# 或者: from access.models.Group import save [as 别名]
    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,代码行数:30,代码来源:test_views.py

示例4: test_my_account_menu

# 需要导入模块: from access.models import Group [as 别名]
# 或者: from access.models.Group import save [as 别名]
    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,代码行数:29,代码来源:test_views.py

示例5: test_password_empty

# 需要导入模块: from access.models import Group [as 别名]
# 或者: from access.models.Group import save [as 别名]
 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,代码行数:10,代码来源:test_views.py


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