d0863325a5
But for real, it's a real shitstorm in there. - Added context by making the init go through a function and not implicitly happen via imports - Fixup all context and contextless function mixups - splitup the models in sensible different files - give the dump of view functions in views/__init__.py their own file - add all routes via blueprints, not half of them - move the slack notifications function and class to its own file, no idea what it was doing in a views file in the first place.
20 lines
705 B
Python
20 lines
705 B
Python
from models import db
|
|
|
|
|
|
class Product(db.Model):
|
|
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, name, price):
|
|
self.location = location
|
|
self.name = name
|
|
self.price = price
|
|
|
|
def __repr__(self):
|
|
return '%s (€%d)from %s' % (self.name, self.price / 100, self.location
|
|
or 'None')
|