Esempio n. 1
0
def edit_post(post_id):
    post = Post.query.get(post_id)
    post.title = request.form['title']
    post.content = request.form['content']
    db.session.commit()

    tags = request.form.getlist('tags')
    Tag.fill_tags(tags, post_id)

    return redirect(f"/posts/{post.id}")
Esempio n. 2
0
def make_post(user_id):
    title = request.form['title']
    content = request.form['content']
    user_id = user_id
    created_at = None

    post = Post(title=title,
                content=content,
                user_id=user_id,
                created_at=created_at)
    db.session.add(post)
    db.session.commit()

    tags = request.form.getlist('tags')
    post_id = post.id
    Tag.fill_tags(tags, post_id)

    return redirect(f"/users/{user_id}")