Beispiel #1
0
    def post(self):
        if not self.user:
            self.redirect('/login')
        else:
            comment_id = int(self.request.get('comment_id'))
            comment = Comment.get_by_id(comment_id)

            if self.user.key.id() == comment.author.id():
                comment.key.delete()
                self.write(json.dumps(({'success': 'Comment deleted'})))
Beispiel #2
0
 def post(self):
     if not self.user:
         self.redirect('/login')
     else:
         comment_id = int(self.request.get('comment_id'))
         new_comment = self.request.get('new_comment')
         comment = Comment.get_by_id(comment_id)
         if comment:
             if comment.author.id() == self.user.key.id():
                 comment.content = new_comment
                 comment.put()
                 self.write(
                     json.dumps(({
                         'comment':
                         self.render_comment(comment.content)
                     })))
         else:
             self.write(json.dumps(({'comment': "There was no comment"})))