haldis/app/models/location.py

27 lines
925 B
Python
Raw Normal View History

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