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


Python Request.in_conflict_ou方法代码示例

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


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

示例1: get_conflict

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import in_conflict_ou [as 别名]
    def get_conflict(self, requests):
        """ Returns requests conflicts """
        conflicts = {}
        for req in requests:
            req.conflict = [req2.summary for req2 in
                            Request.in_conflict_ou(self.session, req)]
            if req.conflict:
                req.conflict = {'': req.conflict}
                if req.id not in conflicts:
                    conflicts[req.id] = {}
                conflicts[req.id][''] = '\n'.join(req.conflict[''])

        return conflicts
开发者ID:doyousoft,项目名称:pyvac,代码行数:15,代码来源:request.py

示例2: test_in_conflict_ou

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import in_conflict_ou [as 别名]
 def test_in_conflict_ou(self):
     from pyvac.models import Request
     req = Request.by_id(self.session, 1)
     self.assertIsInstance(req, Request)
     nb_conflicts = Request.in_conflict_ou(self.session, req, count=True)
     self.assertEqual(nb_conflicts, 1)
开发者ID:doyousoft,项目名称:pyvac,代码行数:8,代码来源:test_models.py

示例3: render

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import in_conflict_ou [as 别名]
    def render(self):

        req_list = {'requests': [], 'conflicts': {}}
        requests = []
        if self.user.is_admin:
            country = self.user.country
            requests = Request.all_for_admin_per_country(self.session,
                                                         country)
            # check if admin user is also a manager, in this case merge all
            # requests
            requests_manager = Request.by_manager(self.session, self.user)
            # avoid duplicate entries
            req_to_add = [req for req in requests_manager
                          if req not in requests]
            requests.extend(req_to_add)
        elif self.user.is_super:
            requests = Request.by_manager(self.session, self.user)

        if requests:
            conflicts = {}

            settings = self.request.registry.settings
            use_ldap = False
            if 'pyvac.use_ldap' in settings:
                use_ldap = asbool(settings.get('pyvac.use_ldap'))

            if use_ldap:
                ldap = LdapCache()
                users_teams = {}
                for team, members in ldap.list_teams().iteritems():
                    for member in members:
                        users_teams.setdefault(member, []).append(team)

                for req in requests:
                    user_teams = users_teams.get(req.user.dn, [])
                    matched = {}
                    # for all requests in conflict with current req
                    for req2 in Request.in_conflict(self.session, req):
                        # if we have some match between request teams
                        # and conflicting request teams
                        conflict_teams = users_teams.get(req2.user.dn, [])
                        common_set = set(conflict_teams) & set(user_teams)
                        if common_set:
                            for team in common_set:
                                if team not in matched:
                                    matched[team] = []
                                matched[team].append(req2.summary)

                    req.conflict = matched
                    if req.conflict:
                        for team in req.conflict:
                            if req.id not in conflicts:
                                conflicts[req.id] = {}
                            conflicts[req.id][team] = ('\n'.join([team] +
                                                       req.conflict[team]))
            else:
                for req in requests:
                    req.conflict = [req2.summary for req2 in
                                    Request.in_conflict_ou(self.session, req)]
                    if req.conflict:
                        conflicts[req.id] = '\n'.join(req.conflict)

            req_list['requests'] = requests
            req_list['conflicts'] = conflicts

        # always add our requests
        for req in Request.by_user(self.session, self.user):
            if req not in req_list['requests']:
                req_list['requests'].append(req)

        return req_list
开发者ID:baloo,项目名称:pyvac,代码行数:73,代码来源:request.py


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