def post(self, key_id): if self.user: post = Post.get_by_id(int(key_id)) if not post: self.redirect("/") comment = self.request.get("comment") username = self.request.get("username") cmt = Comment(username=username, comment=comment, post_id=int(key_id)) cmt.put() comments = db.GqlQuery("SELECT * FROM Comment WHERE post_id = " + ":id ORDER BY created ASC", id=int(key_id)) likes = Like.getNumOfLikes(key_id) liked = Like.checkLikes(key_id, self.user.key().id()) #self.render("postpage.html", posts=[post], comments=comments, # numOfLikes=likes, liked=liked) self.redirect('/%s' % post.key().id()) else: self.redirect("/login")
def get(self, key_id): post = Post.get_by_id(int(key_id)) if not post: self.redirect("/") comments = db.GqlQuery("SELECT * FROM Comment WHERE post_id = :id" + " ORDER BY created ASC", id=int(key_id)) likes = Like.getNumOfLikes(key_id) if self.user: liked = Like.checkLikes(key_id, self.user.key().id()) self.render("postpage.html", posts=[post], comments=comments, numOfLikes=likes, liked=liked, user_id=self.user.key().id()) else: self.render("postpage.html", posts=[post], comments=comments, numOfLikes=likes, liked=True)