Exemplo n.º 1
0
def process_post_form(form):
    title = form.get('title').strip()
    content = form.get('content').strip()

    if not title or not content:
        return False
    else:
        post = {'title': title, 'content': content}

        all_tags = Tag.get_all()
        post_tags = []
        for tag in all_tags:
            if form.get(f'tag_{tag.id}') == 'on':
                post_tags.append(tag.id)
        post['tags'] = post_tags
        return post
Exemplo n.º 2
0
def edit_post_form(post_id):
    """Displays the form to edit the specified post"""
    post = Post.get(post_id)
    tags = Tag.get_all()
    return render_template('post_edit_form.html', post=post, tags=tags)
Exemplo n.º 3
0
def new_post_form(user_id):
    """Shows the New Post Form"""
    user = User.get(user_id)
    tags = Tag.get_all()
    return render_template('post_new_form.html', user=user, tags=tags)