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

Ocelots-Jennifer and Cindy #10

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Jan 5, 2023
6a0c9b0
wave 1 draft, working on debugging
Jewelhae Jan 5, 2023
645ae16
added rental model and bluebrints
ciindii Jan 5, 2023
bd153be
Merge branch 'main' of https://github.com/Jewelhae/retro-video-store-g6
ciindii Jan 5, 2023
a64e5ef
added blueprints for customer, video, and rental
ciindii Jan 5, 2023
25846f1
added rental model and blueprints
ciindii Jan 5, 2023
6e42557
added rental route post
ciindii Jan 5, 2023
d86de09
fixed routes
ciindii Jan 5, 2023
68a40bb
wave one bugs
ciindii Jan 5, 2023
d3069e6
wave 1 finished -bugfree
Jewelhae Jan 6, 2023
7c780c0
nothing to commit
ciindii Jan 6, 2023
daae927
merge routes
ciindii Jan 6, 2023
7495ffb
rental check in and out routes along with the rental model
ciindii Jan 6, 2023
46e1e3d
get routes for customers and video rentals
ciindii Jan 7, 2023
b40a521
added sorting function to customer and video route.
Jewelhae Jan 7, 2023
4be50fc
add pagination to customer route and 11 test passed.
Jewelhae Jan 7, 2023
8877798
modified test_wave_03
Jewelhae Jan 8, 2023
a1440e5
rewrote wave 2, updated models
ciindii Jan 8, 2023
c5b2cf4
updated wave 2 and models
ciindii Jan 8, 2023
b976fbd
add to_dict and from_dict back to customer and video models.
Jewelhae Jan 8, 2023
d38f205
updated fixture
Jewelhae Jan 8, 2023
ff3b70b
sort and pag for get customer/rentals
ciindii Jan 8, 2023
e84b97d
added sort and pag for videos/<video_id>/rentals
ciindii Jan 8, 2023
a9cc67c
fixed delete after checkin in checkin route
Jewelhae Jan 8, 2023
354bbf5
refactored sort function and pagination function
Jewelhae Jan 9, 2023
5456043
refactored rental routes
Jewelhae Jan 9, 2023
5a07bde
migration
Jewelhae Jan 9, 2023
8b488f4
change datetime to date
Jewelhae Jan 9, 2023
8e2de64
modified rental route
Jewelhae Jan 9, 2023
b4e9dd2
change rental duedate to date
Jewelhae Jan 9, 2023
f092ddf
modified rental model
Jewelhae Jan 9, 2023
9796562
modified routes
Jewelhae Jan 10, 2023
7438f1e
modified rental routes
Jewelhae Jan 10, 2023
a327188
modified rental routes
Jewelhae Jan 10, 2023
e96464e
modified rental routes
Jewelhae Jan 10, 2023
1ab8589
modified rental routes
Jewelhae Jan 10, 2023
86653cf
modified rental routes
Jewelhae Jan 10, 2023
4f159f4
modified rental route
Jewelhae Jan 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@ def create_app(test_config=None):
migrate.init_app(app, db)

#Register Blueprints Here
from .routes import customers_bp
app.register_blueprint(customers_bp)

from .routes import videos_bp
app.register_blueprint(videos_bp)

from .routes import rentals_bp
app.register_blueprint(rentals_bp)

return app
28 changes: 28 additions & 0 deletions app/models/customer.py
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)
20 changes: 19 additions & 1 deletion app/models/rental.py
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
'''
25 changes: 24 additions & 1 deletion app/models/video.py
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")

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


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)
Loading