Exemplo n.º 1
0
 def testGroupHolder(self):
     gh = GroupHolder()
     ah = AvatarHolder()
     self.assert_(gh.getById("fake-group-1").containsUser(ah.getById("fake-1")))
     self.assertEqual(gh.match({"groupname": "fake-group-1"}, searchInAuthenticators=False)[0].getEmail(),
                      "*****@*****.**")
     self.assertEqual(len(gh.matchFirstLetter("f", searchInAuthenticators=False)), 2)
Exemplo n.º 2
0
 def _checkParams(self):
     AdminService._checkParams(self)
     self._pm = ParameterManager(self._params)
     gh = GroupHolder()
     groupId = self._pm.extract("groupId", pType=str, allowEmpty=False)
     self._group = gh.getById(groupId)
     if self._group == None:
         raise ServiceError("ER-G0", _("Cannot find group with id %s") % groupId)
Exemplo n.º 3
0
 def testGroupHolder(self):
     gh = GroupHolder()
     ah = AvatarHolder()
     self.assert_(
         gh.getById("fake-group-1").containsUser(ah.getById("fake-1")))
     self.assertEqual(
         gh.match({"groupname": "fake-group-1"},
                  searchInAuthenticators=False)[0].getEmail(),
         "*****@*****.**")
     self.assertEqual(
         len(gh.matchFirstLetter("f", searchInAuthenticators=False)), 2)
Exemplo n.º 4
0
Arquivo: user.py Projeto: NIIF/indico
def retrieve_principal(principal):
    """
    Retrieves principal object from a `(type, id)` tuple.

    Valid principal types are 'Avatar' and 'Group'
    """
    from MaKaC.user import AvatarHolder, GroupHolder

    ah = AvatarHolder()
    gh = GroupHolder()

    type_, id_ = principal
    try:
        return ah.getById(id_) if type_ == 'Avatar' else gh.getById(id_)
    except KeyError:
        return None
Exemplo n.º 5
0
def retrieve_principals(iterable):
    """Retrieves principal objects from `(type, id)` tuples.

    Valid principal types are 'Avatar' and 'Group'
    """
    from MaKaC.user import AvatarHolder, GroupHolder

    ah = AvatarHolder()
    gh = GroupHolder()
    principals = []
    for type_, id_ in iterable:
        if type_ == 'Avatar':
            principal = ah.getById(id_)
        else:
            principal = gh.getById(id_)
        if principal:
            principals.append(principal)
    return principals