Esempio n. 1
0
class Customer(db.Model):  #UserMixin,

    __tablename__ = 'customers'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(60), index=True, unique=True)
    type = db.Column(db.String(60))
    role_id = db.Column(db.Integer, db.ForeignKey('roles.id'), nullable=True)

    def __repr__(self):
        return '<Customer name is: {}>'.format(self.name)
Esempio n. 2
0
class Product(db.Model):

    __tablename__ = 'products'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    manufacturer_id = db.Column(db.Integer,
                                db.ForeignKey('manufacturers.id'),
                                nullable=True)

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return '<Product: {0}\n{1}>'.format(self.name)
Esempio n. 3
0
class Delivery(db.Model):

    __tablename__ = 'deliveries'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(60), index=True, unique=True)
    tracking_number = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('customers.id'),
                        nullable=True)

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return '<Delivery company: {0}\n{1}>'.format(self.name)
Esempio n. 4
0
class Contract(db.Model):

    __tablename__ = 'contracts'

    id = db.Column(db.Integer, primary_key=True)
    card_info = db.Column(db.Integer)
    bill_number = db.Column(db.String(60), index=True, unique=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('customers.id'),
                        nullable=True)

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return '<Contract: {0}\n{1}>'.format(self.name)
Esempio n. 5
0
class BlogPost(db.Model):
    # This initiates the review table and associates user to it.
    users = db.relationship(User)

    # This initiates the id for each review.
    id = db.Column(db.Integer, primary_key=True)
        # The foreign key with the review id creates a unique instance.
        # The date, title and text compose the review for the now, it does
        # not feature product information.
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    title = db.Column(db.String(140), nullable=False)
    text = db.Column(db.Text, nullable=False)

    def __init__(self, title, text, user_id):
        self.title = title
        self.text = text
        self.user_id =user_id

    def __repr__(self):
        return f"Post Id: {self.id} --- Date: {self.date} --- Title: {self.title}"