Skip to content
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

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

Conversation

rachael-mcbride
Copy link

No description provided.

rachael-mcbride and others added 30 commits November 5, 2021 16:24
… routes.py file; registers customers_bp blueprint in app/__init__.py
…y, and adds a separate helpers.py file for shared validation helper methods
…iting, and pagination functionality for GET requests for videos and customers
Copy link

@spitsfire spitsfire left a 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +21 to +27
return Customer(
name=request_data["name"],
postal_code=request_data["postal_code"],
phone=request_data["phone"],
register_at = datetime.now()
)

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!

Suggested change
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)

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)

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"])

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"])

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"])

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"])

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"])

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"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants