Ejemplo n.º 1
0
    def post(self, post_id, comment_id):
        postKey = ndb.Key(Post, int(post_id), parent=BLOG_KEY)
        c = Comment.by_id(postKey, comment_id)
        own = c and c.is_owned_by(self.user)
        if own:
            c.key.delete()
        else:
            self.flash("you can't delete other's comments", "danger")

        self.redirect('/blog/%s#comments-section' % post_id)
Ejemplo n.º 2
0
    def post(self, post_id, comment_id):
        postKey = ndb.Key(Post, int(post_id), parent=BLOG_KEY)
        comment = Comment.by_id(postKey, comment_id)
        if comment and comment.is_owned_by(self.user):
            message = self.request.get("message")
            if not message:
                error = "inform a valid comment, please"
                self.render("post-permalink.html",
                            p=postKey.get(),
                            comment_error={str(comment_id): error})
                return
            else:
                comment.content = message
                comment.put()
        else:
            self.flash("you can't edit other's comments", "danger")

        self.redirect("/blog/%s" % post_id)