def create_car(current_user_token): # comes from token_required decorator """create_car will be our_flask_function""" name = request.json['name'] model = request.json['model'] make = request.json['make'] year = request.json['year'] category = request.json['category'] seats = request.json['seats'] horsepower = request.json['horsepower'] torque = request.json['torque'] color = request.json['color'] interior = request.json['interior'] user_token = current_user_token.token # comes from token_required wrapper car = Car(name, model, make, year, category, seats, horsepower, torque, color, interior, user_token=user_token) db.session.add(car) db.session.commit() response = car_schema.dump( car) # turns sql data into list obj that can be jsonified return jsonify(response)
def add_car(): model = request.json['model'] year = request.json['year'] color = request.json['color'] price = request.json['price'] new_car = Car(model,year,color,price) db.session.add(new_car) db.session.commit() return car_schema.jsonify(new_car)
def create_car(current_user_token): print(current_user_token) make = request.json['make'] model = request.json['model'] color = request.json['color'] price = request.json['price'] user_id = current_user_token.token car = Car(make, model, color, price, user_id=user_id) db.session.add(car) db.session.commit() response = car_schema.dump(car) return jsonify(response)
def create_car(current_user_token): print(current_user_token) name = request.json['name'] price = request.json['price'] model = request.json['model'] year = request.json['year'] user_id = current_user_token.token test_user = User.query.filter_by(email='*****@*****.**').first() print(user_id == test_user.token) car = Car(name, price, model, year, user_id=user_id) db.session.add(car) db.session.commit() response = car_schema.dump(car) return jsonify(response)