Exemplo n.º 1
0
class Manufacturer(db.Model):
    __tablename__ = 'manufacturer'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))

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

    def __repr__(self):
        return '<Manufacturer %r>' % self.name.capitalize()
Exemplo n.º 2
0
class User(UserMixin, db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    fullname = db.Column(db.String(80))
    email = db.Column(db.String(35), unique=True)
    username = db.Column(db.String(25), unique=True)
    password = db.Column(db.String(60))
    creation_date = db.Column(db.DateTime)
    is_approved = db.Column(db.Boolean, default=False)
    is_admin = db.Column(db.Boolean, default=False)
    is_contributor = db.Column(db.Boolean, default=False)

    # user = User(fullname='sunil', username='******', email='*****@*****.**', password='******', is_approved=True, is_admin=True, is_contributor=True)
    # INSERT INTO User ('sunil', 'sunilzs', '*****@*****.**', 'hello123','2018-12-04 03:29:41', 1, 1, 1)
    def __init__(self,
                 fullname,
                 email,
                 username,
                 password,
                 is_approved=False,
                 is_admin=False,
                 is_contributor=False):
        self.fullname = fullname
        self.email = email
        self.username = username
        self.password = password
        self.creation_date = datetime.utcnow()
        self.is_approved = is_approved
        self.is_admin = is_admin
        self.is_contributor = is_contributor

    def __repr__(self):
        return '<User %r>' % self.username
Exemplo n.º 3
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()
Exemplo n.º 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
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
class DefectType(db.Model):
    __tablename__ = 'defect_type'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    primary_type = db.Column(db.String(80))
    secondary_type = db.Column(db.String(80))

    # is_approved = db.Column(db.Boolean, default=False)

    def __init__(self, name, primary_type, secondary_type):
        self.name = name.lower()
        self.primary_type = primary_type
        self.secondary_type = secondary_type

    def __repr__(self):
        return '<DefectType %r>' % self.name.capitalize()
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
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