forked from AdaGold/retro-video-store
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Ocelots-Jennifer and Cindy #10
Open
ciindii
wants to merge
38
commits into
ada-ac2:main
Choose a base branch
from
Jewelhae:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
80f9689
updated customer.py and video.py.CRUD for customer created
Jewelhae 6a0c9b0
wave 1 draft, working on debugging
Jewelhae 645ae16
added rental model and bluebrints
ciindii bd153be
Merge branch 'main' of https://github.com/Jewelhae/retro-video-store-g6
ciindii a64e5ef
added blueprints for customer, video, and rental
ciindii 25846f1
added rental model and blueprints
ciindii 6e42557
added rental route post
ciindii d86de09
fixed routes
ciindii 68a40bb
wave one bugs
ciindii d3069e6
wave 1 finished -bugfree
Jewelhae 7c780c0
nothing to commit
ciindii daae927
merge routes
ciindii 7495ffb
rental check in and out routes along with the rental model
ciindii 46e1e3d
get routes for customers and video rentals
ciindii b40a521
added sorting function to customer and video route.
Jewelhae 4be50fc
add pagination to customer route and 11 test passed.
Jewelhae 8877798
modified test_wave_03
Jewelhae a1440e5
rewrote wave 2, updated models
ciindii c5b2cf4
updated wave 2 and models
ciindii b976fbd
add to_dict and from_dict back to customer and video models.
Jewelhae d38f205
updated fixture
Jewelhae ff3b70b
sort and pag for get customer/rentals
ciindii e84b97d
added sort and pag for videos/<video_id>/rentals
ciindii a9cc67c
fixed delete after checkin in checkin route
Jewelhae 354bbf5
refactored sort function and pagination function
Jewelhae 5456043
refactored rental routes
Jewelhae 5a07bde
migration
Jewelhae 8b488f4
change datetime to date
Jewelhae 8e2de64
modified rental route
Jewelhae b4e9dd2
change rental duedate to date
Jewelhae f092ddf
modified rental model
Jewelhae 9796562
modified routes
Jewelhae 7438f1e
modified rental routes
Jewelhae a327188
modified rental routes
Jewelhae e96464e
modified rental routes
Jewelhae 1ab8589
modified rental routes
Jewelhae 86653cf
modified rental routes
Jewelhae 4f159f4
modified rental route
Jewelhae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
from app import db | ||
from flask_sqlalchemy import SQLAlchemy | ||
from sqlalchemy.sql.functions import now | ||
|
||
class Customer(db.Model): | ||
id = db.Column(db.Integer, primary_key=True) | ||
name = db.Column(db.String) | ||
registered_at = db.Column(db.Date, nullable=True) | ||
postal_code = db.Column(db.String) | ||
phone = db.Column(db.String) | ||
|
||
def to_dict(self): | ||
customer_as_dict = {} | ||
customer_as_dict["id"] = self.id | ||
customer_as_dict["name"] = self.name | ||
#customer_as_dict["registered_at"] = self.registered_at | ||
customer_as_dict["postal_code"] = self.postal_code | ||
customer_as_dict["phone"] = self.phone | ||
|
||
return customer_as_dict | ||
|
||
@classmethod | ||
def from_dict(cls, customer_data): | ||
new_customer = Customer(name = customer_data["name"], | ||
#registered_at=customer_data["registered_at"], | ||
postal_code = customer_data["postal_code"], | ||
phone = customer_data["phone"]) | ||
return new_customer | ||
|
||
@classmethod | ||
def get_id(cls, id): | ||
return Customer.query.get(id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
from app import db | ||
from app.models.video import Video | ||
from app.models.customer import Customer | ||
from sqlalchemy import func | ||
from datetime import timedelta | ||
from .video import Video | ||
from .customer import Customer | ||
from datetime import datetime, timedelta, date | ||
|
||
class Rental(db.Model): | ||
id = db.Column(db.Integer, primary_key=True) | ||
id = db.Column(db.Integer, primary_key=True, autoincrement=True) | ||
due_date = db.Column(db.Date, nullable=True) | ||
#is_checked_out = db.Column(db.Boolean, default=True) | ||
video_id = db.Column(db.Integer, db.ForeignKey('video.id')) | ||
customer_id = db.Column(db.Integer, db.ForeignKey('customer.id')) | ||
|
||
''' | ||
@staticmethod | ||
def due_date(): | ||
due_date = datetime.today() + timedelta(days=7) | ||
return due_date | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,27 @@ | ||
from app import db | ||
|
||
class Video(db.Model): | ||
id = db.Column(db.Integer, primary_key=True) | ||
id = db.Column(db.Integer, primary_key=True,autoincrement = True) | ||
title = db.Column(db.String) | ||
release_date = db.Column(db.Date, nullable=True) | ||
total_inventory = db.Column(db.Integer, default=0) | ||
customer = db.relationship("Customer", secondary="rental", backref="video") | ||
|
||
def to_dict(self): | ||
video_as_dict = {} | ||
video_as_dict["id"] = self.id | ||
video_as_dict["title"] = self.title | ||
video_as_dict["release_date"] = self.release_date | ||
video_as_dict["total_inventory"] = self.total_inventory | ||
return video_as_dict | ||
|
||
@classmethod | ||
def from_dict(cls, video_data): | ||
new_video = Video(title = video_data["title"], | ||
release_date=video_data["release_date"], | ||
total_inventory = video_data['total_inventory']) | ||
return new_video | ||
|
||
@classmethod | ||
def get_id(cls, id): | ||
return Video.query.get(id) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice job setting up the relationship