def new_post(): form = form_models.NewPostForm() if form.validate_on_submit(): logging.info('Valid form') new_post = posts.create_from_form(form) logging.info(new_post) return flask.redirect('/')
def front_page(): form = form_models.NewPostForm() user = users.get_current_user() recent_posts = posts.recent(user=user) return flask.render_template('index.html', form=form, recent_posts=recent_posts, user=user)
def edit(post_id): user = users.get_current_user() post = repositories.posts.read_post(post_id) #logging.info(models.post_as_tuple(post)) form = form_models.NewPostForm(obj=models.post_as_tuple(post)) return flask.render_template('posts/edit.html', post=post, form=form, user=user)
def new(): form = form_models.NewPostForm() user = users.get_current_user() return flask.render_template('posts/new.html', form=form, user=user)