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)
def testIdentities(self): ah = AvatarHolder() for i in xrange(1, 3): self.assertEqual( self._authMgr.getAvatar(LoginInfo("fake-%d" % i, "fake-%d" % i)), ah.getById("fake-%d" % i))
def _getAnswer(self): ah = AvatarHolder() for user in self._userList: convener = SessionChair() convener.setDataFromAvatar(ah.getById(user["id"])) self._session.addConvener(convener) return self._getConvenerList()
def _getAnswer(self): for user in self._userList: if user["_type"] == "Avatar": # new speaker ah = AvatarHolder() av = ah.getById(user["id"]) if av is None: raise NoReportError( _("The user with email %s that you are adding does not exist anymore in the database" ) % user["email"]) part = self._newParticipant(av) elif user[ "_type"] == "ContributionParticipation": # adding existing author to speaker part = self._contribution.getAuthorById(user["id"]) self._contribution.addSpeaker(part) if self._submissionRights and part: self._contribution.grantSubmission(part) if self._kindOfList == "prAuthor": return self._getParticipantsList( self._contribution.getPrimaryAuthorList()) elif self._kindOfList == "coAuthor": return self._getParticipantsList( self._contribution.getCoAuthorList()) elif self._kindOfList == "speaker": return self._getParticipantsList( self._contribution.getSpeakerList()) else: raise ServiceError("ERR-UK0", _("Invalid kind of list of users."))
def _getAnswer(self): ah = AvatarHolder() for user in self._userList: spk = conference.SubContribParticipation() spk.setDataFromAvatar(ah.getById(user["id"])) self._subContrib.newSpeaker(spk) return fossilize(self._subContrib.getSpeakerList(), ISubContribParticipationFullFossil)
def _checkParams(self): ConferenceModifBase._checkParams(self) pm = ParameterManager(self._params) ah = AvatarHolder() userId = pm.extract("userId", pType=str, allowEmpty=False) self._user = ah.getById(userId) if self._user == None: raise ServiceError("ERR-U0", _("User '%s' does not exist.") % userId)
def _checkParams(self): AdminService._checkParams(self) pm = ParameterManager(self._params) av = AvatarHolder() userId = pm.extract("userId", pType=str, allowEmpty=False) self._user = av.getById(userId) if self._user == None: raise ServiceError("ER-U0", _("Cannot find user with id %s") % userId)
def testAvatarHolder(self): """ Test Avatar Holder """ ah = AvatarHolder() self.assertEqual(ah.getById("fake-1").getName(), "fake-1") self.assertEqual(ah.match({"name": "fake-1"}, searchInAuthenticators=False)[0].getEmail(), "*****@*****.**") self.assertEqual(len(ah.matchFirstLetter("name", "f", searchInAuthenticators=False)), 2)
def _getAnswer(self): ah = AvatarHolder() for user in self._userList: if user["id"] != None: self._conf.getAbstractMgr().addAuthorizedSubmitter(ah.getById(user["id"])) else: raise ServiceError("ERR-U0", _("User does not exist.")) return fossilize(self._conf.getAbstractMgr().getAuthorizedSubmitterList())
def _checkParams(self): self._pm = ParameterManager(self._params) userId = self._pm.extract("userId", None) if userId is not None: ah = AvatarHolder() self._target = ah.getById(userId) else: raise ServiceError("ERR-U5", _("User id not specified"))
def _checkParams(self): AdminService._checkParams(self) self._pm = ParameterManager(self._params) userId = self._pm.extract("userId", pType=str, allowEmpty=True) if userId is not None: ah = AvatarHolder() self._avatar = ah.getById(userId) else: self._avatar = self._aw.getUser()
def _getAnswer(self): ah = AvatarHolder() convener = SessionChair() convener.setDataFromAvatar(ah.getById(self._chairId)) self._session.addConvener(convener) # get both list for the result self._kindOfList = "manager" managerResult = self._getSessionChairList() self._kindOfList = "coordinator" coordinatorResult = self._getSessionChairList() return [managerResult, coordinatorResult]
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)
def _checkParams(self): self._pm = ParameterManager(self._params) userId = self._pm.extract("userId", None) if userId is not None: ah = AvatarHolder() self._user = self._avatar = self._target = ah.getById(userId) else: raise ServiceError("ERR-U5", _("User id not specified")) self._dataType = self._pm.extract("dataType", pType=str, allowEmpty=False) if self._dataType not in self._dataTypes: raise ServiceError("ERR-U7", _("Data argument is not valid"))
def validate_principals(self, field): for item in field.data: try: type_ = item['_type'] id_ = item['id'] except Exception as e: raise ValidationError('Invalid principal data: {}'.format(e)) if type_ not in ('Avatar', 'Group', 'LDAPGroup'): raise ValidationError('Invalid principal data: type={}'.format(type_)) holder = AvatarHolder() if type_ == 'Avatar' else GroupHolder() if not holder.getById(id_): raise ValidationError('Invalid principal: {}:{}'.format(type_, id_))
def _getAnswer(self): ah = AvatarHolder() convEmail = ah.getById(self._chairId).getEmail() for convener in self._session.getConvenerList(): if convEmail == convener.getEmail(): self._session.removeConvener(convener) # get both list for the result self._kindOfList = "manager" managerResult = self._getSessionChairList() self._kindOfList = "coordinator" coordinatorResult = self._getSessionChairList() return [managerResult, coordinatorResult]
def _getAnswer(self): ah = AvatarHolder() av = ah.getById(self._submitterId) participant = self._getParticipantByEmail(av.getEmail()) if self._kindOfList == "prAuthor": self._contribution.removePrimaryAuthor(participant, removeSpeaker=0) elif self._kindOfList == "coAuthor": self._contribution.removeCoAuthor(participant, removeSpeaker=0) elif self._kindOfList == "speaker": self._contribution.removeSpeaker(participant) return self._getSubmittersList()
def validate_principals(self, field): for item in field.data: try: type_ = item["_type"] id_ = item["id"] except Exception as e: raise ValidationError("Invalid principal data: {}".format(e)) if type_ not in ("Avatar", "Group", "LDAPGroup"): raise ValidationError("Invalid principal data: type={}".format(type_)) holder = AvatarHolder() if type_ == "Avatar" else GroupHolder() if not holder.getById(id_): raise ValidationError("Invalid principal: {}:{}".format(type_, id_))
def testAvatarHolder(self): """ Test Avatar Holder """ ah = AvatarHolder() self.assertEqual(ah.getById("fake-1").getName(), "fake-1") self.assertEqual( ah.match({"name": "fake-1"}, searchInAuthenticators=False)[0].getEmail(), "*****@*****.**") self.assertEqual( len(ah.matchFirstLetter("name", "f", searchInAuthenticators=False)), 2)
def validate_principals(self, field): for item in field.data: try: type_ = item['_type'] id_ = item['id'] except Exception as e: raise ValidationError('Invalid principal data: {}'.format(e)) if type_ not in ('Avatar', 'Group', 'LDAPGroup'): raise ValidationError( 'Invalid principal data: type={}'.format(type_)) holder = AvatarHolder() if type_ == 'Avatar' else GroupHolder() if not holder.getById(id_): raise ValidationError('Invalid principal: {}:{}'.format( type_, id_))
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
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
def _getAnswer(self): for user in self._userList: if user["_type"] == "Avatar": # new speaker ah = AvatarHolder() av = ah.getById(user["id"]) part = self._newParticipant(av) elif user["_type"] == "ContributionParticipation": # adding existing author to speaker part = self._contribution.getAuthorById(user["id"]) self._contribution.addSpeaker(part) if self._submissionRights and part: self._contribution.grantSubmission(part) if self._kindOfList == "prAuthor": return self._getParticipantsList(self._contribution.getPrimaryAuthorList()) elif self._kindOfList == "coAuthor": return self._getParticipantsList(self._contribution.getCoAuthorList()) elif self._kindOfList == "speaker": return self._getParticipantsList(self._contribution.getSpeakerList()) else: raise ServiceError("ERR-UK0", _("Invalid kind of list of users."))
def _getAnswer(self): for user in self._userList: if user["_type"] == "Avatar": # new speaker ah = AvatarHolder() av = ah.getById(user["id"]) if av is None: raise NoReportError(_("The user with email %s that you are adding does not exist anymore in the database") % user["email"]) part = self._newParticipant(av) elif user["_type"] == "ContributionParticipation": # adding existing author to speaker part = self._contribution.getAuthorById(user["id"]) self._contribution.addSpeaker(part) if self._submissionRights and part: self._contribution.grantSubmission(part) if self._kindOfList == "prAuthor": return self._getParticipantsList(self._contribution.getPrimaryAuthorList()) elif self._kindOfList == "coAuthor": return self._getParticipantsList(self._contribution.getCoAuthorList()) elif self._kindOfList == "speaker": return self._getParticipantsList(self._contribution.getSpeakerList()) else: raise ServiceError("ERR-UK0", _("Invalid kind of list of users."))
userIds = [] DBMgr.getInstance().startRequest() for av in ah.getList(): userIds.append(av.getId()) DBMgr.getInstance().endRequest() i = 0 total = len(userIds) for id in userIds: print "processed %d users on %d"%(i, total) i += 1 DBMgr.getInstance().startRequest() av = ah.getById(id) av.resetLinkedTo() DBMgr.getInstance().endRequest() print "Indexing groups..." DBMgr.getInstance().startRequest() for group in gh.getValuesToList(): for prin in group.getMemberList(): if isinstance(prin, Avatar): prin.linkTo(group, "member") DBMgr.getInstance().endRequest() def indexCategory(cat):
def _getAnswer(self): ah = AvatarHolder() av = ah.getById(self._submitterId) self._newParticipant(av) return self._getSubmittersList()
def testIdentities(self): ah = AvatarHolder() for i in xrange(1, 3): self.assertEqual(self._authMgr.getAvatar(LoginInfo("fake-%d" % i, "fake-%d" % i)), ah.getById("fake-%d" % i))