def post(self, slug): post = Posts.select().where(Posts.id == slug) if post: post = Posts.select().where(Posts.id == slug).get() loggedInUser = self.current_user print(post.id, 'post id') # Only allow the creator of the post access to edit if post.user_id == loggedInUser.id: title = self.get_body_argument('title') category = self.get_body_argument('category') post = self.get_body_argument('post') # Edit Post Posts.update(title=title, category=category, post=post).where(Posts.id == slug).execute() return self.redirect("/post/" + slug) return self.redirect("/")
def promote(id): app.logger.debug("getting to promote post, id is %s" % id) if ('username' in session): q = Post.update(promoted=True).where(Post.id == id) q.execute() return redirect(url_for('show_posts_beta'))
def demote(id): app.logger.debug("getting to demote post, id is %s" % id) if ('username' in session): q = Post.update(promoted=False).where(Post.id == id) q.execute() return redirect(url_for('show_posts_beta'))
def hide(id): app.logger.debug("getting to hide post id is %s" % id) if ('username' in session): q = Post.update(hidden=True).where(Post.id == id) q.execute() return redirect(url_for('show_posts_beta'))