Ejemplo n.º 1
0
 def post(self, post_id):
         key = db.Key.from_path('Poetry', int(post_id), parent=post_key())
         post = db.get(key)
         if post:
             comment = self.request.get("comment")
             if comment:
                 c = Comments(username = retrieve_username(self, 'user_id'),
                              writer = retrieve_username_hash(self,
                                                              'user_id'),
                              comment = comment,
                              post_id=post.key().id())
                 c.put()
                 self.redirect('/post/%s' % str(post.key().id()))
             else:
                 key = db.Key.from_path('Poetry', int(post_id),
                                        parent=post_key())
                 post = db.get(key)
                 self.redirect('/post/%s' % str(post.key().id()))
         else:
             self.render("errorexist.html")
Ejemplo n.º 2
0
    def post(self):
        post_id = self.request.get("post_id")
        key = db.Key.from_path('Post', int(post_id), parent=blog_key())
        post = db.get(key)

        if not post:
            self.error(404)
            return

        if self.user:
            comment = self.request.get("comment_content")
            user = User.by_name(self.user.name)

            if comment:
                newComment = Comments(user=user, post=post, comment=comment)
                newComment.put()
                return self.redirect("/blog/%s" % str(post.key().id()))
            else:
                comment_error = "Please enter text in comment box."
                self.render("permalink.html",
                            post=post,
                            comment_error=comment_error)
        else:
            return self.redirect("/blog")
Ejemplo n.º 3
0
 def add_comment(self, post, user, comment_text):
     '''Adds comment'''
     comment = Comments(user=user, post=post, text=comment_text)
     comment.put()
     redirect = '/blog/pl/%s' % str(post.key().id())
     return redirect