def __init__(self): self.util = Utility(); self.convertPDF2Image =None; if self.util.isWindows(): self.convertPDF2Image = WinPDF2Image(); else: self.convertPDF2Image = LinuxPDF2Image();
class ForgotController(BaseController): # Uncomment this line if your controller requires an authenticated user # allow_only = predicates.not_anonymous() def __init__(self): dh = LogDBHandler( config=config,request=request); log.addHandler(dh) self.utility = Utility(); self.urlServer = model.SystemEnvironment.getServerUrl(); @expose('json' ) def index(self,**kw): self.email = kw.get('email'); self.user = model.User.by_email_address(self.email); if(self.user): newPassword = self.utility.id_generator(8); #self.user._set_password(newPassword); self.emailValues={}; self.emailValues['user_name'] = self.user.user_name; self.emailValues['email'] = self.user.email_address; self.emailValues['password'] = newPassword; self.sendMailService = SendMailService(); self.sendMailService.sendForgotPassword(self.emailValues); self.sendMailService.start(); else: log.info('forget password email : %s can not access',self.email); redirect("/login")
class ConvertPdf2image(object): def __init__(self): self.util = Utility(); self.convertPDF2Image =None; if self.util.isWindows(): self.convertPDF2Image = WinPDF2Image(); else: self.convertPDF2Image = LinuxPDF2Image(); def convert(self,pdfFilePath,destinationPath): return self.convertPDF2Image.convert2Image(pdfFilePath, destinationPath)
def __init__(self): dh = LogDBHandler( config=config,request=request); log.addHandler(dh) self.utility =Utility()
class GenpollController(BaseController): def __init__(self): dh = LogDBHandler( config=config,request=request); log.addHandler(dh) self.utility =Utility() @expose() def index(self, came_from=lurl('/')): if not request.identity: login_counter = request.environ.get('repoze.who.logins', 0) + 1 redirect('/login', params=dict(came_from=came_from, __logins=login_counter)) userid = request.identity['repoze.who.userid'] flash(_('Welcome back, %s!') % userid) # Do not use tg.redirect with tg.url as it will add the mountpoint # of the application twice. return HTTPFound(location=came_from) @expose('json') @require(predicates.in_any_group('voter','managers', msg=l_('Only for voter'))) def getVariable (self, *args, **kw): user = request.identity['user']; startdate = self.utility.getStartDate() stopdate = self.utility.plusDate(startdate,90) for num in range(1,20): self.project = model.QuestionProject(name='test' + str(num) ,description='test script ',user_id=user.user_id, id_question_project_type=2, header_message='test script', footer_message='test script', welcome_text='test script', end_text='test script', start_date=startdate, end_date=stopdate, active=1); self.project.save() self.questiongroup = model.QuestionGroup(id_question_project=self.project.id_question_project, question_group_name='Default', question_group_description='Default', id_parent=None, order=0, active =1); self.questiongroup.save() self.question = model.Question(id_question_type=2, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script', text_label='test script', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=2, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script1', text_label='test script1', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script3', text_label='test script3', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script4', text_label='test script4', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script5', text_label='test script5', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script6', text_label='test script6', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script7', text_label='test script7', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script8', text_label='test script8', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script9', text_label='test script9', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #----------------------------- self.question = model.Question(id_question_type=1, id_question_project=self.project.id_question_project, user_id=user.user_id, id_question_group=self.questiongroup.id_question_group, id_fix_difficulty_level=1, question='Test Script10', text_label='test script10', order=0, active=1); self.question.save() #answer 1 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 0 self.basicQuestion.score = 0 ; self.basicQuestion.order = 0; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test1" self.basicText.save(); #answer 2 self.basicData = model.BasicData(); self.basicData.id_basic_data_type = 1; #image self.basicData.save(); self.basicQuestion = model.BasicQuestion(); self.basicQuestion.id_question = self.question.id_question self.basicQuestion.id_basic_data = self.basicData.id_basic_data; self.basicQuestion.answer = 1 self.basicQuestion.score = 1 ; self.basicQuestion.order = 1; self.basicQuestion.save(); self.basicText = model.BasicTextData(); self.basicText.id_basic_data = self.basicData.id_basic_data; self.basicText.value = "test2" self.basicText.save(); #---------------- self.template = model.Invitation( name_content='Test', from_name='Test', subject='Test', content='test', create_date=startdate ); self.template.save(); self.option = model.QuestionOption( id_question_project= self.project.id_question_project, id_question_theme=1, id_question_invitation=self.template.id_question_invitation, id_fix_random_type=1, id_close_type=1, name_publication='test publucation', activate_date=startdate , expire_date=stopdate, header_message=None, footer_message=None, welcome_message=None, end_message=None, send_status=0, show_score=0, random_answer=0, redirect_url=None, gen_code=None,show_navigator=None, duration_time=None, use_question_no=1, create_date=None, no_use=1, use_default=0, use_general_information=0); self.option.save() return dict(success=True);
def __init__(self): dh = LogDBHandler( config=config,request=request); log.addHandler(dh) self.utility = Utility(); self.urlServer = model.SystemEnvironment.getServerUrl();