def post(self):
        form = self.form(request.form)
        tags = request.form['tags'] if request.form['tags'] else ''

        if form.validate():
            post = Post()
            form.populate_obj(post)

            tags = uniq_list(tags, ',')
            post['tags'] = tags

            post.save()

        return redirect(url_for('.index'))
    def post(self):
        form = self.form(request.form)
        tags = request.form["tags"] if request.form["tags"] else ""

        if form.validate():
            post = Post()
            form.populate_obj(post)

            tags = uniq_list(tags, ",")
            post["tags"] = tags

            post.save()

        return redirect(url_for(".index"))
    def post(self, slug):
        post = Post.objects.get_or_404(slug=slug)
        form = self.form(request.form)
        tags = request.form['tags'] if request.form['tags'] else ''

        if form.validate():
            now = datetime.now()

            for field in ['slug', 'title', 'body']:
                post[field] = form[field].data

            tags = uniq_list(tags, ',')
            post['tags'] = tags

            post['updated_at'] = now

            post.save()

        return redirect(url_for('.index'))
    def post(self, slug):
        post = Post.objects.get_or_404(slug=slug)
        form = self.form(request.form)
        tags = request.form["tags"] if request.form["tags"] else ""

        if form.validate():
            now = datetime.now()

            for field in ["slug", "title", "body"]:
                post[field] = form[field].data

            tags = uniq_list(tags, ",")
            post["tags"] = tags

            post["updated_at"] = now

            post.save()

        return redirect(url_for(".index"))