Пример #1
0
class Product(db.Model):
    __tablename__ = 'product'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    spec_file_name = db.Column(db.String(80))
    spec_image_name = db.Column(db.String(80))
    total_samples = db.Column(db.Integer)
    sample_counter = db.Column(db.Integer)
    manufacturer = db.Column(db.Integer, db.ForeignKey('manufacturer.id'))
    is_approved = db.Column(db.Boolean, default=False)

    def __init__(self,
                 name,
                 manufacturer_id,
                 total_samples,
                 sample_counter=0,
                 spec_file_name=None,
                 spec_image_name=None,
                 is_approved=False):
        self.name = name.lower()
        self.manufacturer = manufacturer_id
        self.total_samples = total_samples
        self.sample_counter = sample_counter
        self.spec_file_name = spec_file_name
        self.spec_image_name = spec_image_name
        self.is_approved = is_approved

    def __repr__(self):
        return '<Product %r>' % self.name.capitalize()
Пример #2
0
class Defect(db.Model):
    __tablename__ = 'defect'
    id = db.Column(db.Integer, primary_key=True)
    chip = db.Column(db.Integer, db.ForeignKey('chip.id'))
    sample = db.Column(db.Integer, db.ForeignKey('sample.id'))
    defect_type = db.Column(db.Integer, db.ForeignKey('defect_type.id'))
    defect_image_name = db.Column(db.String(256))
    creation_date = db.Column(db.DateTime)

    def __init__(self, chip_id, sample_id, defect_type_id, defect_image_name):
        self.chip = chip_id
        self.sample = sample_id
        self.defect_type = defect_type_id
        self.defect_image_name = defect_image_name
        spec_image_name = db.Column(db.String(80))
        self.creation_date = datetime.utcnow()

    def __repr__(self):
        return '<Defect %r>' % self.id
Пример #3
0
class Chip(db.Model):
    __tablename__ = 'chip'
    id = db.Column(db.Integer, primary_key=True)
    user = db.Column(db.Integer, db.ForeignKey('user.id'))
    product = db.Column(db.Integer, db.ForeignKey('product.id'))
    manufacturer = db.Column(db.Integer, db.ForeignKey('manufacturer.id'))
    is_approved = db.Column(db.Boolean, default=True)
    __table_args__ = (db.UniqueConstraint('user',
                                          'product',
                                          'manufacturer',
                                          name='user_manufacturer_product'), )

    def __init__(self, user, manufacturer, product):
        self.user = user
        self.manufacturer = manufacturer
        self.product = product
        self.creation_date = datetime.utcnow()

    def __repr__(self):
        return '<Chip %r>' % self.id
Пример #4
0
class Sample(db.Model):
    __tablename__ = 'sample'
    id = db.Column(db.Integer, primary_key=True)
    sample_id = db.Column(db.Integer)
    chip = db.Column(db.Integer, db.ForeignKey('chip.id'))
    creation_date = db.Column(db.DateTime)
    is_approved = db.Column(db.Boolean, default=True)

    def __init__(self, sample_id, chip):
        self.sample_id = sample_id
        self.chip = chip
        self.creation_date = datetime.utcnow()

    def __repr__(self):
        return '<Sample %r>' % self.id
Пример #5
0
class Dataset(db.Model):
    __tablename__ = 'dataset'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(25))
    description = db.Column(db.String(256))
    filename = db.Column(db.String(80))
    user = db.Column(db.Integer, db.ForeignKey('user.id'))
    creation_date = db.Column(db.DateTime)


    def __init__(self, name, description, filename, user_id):
        self.name = name
        self.description = description
        self.filename = filename
        self.user = user_id
        self.creation_date = datetime.utcnow()

    def __repr__(self):
        return '<User %r>' % self.filename