Remove old, database-based models

This commit is contained in:
Midgard 2020-01-26 02:13:02 +01:00
parent 996444e1b0
commit f2c6ad9c89
Signed by: midgard
GPG key ID: 511C112F1331BBB4
3 changed files with 1 additions and 53 deletions

View file

@ -11,8 +11,7 @@
# ...
from .database import db
from .location import Location
from .order import Order
from .orderitem import OrderItem
from .product import Product
from .orderitemchoice import OrderItemChoice
from .user import User

View file

@ -1,26 +0,0 @@
"Script for everything Location related in the database"
import typing
from models import db
class Location(db.Model):
"Class used for configuring the Location model in the database"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(120), nullable=False)
address = db.Column(db.String(254))
website = db.Column(db.String(120))
telephone = db.Column(db.String(20), nullable=True)
products = db.relationship("Product", backref="location", lazy="dynamic")
orders = db.relationship("Order", backref="location", lazy="dynamic")
def configure(self, name: str, address: str,
telephone: typing.Optional[str], website: str) -> None:
"Configure the Location"
self.name = name
self.address = address
self.website = website
self.telephone = telephone
def __repr__(self) -> str:
return "%s" % (self.name)

View file

@ -1,25 +0,0 @@
"Script for everything Product related in the database"
from models import db
from .location import Location
class Product(db.Model):
"Class used for configuring the Product model in the database"
id = db.Column(db.Integer, primary_key=True)
location_id = db.Column(db.Integer, db.ForeignKey("location.id"))
name = db.Column(db.String(120), nullable=False)
price = db.Column(db.Integer, nullable=False)
orderItems = db.relationship("OrderItem",
backref="product", lazy="dynamic")
def configure(self, location: Location, name: str, price: int) -> None:
"Configure the Product"
# pylint: disable=W0201
self.location = location
self.name = name
self.price = price
def __repr__(self) -> str:
return "%s (€%d)from %s" % (self.name, self.price / 100,
self.location or "None",)