def post(self, post_id): a = Article.check_if_valid_post(post_id) if a: if self.user: key = db.Key.from_path('Article', int(post_id), parent=blog_key()) a = db.get(key) comment = self.request.get('comment') created_by = self.user.name if comment: c = Comment(parent=blog_key(), comment=comment, post_id=int(post_id), created_by=created_by) c.put() comments = db.GqlQuery( "select * from Comment where post_id = " + post_id + " order by created desc") self.render("permalink.html", a=a, comments=comments) else: self.redirect('/blog/login') else: self.error(404) return
def post(self, blog_id): if not self.user: self.redirect("/login") user_id = self.request.cookies.get('user_id').split('|')[0] commentstr = self.request.get('comment') com = Comment(user_id=user_id, blog_id=blog_id, comment=commentstr) com.put() self.redirect("/blog/")
def post(self, post_id, posts): content = self.request.get('content') name = self.user.name # created = self.request.get('created') # key = db.Key.from_path('Post', int(post_id), parent=blog_key()) # posts = db.get(key) # if posts is None: # return self.redirect('/blog') if content: c = Comment(comment=content, name=name, post_id=posts, postId=int(post_id)) c.put() return self.redirect('/blog') else: error = "content is required" self.render('comment.html', content=content, error=error)
def post(self, post_id): """ Handles the post request from the post page. This is the comment submission. """ content = self.request.get("content") current_user = self.authenticate_user() post = Post.get_by_id(long(post_id)) if not post: self.render("post404.html") else: user = User.get_by_id(post.user.id()) comments = Comment.query().filter(Comment.post == post.key).fetch() if not current_user: self.redirect("/login") elif not content: self.render("post.html", comments=comments, post=post, current_user=current_user, user=user, error="No comment text was received") else: comment = Comment(content=content, user=current_user.key, post=post.key) comment.put() current_user.comments.append(comment.key) current_user.put() self.render( "post.html", post=post, user=user, current_user=current_user, comments=comments)