Example #1
0
File: weibo.py Project: fxyan/Dawn
def delete(request):
    weibo_id = int(request.query['weibo_id'])
    Weibo.delete(weibo_id)
    comments = Comment.all(weibo_id=weibo_id)
    for comment in comments:
        Comment.delete(comment.id)
    return redirect('/weibo')
Example #2
0
 def post(self, post_id, comment_id):
     if not self.user:
         self.render("/login")
         return
     
     # get the comment from the comment id
     comment = Comment.get_by_id(int(comment_id))
     # check if there is a comment associated with that id
     if comment:
         # check if this user is the author of this comment
         if comment.author == self.user.name:
             # delete the comment and redirect to the post page
             Comment.delete(comment_id)
             time.sleep(0.1)
             self.redirect('/post/%s' % str(post_id))
         # otherwise if this user is not the author of this comment throw an
         # error
         else:
             self.write("You cannot delete other user's comments")
     # otherwise if there is no comment associated with that id throw an
     # error
     else:
         self.write("This comment no longer exists")
Example #3
0
File: weibo.py Project: fxyan/Dawn
def comment_delete(request):
    comment_id = int(request.query['comment_id'])
    Comment.delete(comment_id)
    return redirect('/weibo')