def post_logout(self, came_from=lurl('/'), *args, **kw): """ Redirect the user to the initially requested page on logout and say goodbye as well. """ #flash(_('We hope to see you soon!')) ManageSession.deleteAll(); return HTTPFound(location=came_from)
def index(self, came_from=lurl('/')): #print request.scheme + '://'; #hooks.notify('tgext.pylogservice.startup' ) #hooks.notify('tgext.pyutilservice.startup') if not request.identity: ManageSession.deleteAll() if ManageSession.getLanguage() is None: ManageSession.setLanguage() print 'Session Language : %s' %(ManageSession.getLanguage()) return dict(page='metronic')
def saveProject(self, came_from=lurl('/'), *args, **kw): reload(sys).setdefaultencoding("utf-8"); self.success = True; self.message = "success"; print 'Session Language : %s' %(ManageSession.getLanguage()) self.project = model.QuestionProject(**kw); self.project.id_question_project = self.utility.setIfEmpty(self.project.id_question_project) user = request.identity['user']; self.project.user_id = user.user_id; if self.project.id_question_project : self.project.updateall(); else: self.project.save(); self.addQuestionGroup( id_question_project=self.project.id_question_project, question_group_name='default', question_group_description='default', id_question_result_group = '', order=0 ); return dict(success=self.success, message = self.message, project_id=self.project.id_question_project);
def index(self, came_from=lurl('/'), **kw): reload(sys).setdefaultencoding("utf-8"); self.content = model.Content.getByContentType(3,lang=ManageSession.getLanguage()) return dict(page='service', content = self.content.content,title='Terms of Service')
def post_login(self, came_from=lurl('/'), *args, **kw): log.info("post_login"); if not request.identity: log.warning("user cannot login, redirect to login"); login_counter = request.environ.get('repoze.who.logins', 0) + 1 log.info( self.urlServer + '/login') redirect('/login', params=dict(came_from=came_from, __logins=login_counter)) #userid = request.identity['repoze.who.userid']; user = request.identity['user']; groups = request.identity['groups'] ; log.info("user in group : %s " %groups ); userActive = model.UserGenCode.getUserActivated(user.user_id); if(userActive is None ):# and ('managers' not in groups )): log.warning("user cannot login, redirect to login"); flash(_('Please activate in your email'), 'warning') #request.identity.current.logout(); self.registerService.reActivateUser(user) auth_force_logout() login_counter = request.environ.get('repoze.who.logins', 0) ; redirect( '/login')#, params=dict(came_from=came_from, __logins=login_counter)) print "add session" ManageSession.setLanguage('EN') #flash(_('Welcome back, %s!') % userid) if('/' == came_from): if ('voter' in groups): log.info("redirect to home page"); #model.LogSurvey.insert(ip_server='127.0.0.1',status='INFO',message="redirect to home page" ,current_page='Login',user_name=user); log.info(self.urlServer + '/home' ); redirect( '/home'); if ('creator' in groups): log.info("redirect to create survey page"); log.info(self.urlServer + '/survey' ); #model.LogSurvey.insert(ip_server='127.0.0.1',status='INFO',message="redirect to create survey page" ,current_page='Login',user_name=user); redirect('/survey'); #identity = request.environ.get('repoze.who.identity') #for key in request.environ: # print key # print request.environ[key]; # print '-------' #print "----------------------------------------------------------------"; #for key in request.identity: # print key # print request.identity[key]; # print '-------' #print "----------------------------------------------------------------"; #print "User id " ; #user = request.identity['user']; #print user.user_id; """ if 'voter' in groups: print "voter"; log.info('voter'); return HTTPFound(location='/survey') print "other"; """ # Do not use tg.redirect with tg.url as it will add the mountpoint # of the application twice. return HTTPFound(location=came_from)
def getContentForHelp(self,**kw): reload(sys).setdefaultencoding("utf-8"); self.searchObject = SearchObject(**kw) self.content = model.Content.getByContentType(self.searchObject.idsearch,lang=ManageSession.getLanguage()) self.value ="" if self.content: self.value = self.content.content return dict(content = self.value)