Beispiel #1
0
def post_constructor_handle(board_short):
    board = Engine.get_board_by_short(board_short)
    parent_post = Engine.get_post_by_id(request.args.get('parent_post_id'))
    return render_template('post_constructor.html',
                           boards=Engine.get_boards_dumped(),
                           current_board=board,
                           parent_post=parent_post)
Beispiel #2
0
def board_handle(board_short):
    current_board = Engine.get_board_by_short(board_short)
    return render_template(
        'board.html',
        current_board=current_board.dump_to_dict(),
        boards=Engine.get_boards_dumped(),
        posts=Engine.get_threads_preview_dumped(current_board))
Beispiel #3
0
def thread_handle(board_short, thread_post_id):
    current_board = Engine.get_board_by_short(board_short)
    return render_template(
        'thread.html',
        current_board=current_board.dump_to_dict(),
        boards=Engine.get_boards_dumped(),
        posts=[Engine.get_thread_dumped(current_board, thread_post_id)])
Beispiel #4
0
def board_make_post_handle(board_short):
    board = Engine.get_board_by_short(board_short)
    parent_post_id = int(request.args.get('parent_post_id'))
    body = request.args.get('body')
    head = request.args.get('head')
    files = json.loads(request.args.get('files'))

    parent_post = None
    if parent_post_id == 1:
        parent_post = Post.query.filter_by(id=parent_post_id).first()
    else:
        parent_post = Post.query.filter_by(id=parent_post_id,
                                           board=board).first()

    if not parent_post:
        return "<h1>There is no such post :|</h1>"

    new_post = Post(parent=parent_post, head=head, body=body, board=board)
    db.session.add(new_post)
    db.session.commit()

    Engine.associate_with_post(files, new_post)

    thread_post = get_thread_post(new_post)
    return redirect('/%s/thread/%s' % (board.short, thread_post.id))