haldis/app/models/location.py

27 lines
925 B
Python
Raw Normal View History

2019-09-09 23:06:11 +00:00
"Script for everything Location related in the database"
2019-09-07 22:41:50 +00:00
import typing
from models import db
class Location(db.Model):
2019-09-09 23:06:11 +00:00
"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)
2019-09-05 01:33:29 +00:00
products = db.relationship("Product", backref="location", lazy="dynamic")
orders = db.relationship("Order", backref="location", lazy="dynamic")
2019-09-09 23:06:11 +00:00
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
2019-09-07 22:41:50 +00:00
def __repr__(self) -> str:
2019-09-05 01:33:29 +00:00
return "%s" % (self.name)