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


Python UserGroup.get方法代码示例

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


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

示例1: validate_python

# 需要导入模块: from kallithea.model.db import UserGroup [as 别名]
# 或者: from kallithea.model.db.UserGroup import get [as 别名]
        def validate_python(self, value, state):
            if value in ['default']:
                msg = M(self, 'invalid_group', state)
                raise formencode.Invalid(msg, value, state,
                    error_dict=dict(users_group_name=msg)
                )
            #check if group is unique
            old_ugname = None
            if edit:
                old_id = old_data.get('users_group_id')
                old_ugname = UserGroup.get(old_id).users_group_name

            if old_ugname != value or not edit:
                is_existing_group = UserGroup.get_by_group_name(value,
                                                        case_insensitive=True)
                if is_existing_group:
                    msg = M(self, 'group_exist', state, usergroup=value)
                    raise formencode.Invalid(msg, value, state,
                        error_dict=dict(users_group_name=msg)
                    )

            if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
                msg = M(self, 'invalid_usergroup_name', state)
                raise formencode.Invalid(msg, value, state,
                    error_dict=dict(users_group_name=msg)
                )
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: test_create_and_remove

# 需要导入模块: from kallithea.model.db import UserGroup [as 别名]
# 或者: from kallithea.model.db.UserGroup import get [as 别名]
    def test_create_and_remove(self):
        usr = UserModel().create_or_update(username=u'test_user',
                                           password=u'qweqwe',
                                           email=u'[email protected]',
                                           firstname=u'u1', lastname=u'u1')
        Session().commit()
        assert User.get_by_username(u'test_user') == usr
        assert User.get_by_username(u'test_USER', case_insensitive=True) == usr
        # User.get_by_username without explicit request for case insensitivty
        # will use database case sensitivity. The following will thus return
        # None on for example PostgreSQL but find test_user on MySQL - we are
        # fine with leaving that as undefined as long as it doesn't crash.
        User.get_by_username(u'test_USER', case_insensitive=False)

        # make user group
        user_group = fixture.create_user_group(u'some_example_group')
        Session().commit()

        UserGroupModel().add_user_to_group(user_group, usr)
        Session().commit()

        assert UserGroup.get(user_group.users_group_id) == user_group
        assert UserGroupMember.query().count() == 1
        UserModel().delete(usr.user_id)
        Session().commit()

        assert UserGroupMember.query().all() == []
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:29,代码来源:test_users.py

示例3: test_create_and_remove

# 需要导入模块: from kallithea.model.db import UserGroup [as 别名]
# 或者: from kallithea.model.db.UserGroup import get [as 别名]
    def test_create_and_remove(self):
        usr = UserModel().create_or_update(username=u'test_user',
                                           password=u'qweqwe',
                                           email=u'[email protected]',
                                           firstname=u'u1', lastname=u'u1')
        Session().commit()
        self.assertEqual(User.get_by_username(u'test_user'), usr)

        # make user group
        user_group = fixture.create_user_group('some_example_group')
        Session().commit()

        UserGroupModel().add_user_to_group(user_group, usr)
        Session().commit()

        self.assertEqual(UserGroup.get(user_group.users_group_id), user_group)
        self.assertEqual(UserGroupMember.query().count(), 1)
        UserModel().delete(usr.user_id)
        Session().commit()

        self.assertEqual(UserGroupMember.query().all(), [])
开发者ID:msabramo,项目名称:kallithea,代码行数:23,代码来源:test_users.py

示例4: get_user_group_slug

# 需要导入模块: from kallithea.model.db import UserGroup [as 别名]
# 或者: from kallithea.model.db.UserGroup import get [as 别名]
def get_user_group_slug(request):
    _group = request.environ['pylons.routes_dict'].get('id')
    _group = UserGroup.get(_group)
    if _group:
        return _group.users_group_name
    return None
开发者ID:,项目名称:,代码行数:8,代码来源:

示例5: get

# 需要导入模块: from kallithea.model.db import UserGroup [as 别名]
# 或者: from kallithea.model.db.UserGroup import get [as 别名]
 def get(self, user_group_id, cache=False):
     return UserGroup.get(user_group_id)
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:4,代码来源:user_group.py


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