Exemple #1
0
	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))
Exemple #2
0
    def get(self, answerId):
        print answerId
        # 按answerId 搜索评论
        answerComments = AnswerComment.queryByAnswerId(answerId)

        commentModel = u"""
			<ul>
				<li>
					<a class="aw-user-name" href="http://wenda.wecenter.com/people/seosns" data-id="8884"><img src="http://wenda.wecenter.com/uploads/avatar/000/00/88/84_avatar_min.jpg" alt="" /></a>
				
					<div>
						<p class="clearfix">
						
										<span class="pull-right">
													<a href="javascript:;" onclick="if ($(this).parents('.aw-comment-box').find('form textarea').val() == $(this).parents('.aw-comment-box').find('form textarea').attr('placeholder')){$(this).parents('.aw-comment-box').find('form textarea').val('');};$(this).parents('.aw-comment-box').find('form').show().find('textarea').focus();$(this).parents('.aw-comment-box').find('form textarea').insertAtCaret('@seosns:');$.scrollTo($(this).parents('.aw-comment-box').find('form'), 300, {queue:true});$(this).parents('.aw-comment-box').find('textarea').focus();">回复</a>				</span>
									
						<a href="http://wenda.wecenter.com/people/seosns" class="aw-user-name author" data-id="8884">seosns</a> • <span>2015-04-17 21:45</span>
						</p>
						<p class="clearfix">%s</p>
					</div>
				</li>
			</ul>
			"""
        result = ""
        if answerComments:
            for answerComment in answerComments:
                comment = commentModel % (answerComment.message)
                # print commentModel
                result += comment
                # print answerComment.message
        print result
        self.write(result)