def post(self, post_id, vote_default): post = post_exist(post_id) v = vote_exist(post_id, self.user.name) voteresult = self.request.get('voteresult') if not vote_default: vote_default = "votepost" if post: if self.user.name == post.created_by: error = "You cannot Like your own Post" self.render("errorpost.html", p=post, error=error) elif v.count() > 0: error = "You have already voted" self.render("errorpost.html", p=post, error=error) elif not voteresult: error = "You did not vote" + voteresult self.render(vote_default + ".html", p=post, error=error) else: v = Vote(parent=blog_key(), username_fk=self.user.name, post_id_fk=int(post_id), content=voteresult) v.put() self.redirect('/blog/%s' % post_id) else: self.redirect("/blog")
def get(self,post_id): if self.user: post=post_exist(post_id) if post: self.render("newcomment.html", p=post) else: self.render("errorpost.html", error="Post does not exist") else: self.redirect("/login")
def post(self,post_id): post = post_exist(post_id) if not self.user: self.redirect('/blog') elif not post.created_by: post.delete() self.redirect('/blog') elif self.user.name!=post.created_by: self.render("deletepost.html", post=post,error="You cannot delete other user's post") else: post.delete() self.redirect('/blog')
def get(self, post_id): if self.user: post=post_exist(post_id) if post: if self.user.name!=post.created_by: error = "You cannot delete other user's Post" self.render("errorpost.html", p=post, error=error) else: self.render("deletepost.html", post=post) else: self.redirect("/blog") else: self.redirect("/login")
def post(self,post_id): if not self.user: self.redirect('/blog') post=post_exist(post_id) if post: content = self.request.get('content') if content: c = Comment(parent = blog_key(), post_fk = post, content = content, created_by=self.user.name) c.put() self.redirect('/blog/%s' % str(post_id)) else: error = "comment, please!" self.render("newcomment.html", p=post, error=error) else: self.render("errorpost.html", error="Post does not exist")
def get(self, post_id): if self.user: p = post_exist(post_id) v = vote_exist(post_id, self.user.name) if p: if self.user.name == p.created_by: error = "You cannot Like your own Post" self.render("errorpost.html", p=p, error=error) elif v: error = "You have already voted" self.render("errorpost.html", p=p, error=error) else: self.render("likepost.html", p=p) else: self.redirect("/blog") else: self.redirect("/login")
def get(self, post_id, vote_default): if not vote_default: vote_default = "votepost" if self.user: p = post_exist(post_id) v = vote_exist(post_id, self.user.name) if p: if self.user.name == p.created_by: error = "You cannot Like your own Post" self.render("errorpost.html", p=p, error=error) elif v.count() > 0: error = "You have already voted" self.render("errorpost.html", p=p, error=error) else: self.render(vote_default + ".html", p=p) else: self.redirect("/blog") else: self.redirect("/login")
def post(self, post_id): post = post_exist(post_id) v = vote_exist(post_id, self.user.name) if post: if self.user.name == post.created_by: error = "You cannot Like your own Post" self.render("errorpost.html", p=post, error=error) elif v: error = "You have already voted" self.render("errorpost.html", p=p, error=error) else: v = Vote(parent=blog_key(), user_fk=user, post_fk=post, content="Like") v.put() self.redirect('/blog/%s' % post_id) else: self.redirect("/blog")