def update_car(current_user_token, id): car = Car.query.get(id) car.car_make = request.json['car_make'] car.car_model = request.json['car_model'] car.car_year = request.json['car_year'] car.car_color = request.json['car_color'] car.user_token = current_user_token.token db.session.commit() response = car_schema.dump(car) return jsonify(response)
def create_car(current_user_token): car_make = request.json['car_make'] car_model = request.json['car_model'] car_year = request.json['car_year'] car_color = request.json['car_color'] user_token = current_user_token.token car = Car(car_make, car_model, car_year, car_color, user_token=user_token) db.session.add(car) db.session.commit() response = car_schema.dump(car) return jsonify(response)
def update_car(current_user_token, id): # Grabbing the car from the table - instance is denoted by the id car = Car.query.get(id) #Getting a car instance # Then grab each individual attribute and update zero or more of the following values car.make = request.json['make'] car.model = request.json['model'] car.sale_price = request.json['sale_price'] car.color = request.json['color'] car.year = request.json['year'] car.mpg = request.json['mpg'] car.new_used = request.json['new_used'] car.user_token = current_user_token.token # Then commit it to the database db.session.commit() response = car_schema.dump(car) return jsonify(response)
def create_car(current_user_token): make = request.json['make'] model = request.json['model'] sale_price = request.json['sale_price'] color = request.json['color'] year = request.json['year'] mpg = request.json['mpg'] new_used = request.json['new_used'] user_token = current_user_token.token car = Car(make, model, sale_price, color, year, mpg, new_used, user_token=user_token) db.session.add(car) db.session.commit() response = car_schema.dump(car) return jsonify(response)
def delete_car(current_user_token, id): car = Car.query.get(id) db.session.delete(car) db.session.commit() response = car_schema.dump(car) return jsonify(response)
def get_car(current_user_token, id): car = Car.query.get(id) response = car_schema.dump(car) return jsonify(response)