def create_review(place_id): content = request.get_json() if content is None: return (jsonify({"error": "Not a JSON"}), 400) my_place = storage.get("Place", place_id) if my_place is None: abort(404) user_id = content.get("user_id") if user_id is None: return (jsonify({"error": "Missing user_id"}), 400) my_user = storage.get("User", user_id) if my_user is None: abort(404) text = content.get("text") if text is None: return (jsonify({"error": "Missing text"}), 400) new_review = Review() new_review.place_id = my_place.id for key, val in content.items(): setattr(new_review, key, val) new_review.save() return (jsonify(new_review.to_dict()), 201)