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


Python User.by_role方法代码示例

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


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

示例1: update_view

# 需要导入模块: from pyvac.models import User [as 别名]
# 或者: from pyvac.models.User import by_role [as 别名]
    def update_view(self, model, view):
        settings = self.request.registry.settings
        ldap = False
        if 'pyvac.use_ldap' in settings:
            ldap = asbool(settings.get('pyvac.use_ldap'))

        if view['errors']:
            self.request.session.flash('error;%s' % ','.join(view['errors']))

        view['groups'] = Group.all(self.session, order_by=Group.name)
        view['managers'] = User.by_role(self.session, 'manager')

        if ldap:
            ldap = LdapCache()
            login = self.get_model().login
            if login:
                view['ldap_user'] = ldap.search_user_by_login(login)
            else:
                view['ldap_user'] = {}
            view['managers'] = ldap.list_manager()
            view['units'] = ldap.list_ou()
            view['countries'] = Countries.all(self.session,
                                              order_by=Countries.name)
            # generate a random password for the user, he must change it later
            password = randomstring()
            log.info('temporary password generated: %s' % password)
            view['password'] = password
            view['view_name'] = self.__class__.__name__.lower()
            view['myself'] = (self.user.id == self.get_model().id)
开发者ID:grigouze,项目名称:pyvac,代码行数:31,代码来源:account.py

示例2: update_view

# 需要导入模块: from pyvac.models import User [as 别名]
# 或者: from pyvac.models.User import by_role [as 别名]
    def update_view(self, model, view):
        settings = self.request.registry.settings
        ldap = False
        if 'pyvac.use_ldap' in settings:
            ldap = asbool(settings.get('pyvac.use_ldap'))

        if view['errors']:
            self.request.session.flash('error;%s' % ','.join(view['errors']))

        view['groups'] = Group.all(self.session, order_by=Group.name)
        view['managers'] = User.by_role(self.session, 'manager')

        if ldap:
            ldap = LdapCache()
            login = self.get_model().login
            view['ldap_user'] = {}
            if login:
                try:
                    view['ldap_user'] = ldap.search_user_by_login(login)
                except UnknownLdapUser:
                    msg = 'Unknown ldap user %s' % login
                    self.request.session.flash('error;%s' % msg)

            view['managers'] = ldap.list_manager()
            view['units'] = ldap.list_ou()

            view['teams'] = ldap.list_teams()
            uteams = {}
            for team, members in view['teams'].iteritems():
                for member in members:
                    uteams.setdefault(member, []).append(team)
            view['user_teams'] = uteams.get(view['ldap_user'].get('dn'), [])

            view['countries'] = Countries.all(self.session,
                                              order_by=Countries.name)
            # generate a random password for the user, he must change it later
            password = randomstring()
            log.debug('temporary password generated: %s' % password)
            view['password'] = password
            view['view_name'] = self.__class__.__name__.lower()
            view['myself'] = (self.user.id == self.get_model().id)
开发者ID:baloo,项目名称:pyvac,代码行数:43,代码来源:account.py

示例3: test_by_role

# 需要导入模块: from pyvac.models import User [as 别名]
# 或者: from pyvac.models.User import by_role [as 别名]
 def test_by_role(self):
     from pyvac.models import User
     admins = User.by_role(self.session, 'admin')
     self.assertEqual(len(admins), 1)
开发者ID:doyousoft,项目名称:pyvac,代码行数:6,代码来源:test_models.py


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