-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maple - Mariama & Rachael #36
base: master
Are you sure you want to change the base?
Conversation
… routes.py file; registers customers_bp blueprint in app/__init__.py
…y, and adds a separate helpers.py file for shared validation helper methods
…in video_route.py
…details method was repeated twice)
…sed on optional query params
…iting, and pagination functionality for GET requests for videos and customers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heck yeah, Mariama and Rachael! This was a lot of fun to grade! You had a lot of great ideas for helper functions and separating out actions! I gave a few suggestions on how to clean up a few of your functions, but all in all this was great!
Good work!!
id = db.Column(db.Integer, primary_key=True, autoincrement=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
return Customer( | ||
name=request_data["name"], | ||
postal_code=request_data["postal_code"], | ||
phone=request_data["phone"], | ||
register_at = datetime.now() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo good idea! one thing to think about is, in order to use this method, it already needs an instance, which defeats the purpose of your method. BUT! why don't we change it into a @classmethod
?? Now we can call it directly on the class Customer itself!
def new_customer(self, request_data): | |
return Customer( | |
name=request_data["name"], | |
postal_code=request_data["postal_code"], | |
phone=request_data["phone"], | |
register_at = datetime.now() | |
) | |
@classmethod | |
def new_customer(cls, request_data): | |
return cls( | |
name=request_data["name"], | |
postal_code=request_data["postal_code"], | |
phone=request_data["phone"], | |
register_at = datetime.now() | |
) |
id = db.Column(db.Integer, primary_key=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
id = db.Column(db.Integer, primary_key=True, autoincrement=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
customers_bp = Blueprint("customer", __name__, url_prefix="/customers") | ||
|
||
@customers_bp.route("", methods=["GET"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
rentals_response = [rental.to_json() for rental in rentals] | ||
return jsonify(rentals_response), 200 | ||
|
||
@rentals_bp.route("/check-out", methods=["POST"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
return video_to_check_out.to_json(), 200 | ||
|
||
@rentals_bp.route("/check-in", methods=["POST"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
videos_response = [video.to_json() for video in videos] | ||
return jsonify(videos_response), 200 | ||
|
||
@videos_bp.route("", methods=["POST"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
return jsonify(video.to_json()), 201 | ||
|
||
@videos_bp.route("/<video_id>", methods=["GET", "PUT", "DELETE"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
db.session.commit() | ||
return make_response({"id": video.id}, 200) | ||
|
||
@videos_bp.route("<video_id>/rentals", methods=["GET"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
No description provided.