def get(self): cookie = self.get_cookie("user.opros", default=None) if cookie == None: if self.get_query_argument("err", default=False): self.write(page.makepage('newuser', 'incorrectdata')) else: self.write(page.makepage('newuser')) else: self.write(page.makepage('continue'))
def get(self): cookie = self.get_cookie("user.opros",default=None) if cookie == None: if self.get_query_argument("err", default = False): self.write(page.makepage('newuser', 'incorrectdata')) else: self.write(page.makepage('newuser')) else: self.write(page.makepage('continue'))
def post(self): if self.get_query_argument("err", default = False): self.write(page.makepage('questions', 'incorrectdata')) elif self.get_body_argument("new", default = False): self.Start() else: fio = self.CorrectName() if fio == 'ERROR': self.redirect('/?err=1') else: user_id = db.Answer(fio) if user_id == False: user_id = db.FindAnswer(fio) self.set_cookie("user.opros", (str(user_id))) self.write(page.makepage('answerexist')) else: self.set_cookie("user.opros", (str(user_id))) self.Start()
def post(self): if self.get_query_argument("err", default=False): self.write(page.makepage('questions', 'incorrectdata')) elif self.get_body_argument("new", default=False): self.Start() else: fio = self.CorrectName() if fio == 'ERROR': self.redirect('/?err=1') else: user_id = db.Answer(fio) if user_id == False: user_id = db.FindAnswer(fio) self.set_cookie("user.opros", (str(user_id))) self.write(page.makepage('answerexist')) else: self.set_cookie("user.opros", (str(user_id))) self.Start()
def Start(self): questlist = db.GetQuestions() content = "<p>Начинаем самый бессмысленный тест в твоей жизни!\n<form action='/endtest' method='POST'>\n" for question in sorted(questlist): content = content + page.makequestion(question, questlist[question]) content = content + "<br><input type='submit'></form>" quest = open(staticdir + "questions", 'w') quest.write(content) quest.close() self.write(page.makepage('questions'))
def post(self): cookie = self.get_cookie("user.opros",default=None) user_id = cookie data = self.CorrectData() if data == 'ERROR': self.redirect('/begintest?err=1') else: printable = db.SetDataInDB(data, user_id) result = open(staticdir + "result", 'w') result.write(printable) result.close() self.write(page.makepage('result')) self.clear_cookie("user.opros")
def post(self): cookie = self.get_cookie("user.opros", default=None) user_id = cookie data = self.CorrectData() if data == 'ERROR': self.redirect('/begintest?err=1') else: printable = db.SetDataInDB(data, user_id) result = open(staticdir + "result", 'w') result.write(printable) result.close() self.write(page.makepage('result')) self.clear_cookie("user.opros")
def get(self): cookie = self.get_cookie("user.opros",default=None) try: user_id = int(cookie) except: self.redirect('/') if self.get_argument("results", default=False): printable = db.GetResults(user_id) results = open(staticdir + "results", 'w') results.write(printable) results.close() self.write(page.makepage('results')) self.clear_cookie("user.opros") else: self.redirect('/')
def get(self): cookie = self.get_cookie("user.opros", default=None) try: user_id = int(cookie) except: self.redirect('/') if self.get_argument("results", default=False): printable = db.GetResults(user_id) results = open(staticdir + "results", 'w') results.write(printable) results.close() self.write(page.makepage('results')) self.clear_cookie("user.opros") else: self.redirect('/')