def post(self, answerId): print 'hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii' print answerId message = self.get_argument("message") userId = self.get_current_user_id() answer = Answer.queryByAnswerId(answerId) # 异常1 回答不存在 if not answer : self.write(Util.response(None, -1, u'回复不存在')) return # 请输入评论内容 if message == "": self.write(Util.response(None, -1, u'请输入评论内容')) return # 不能评论锁定的问题 question = Question.queryById(answer.question_id) if question.lock == 1 : self.write(Util.response(None, -1, u'不能评论锁定的问题')) return # 你没有发表评论的权限(略) # 插入一条评论 AnswerComment.addAnswerComment(answerId, userId, message) rsm = {'item_id':answerId, 'type_name':'answer'} self.write(Util.response(rsm, 1, None))
def post(self): print 'PublishQuestionHandler' question_content = self.get_argument('question_content') question_detail = self.get_argument('question_detail') print question_detail print question_content user = self.get_current_user() userId = self.get_current_user_id() if len(question_content) < 5 : self.write(Util.response(None, -1, u'问题标题字数不得少于 5 个字')) return else : Question.addQuestion(question_content, question_detail, userId) url = '/' rsm = {'url':'/question/2'} self.write(Util.response(rsm, 1, None))
def get(self): question = {'context': 123} # print question.context u = AutoUser.queryAllUsers() q = Question.queryAllQuestions() questions = {'hi','hello'} answer = 'hi' self.render("explore/index.html", questions=q)
def get(self, questionId): question = Question.queryById(questionId) answers = Answer.queryByQuestionId(questionId) print answers[0].answer_content user = self.get_current_user() for answer in answers: print "answer.answer_content", answer.answer_content vote = {"user": "******"} print vote["user"] answer.vote = vote print answer.vote["user"] showmax = 5 answer.showmax = 2 # 获取投赞同票人name votename = Answer_AnswerVote.queryByAnswerId(answer.answer_id, 1) answer.votename = votename # 判读是否已经投赞同票 if user.name in votename: answer.agreeActive = 1 else: answer.agreeActive = 0 # 判读是否投反对票 votename = Answer_AnswerVote.queryByAnswerId(answer.answer_id, -1) if user.name in votename: answer.againstActive = 1 else: answer.againstActive = 0 print "answer.answer_id", answer.answer_id print "votename", votename print "user.name", user.name print "answer.agreeActive", answer.agreeActive # 今天的日期 today = datetime.date.today() # 今天日期的时间戳 todayStamp = int(time.mktime(today.timetuple())) # 回答时间 answerStamp = answer.add_time t = time.localtime(answerStamp) # 判断是否为今天回答 if answerStamp - todayStamp > 0: # 今天的回答只截取日期和时间 addTimeStr = time.strftime("%H:%M", t) else: addTimeStr = time.strftime("%Y-%m-%d", t) answer.addTimeStr = addTimeStr self.render( "question/question_detail.html", question=question, questionId=questionId, answers=answers, user=user )
def get(self): question = {'context': 123} u = AutoUser.queryAllUsers() q = Question.queryAllQuestions() questions = {'hi','hello'} answer = 'hi' # 获取连接 linkList = Link.queryAll() # 获取页数 pageCount = Link.queryPageCount(10) pageNumList = [2,3,4,5,6] user = self.get_current_user() # get_time_format = Util.get_time_format; # nowStamp = int(time.time()) # print get_time_format(nowStamp -186400) self.render("explore/index.html", linkList = linkList, pageNumList = pageNumList, get_time_format = Util.get_time_format, user = user)
def get(self): self.clear_cookie("current_user") q = Question.queryAllQuestions() self.redirect("/explore")