def _process(self): if self._params.get("Cancel", None) is not None: p = adminPages.WPUserDetails(self, self._avatar) return p.display() msg = "" ok = False if self._ok: ok = True ih = AuthenticatorMgr() #first, check if login is free if not ih.isLoginFree(self._login): msg += "Sorry, the login you requested is already in use. Please choose another one.<br>" ok = False if not self._pwd: msg += "you must enter a password<br>" ok = False #then, check if password is OK if self._pwd != self._pwdBis: msg += "You must enter the same password twice<br>" ok = False if ok: #create the indentity li = user.LoginInfo(self._login, self._pwd) id = ih.createIdentity(li, self._avatar, self._system) ih.add(id) self._redirect(urlHandlers.UHUserDetails.getURL(self._avatar)) return self._params["msg"] = msg p = adminPages.WPIdentityCreation(self, self._avatar, self._params) return p.display()
def _process(self): authManager = AuthenticatorMgr() #first, check if login is free if not authManager.isLoginAvailable(self._login): self._redirect(self._fromURL + "&msg=Login not avaible") return #then, check if password is OK if self._pwd != self._pwdBis: self._redirect(self._fromURL + "&msg=You must enter the same password twice") return #create the indentity li = user.LoginInfo( self._login, self._pwd ) id = authManager.createIdentity( li, self._avatar, self._system ) authManager.add( id ) #commit and if OK, send activation mail DBMgr.getInstance().commit() scr = mail.sendConfirmationRequest(self._avatar) scr.send() self._redirect(urlHandlers.UHUserDetails.getURL(self._avatar)) # to set to the returnURL
def _process(self): save = False ih = AuthenticatorMgr() minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() self._params["msg"] = "" if self._save: save = True #check submited data if not self._params.get("name", ""): self._params["msg"] += _("You must enter a name.") + "<br>" save = False if not self._params.get("surName", ""): self._params["msg"] += _("You must enter a surname.") + "<br>" save = False if not self._params.get("organisation", ""): self._params["msg"] += _( "You must enter the name of your organisation.") + "<br>" save = False if not self._params.get("email", ""): self._params["msg"] += _( "You must enter an email address.") + "<br>" save = False if not self._params.get("login", ""): self._params["msg"] += _("You must enter a login.") + "<br>" save = False if not self._params.get("password", ""): self._params["msg"] += _( "You must define a password.") + "<br>" save = False if self._params.get("password", "") != self._params.get( "passwordBis", ""): self._params["msg"] += _( "You must enter the same password twice.") + "<br>" save = False if not ih.isLoginFree(self._params.get("login", "")): self._params["msg"] += _( "Sorry, the login you requested is already in use. Please choose another one." ) + "<br>" save = False if not self._validMail(self._params.get("email", "")): self._params["msg"] += _( "You must enter a valid email address") save = False if save: #Data are OK, Now check if there is an existing user or create a new one ah = user.AvatarHolder() res = ah.match({"email": self._params["email"]}, exact=1, forceWithoutExtAuth=True) if res: #we find a user with the same email a = res[0] #check if the user have an identity: if a.getIdentityList(): self._redirect( urlHandlers.UHUserExistWithIdentity.getURL(a)) return else: #create the identity to the user and send the comfirmatio email _UserUtils.setUserData(a, self._params) li = user.LoginInfo(self._params["login"], self._params["password"]) id = ih.createIdentity(li, a, "Local") ih.add(id) DBMgr.getInstance().commit() if minfo.getModerateAccountCreation(): mail.sendAccountCreationModeration(a).send() else: mail.sendConfirmationRequest(a).send() if minfo.getNotifyAccountCreation(): mail.sendAccountCreationNotification(a).send() else: a = user.Avatar() _UserUtils.setUserData(a, self._params) ah.add(a) li = user.LoginInfo(self._params["login"], self._params["password"]) id = ih.createIdentity(li, a, "Local") ih.add(id) DBMgr.getInstance().commit() if minfo.getModerateAccountCreation(): mail.sendAccountCreationModeration(a).send() else: mail.sendConfirmationRequest(a).send() if minfo.getNotifyAccountCreation(): mail.sendAccountCreationNotification(a).send() self._redirect(urlHandlers.UHUserCreated.getURL(a)) else: cp = None if self._params.has_key("cpEmail"): ph = pendingQueues.PendingQueuesHolder() cp = ph.getFirstPending(self._params["cpEmail"]) if self._aw.getUser() and self._aw.getUser() in minfo.getAdminList( ).getList(): p = adminPages.WPUserCreation(self, self._params, cp) else: p = adminPages.WPUserCreationNonAdmin(self, self._params, cp) return p.display()
def runTests(host='localhost', port=FAKE_SERVICE_PORT, scenarios=[(2, 10)]): execTimes = [] agent = InvenioBatchUploaderAgent('test1', 'test1', 'test', 0, 'http://%s:%s' \ % (host, port)) ph = PluginsHolder() ph.reloadAllPlugins() ph.getPluginType('livesync').toggleActive() do = DummyObservable() do._notify('updateDBStructures', 'indico.ext.livesync', None, None, None) sm = SyncManager.getDBInstance() sm.registerNewAgent(agent) cm = CategoryManager() avatar = user.Avatar() avatar.setName( "fake" ) avatar.setSurName( "fake" ) avatar.setOrganisation( "fake" ) avatar.setLang( "en_GB" ) avatar.setEmail( "*****@*****.**" ) #registering user ah = user.AvatarHolder() ah.add(avatar) #setting up the login info li = user.LoginInfo("dummyuser", None) am = AuthenticatorMgr() userid = am.createIdentity( li, avatar, "Local" ) am.add( userid ) #activate the account avatar.activateAccount() #since the DB is empty, we have to add dummy user as admin minfo = HelperMaKaCInfo.getMaKaCInfoInstance() al = minfo.getAdminList() al.grant( avatar ) dummy = avatar ContextManager.destroy() HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(DefaultConference()) cm.getRoot() do._notify('requestStarted') home = cm.getById('0') # execute code for nconf in range(0, 1000): conf = home.newConference(dummy) conf.setTitle('Test Conference %s' % nconf) do._notify('requestFinished') time.sleep(1) # params won't be used task = LiveSyncUpdateTask(dateutil.rrule.MINUTELY) for scen in scenarios: print "Scenario %s workers, size = %s " % scen, # configure scenario InvenioBatchUploaderAgent.NUM_WORKERS = scen[0] InvenioBatchUploaderAgent.BATCH_SIZE = scen[1] ts = time.time() # just run it task.run() te = time.time() execTimes.append(te - ts) print "%s" % (te - ts) sm._track._pointers['test1'] = None for i in range(0, len(execTimes)): results[scenarios[i]] = execTimes[i]
def _process(self): save = False authManager = AuthenticatorMgr() minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() self._params["msg"] = "" if self._save: save = True #check submited data if not self._params.get("name", ""): self._params["msg"] += _("You must enter a name.") + "<br>" save = False if not self._params.get("surName", ""): self._params["msg"] += _("You must enter a surname.") + "<br>" save = False if not self._params.get("organisation", ""): self._params["msg"] += _( "You must enter the name of your organisation.") + "<br>" save = False if not self._params.get("email", ""): self._params["msg"] += _( "You must enter an email address.") + "<br>" save = False if not self._params.get("login", ""): self._params["msg"] += _("You must enter a login.") + "<br>" save = False if not self._params.get("password", ""): self._params["msg"] += _( "You must define a password.") + "<br>" save = False if self._params.get("password", "") != self._params.get( "passwordBis", ""): self._params["msg"] += _( "You must enter the same password twice.") + "<br>" save = False if not authManager.isLoginAvailable(self._params.get("login", "")): self._params["msg"] += _( "Sorry, the login you requested is already in use. Please choose another one." ) + "<br>" save = False if not self._validMail(self._params.get("email", "")): self._params["msg"] += _( "You must enter a valid email address") save = False if save: #Data are OK, Now check if there is an existing user or create a new one ah = user.AvatarHolder() res = ah.match({"email": self._params["email"]}, exact=1, searchInAuthenticators=False) if res: #we find a user with the same email a = res[0] #check if the user have an identity: if a.getIdentityList(): self._redirect( urlHandlers.UHConfUserExistWithIdentity.getURL( self._conf, a)) return else: #create the identity to the user and send the comfirmation email li = user.LoginInfo(self._params["login"], self._params["password"]) id = authManager.createIdentity(li, a, "Local") authManager.add(id) DBMgr.getInstance().commit() if minfo.getModerateAccountCreation(): mail.sendAccountCreationModeration(a).send() else: mail.sendConfirmationRequest(a, self._conf).send() if minfo.getNotifyAccountCreation(): mail.sendAccountCreationNotification(a).send() else: a = user.Avatar() _UserUtils.setUserData(a, self._params) ah.add(a) li = user.LoginInfo(self._params["login"], self._params["password"]) id = authManager.createIdentity(li, a, "Local") authManager.add(id) DBMgr.getInstance().commit() if minfo.getModerateAccountCreation(): mail.sendAccountCreationModeration(a).send() else: mail.sendConfirmationRequest(a).send() if minfo.getNotifyAccountCreation(): mail.sendAccountCreationNotification(a).send() self._redirect(urlHandlers.UHConfUserCreated.getURL(self._conf, a)) else: p = conferences.WPConfUserCreation(self, self._conf, self._params) return p.display()