def update(self): toUpdate = self.request.get('id') post = Post.get_by_id(int(toUpdate)) post.description = self.request.get('description') post.last_edit_author = str(users.get_current_user()) if post.description and post.last_edit_author and toUpdate: post.put() self.redirect("/?msg=El post ha sido editado correctamente.") else: self.redirect('/?msg=El post no ha podido actualizarse.')
def post(self, post_id): post = Post.get_by_id(int(post_id)) content = self.request.get('content') # let's check if user is logged in if self.user: # and there is something in the content field if content: comment = Comment(post=post, user=User.by_id(self.uid()), content=content) comment.put() self.render_post(post) else: error = "Your comment can't be empty" self.render_post(post, error) # user not logged in, let's go to the login page else: self.redirect('/login')
def post(self, post_id): post = Post.get_by_id(int(post_id)) content = self.request.get('content') # let's check if user is logged in if self.user: # and there is something in the content field if content: comment = Comment( post=post, user=User.by_id(self.uid()), content=content ) comment.put() self.render_post(post) else: error = "Your comment can't be empty" self.render_post(post, error) # user not logged in, let's go to the login page else: self.redirect('/login')
def post(self, post_id): post = Post.get_by_id(int(post_id)) # check if the user is the post owner if post.user.key().id() == self.uid(): post.delete() self.redirect('/')
def get(self, post_id): post = Post.get_by_id(int(post_id)) self.render('delete-post.html', post=post, user=self.user)
def get(self, post_id): post = Post.get_by_id(int(post_id)) self.render_post(post)