Exemplo n.º 1
0
    def post(self):
        # this method is reserved for AJAX call to this object
        # json response
        result = {'message': ""}
        comment_id = self.request.POST.get("comment_id", "")
        operation = self.request.POST.get("operation", "")
        logging.info("CommentManager, post data: comment_id = %s, operation = %s" % (comment_id, operation))
        if comment_id:
            comment = Comment.get_by_id(long(comment_id))
            if comment:
                if operation == "delete":
                    # update entry.commentcount
                    comment.entry.commentcount -= 1
                    comment.entry.put()
                    # delete this comment
                    comment.delete()
                    result['message'] = "comment '%s' has been deleted" % (comment_id)
                else:
                    result['message'] = "unknown operation %s" % (operation)
            else:
                result['message'] = "unknown comment id %s" % (comment_id)
        else:
            result['message'] = "empty comment id"

        json_response = json.encode(result)
        logging.info("json response: %s" % (json_response))

        self.response.content_type = "application/json"
        return self.response.out.write(json_response)
Exemplo n.º 2
0
	def post(self,page):
		code=page.param("code")
		OptionSet.setValue("Akismet_code",code)
		rm=page.param('autorm')
		if rm and int(rm)==1:
			rm=True
		else:
			rm=False
		oldrm = OptionSet.getValue("Akismet_AutoRemove",False)
		if oldrm!=rm:
			OptionSet.setValue("Akismet_AutoRemove",rm)
		spam=page.param("spam")
		spam = len(spam)>0 and int(spam) or 0
		sOther = ""
		if spam>0:
			cm = Comment.get_by_id(spam)
			try:
				url = Blog.all().fetch(1)[0].baseurl
				self.SubmitAkismet({
					'user_ip' : cm.ip,
					'comment_type' : 'comment', 
					'comment_author' : cm.author.encode('utf-8'),
					'comment_author_email' : cm.email,
					'comment_author_url' : cm.weburl,
					'comment_content' : cm.content.encode('utf-8')
				},url,"Spam")
				sOther = u"<div style='padding:8px;margin:8px;border:1px solid #aaa;color:red;'>评论已删除</div>"
				cm.delit()
			except:
				sOther = u"<div style='padding:8px;margin:8px;border:1px solid #aaa;color:red;'>无法找到对应的评论项</div>"
		return sOther + self.get(page)
Exemplo n.º 3
0
 def post(self):
     try:
         checkList = self.request.get_all('checks')
         for key in checkList:
             keyID = int(key)
             comment = Comment.get_by_id(keyID)
             comment.delete()
     finally:
         self.redirect('/admin/comments')
     return
Exemplo n.º 4
0
 def get(self,commID):
   comm = Comment.get_by_id(int(commID))
   if comm is None:
     return self.redirect('/')
   post = comm.post
   post.commentcount -= 1
   link = comm.post.full_permalink()
   comm.delete()
   util.flushRecentComment()
   return self.redirect(link)
Exemplo n.º 5
0
 def post(self):
     try:
         checkList = self.request.get_all('checks')
         for key in checkList:
             keyID = int(key)
             comment=Comment.get_by_id(keyID)
             comment.delete()
     finally:
         self.redirect('/admin/comments')
     return
Exemplo n.º 6
0
    def post(self, comment_id=0):
        '''Updating the comment and redirecting back to the photo page.'''
        user_id, user = self.get_user()
        if not user:
            self.redirect('/')
            return

        comment_id = int(comment_id)
        comment = Comment.get_by_id(comment_id)

        error, data = self._check(user, comment)
        if error:
            self.render('error.html', **data)

        comment_text = self.request.get('comment-text')
        photo_id = int(self.request.get('photo_id'))
        logging.info(comment_text)
        logging.info(photo_id)

        comment.text = comment_text
        comment.put()

        self.redirect('/photo/{}'.format(photo_id))
Exemplo n.º 7
0
    def get(self, comment_id=0):
        '''Edit a comment'''
        user_id, user = self.get_user()
        if not user:
            self.redirect('/')
            return

        comment_id = int(comment_id)
        comment = Comment.get_by_id(comment_id)

        error, data = self._check(user, comment)
        if error:
            self.render('error.html', **data)
            return

        data = {
            'page_title': 'Edit Comment',
            'user': user,
            'userid': user_id,
            'comment': comment,
            'photo_id': comment.photo.id(),
        }
        self.render('comment-edit.html', **data)