Beispiel #1
0
class Size(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(120), unique=True, nullable=False)
    fabric_multiplier = db.Column(db.Float, nullable=False)

    def __repr__(self):
        return f"Size('{self.name}', '{self.id}')"
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    role = db.Column(db.Integer, db.ForeignKey('role.id'), nullable=True)

    def __repr__(self):
        return f"User('{self.id}', '{self.email}', '{self.role}')"
Beispiel #3
0
class OrderedComponent(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    quantity = db.Column(db.Integer, nullable=False)
    component = db.Column(db.ForeignKey('component.id'), nullable=False)
    product_fk = db.Column(db.ForeignKey('product.id'), nullable=False)
    product = db.relationship('Product', backref=db.backref('components', lazy=True), lazy=True)

    def __repr__(self):
        return f"OrderedComponent('{self.quantity}', '{self.component}')"
Beispiel #4
0
class OrderItem(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    quantity = db.Column(db.Integer, nullable=False)
    product = db.Column(db.ForeignKey('product.id'), nullable=False)
    size = db.Column(db.ForeignKey('size.id'), nullable=False)
    order = db.relationship('Order', backref=db.backref('items', lazy=True), lazy=True)
    order_fk = db.Column(db.ForeignKey('order.id'), nullable=False)

    def __repr__(self):
        return f"Item('{self.quantity}', '{self.size}')"
Beispiel #5
0
class Component(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(120), unique=False, nullable=False)
    color = db.Column(db.ForeignKey('color.id'), nullable=False)
    fabric = db.Column(db.Boolean, nullable=False, default=False)
    quantity = db.Column(db.Float, nullable=False)

    def __repr__(self):
        return f"Component('{self.name}', '{self.quantity}')"

    def to_json(self):
        return {"nazwa": self.name, "kolor": self.color, "ilosc": str(self.quantity)}
Beispiel #6
0
class Order(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(120), nullable=False)
    completed = db.Column(db.Boolean, nullable=False, default=False)
    requires_action = db.Column(db.Boolean, nullable=False, default=False)
    position = db.Column(db.ForeignKey('role.id'), nullable=False, default=1)
    message = db.Column(db.String(120), nullable=True)

    def __repr__(self):
        return f"Order('{self.name}', '{self.id}')"
Beispiel #7
0
class Product(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(120), unique=True, nullable=False)

    def __repr__(self):
        return f"Product('{self.name}')"
class Role(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(60), unique=True, nullable=False)

    def __repr__(self):
        return f"Role('{self.id}', '{self.name}')"