def index_POST(board, **_): form = CreateColumnForm(request.form) if not form.validate_on_submit(): return jsonify(form.errors), 400 column = Column() form.populate_obj(column) column.board_id = board.id column.created_by = current_user.id column.save() board.columns.append(column) board.save() return jsonify({ 'column': column, }), 201
def create_column(cls, board, **kwargs): column = Column() column.board_id = board.id column.created_by = kwargs.get('created_by', cls.user.id) column.name = kwargs.get( 'name', cls.fake.pystr(min_chars=1, max_chars=256), ) saved_column = column.save() board.columns.append(saved_column) board.save() return saved_column