def compose(post_id=None): post = None if post_id: post = Post.query.get_or_404(post_id) form = ComposeForm(obj=post) if form.validate_on_submit(): if post: post.title = form.title.data post.link_text = canocalize( form.title.data ) post.content = form.content.data post.content_html = markdown(form.content.data) else: post = Post( title=form.title.data, link_text=canocalize(form.title.data), content=form.content.data, content_html=markdown(form.content.data), creation_date=datetime.now() ) db.session.add(post) db.session.commit() return redirect(url_for( 'regular.post', post_id=post.id, link_text=post.link_text )) return render_template('admin/compose.jinja2', form=form)
def test_canocalization(self): self.assertEquals('this-is-a-title-bam', canocalize('This is -- a_title - bam!'))