Exemplo n.º 1
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    multipleupload = db.Column(db.Integer, default=0)
    items = db.relationship('Item', backref='owner', lazy=True)
    targets = db.relationship('Target', backref='searcher', lazy=True)

    def get_reset_token(self, expires_sec=1800):
        s = Serializer(current_app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Exemplo n.º 2
0
class Item(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    item_file = db.Column(db.String(20), nullable=False, default='default.jpg')
    itemname = db.Column(db.String(100), nullable=False)
    thumbnail = db.Column(db.String(20), nullable=False, default='default.jpg')
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    analysis_keywords = db.Column(db.Boolean, nullable=False, default=False)
    analysis_persons = db.Column(db.Boolean, nullable=False, default=False)
    analysis_celebs = db.Column(db.Boolean, nullable=False, default=False)
    analysis_targets = db.Column(db.Boolean, nullable=False, default=False)
    analysis_text = db.Column(db.Boolean, nullable=False, default=False)
    analysis_labels = db.Column(db.Boolean, nullable=False, default=False)
    analysis_threshold = db.Column(db.Integer, default=False)
    text = db.Column(db.String(1000), nullable=False, default='')
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    itemkeywords = db.relationship('ItemKeyword',
                                   backref='itemin',
                                   lazy=True,
                                   cascade="delete")
    persons = db.relationship('Person',
                              backref='itemin',
                              lazy=True,
                              cascade="delete")

    def __repr__(self):
        return f"Item('{self.item_file}','{self.itemname}', '{self.thumbnail}','{self.date_posted}')"
Exemplo n.º 3
0
class Person(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_analysis = db.Column(db.DateTime,
                              nullable=False,
                              default=datetime.utcnow)
    item_id = db.Column(db.Integer, db.ForeignKey('item.id'), nullable=False)
    celebrity_id = db.Column(db.Integer, db.ForeignKey('celebrity.id'))
    targetimage_id = db.Column(db.Integer, db.ForeignKey('targetimage.id'))
    personattributes = db.relationship('PersonAttribute',
                                       backref='referenceperson',
                                       lazy=True,
                                       cascade="all, delete-orphan")
    BoundingBoxWidth = db.Column(db.Numeric(precision=18, scale=17),
                                 nullable=False,
                                 default=1)
    BoundingBoxHeight = db.Column(db.Numeric(precision=18, scale=17),
                                  nullable=False,
                                  default=1)
    BoundingBoxLeft = db.Column(db.Numeric(precision=18, scale=17),
                                nullable=False,
                                default=0)
    BoundingBoxTop = db.Column(db.Numeric(precision=18, scale=17),
                               nullable=False,
                               default=0)
    AgeLow = db.Column(db.Integer, nullable=False, default=0)
    AgeHigh = db.Column(db.Integer, nullable=False, default=999)

    def __repr__(self):
        return f"Person('{self.date_analysis, self.item_id}')"
Exemplo n.º 4
0
class Celebrity(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    url = db.Column(db.String(100), nullable=False)
    aws_id = db.Column(db.String(20), nullable=False)
    date_create = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    persons = db.relationship('Person', backref='relatedcelebrity', lazy=True)

    def __repr__(self):
        return f"Attribute('{self.name}','{self.date_create}')"
Exemplo n.º 5
0
class Attribute(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    attributetextname = db.Column(db.String(100), nullable=False)
    date_create = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    personattributes = db.relationship('PersonAttribute',
                                       backref='referenceattribute',
                                       lazy=True)

    def __repr__(self):
        return f"Attribute('{self.attributetextname}','{self.date_create}')"
Exemplo n.º 6
0
class Keyword(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    keywordtextname = db.Column(db.String(100), nullable=False)
    label = db.Column(db.Boolean, nullable=False, default=False)
    date_create = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    itemkeywords = db.relationship('ItemKeyword',
                                   backref='reference',
                                   lazy=True)

    def __repr__(self):
        return f"Keyword('{self.keywordtextname}','{self.date_create}')"
Exemplo n.º 7
0
class Target(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    targetimages = db.relationship('Targetimage',
                                   backref='imagefortarget',
                                   lazy=True,
                                   cascade="delete")

    def __repr__(self):
        return f"Target({self.name}'','{self.date_created}')"
Exemplo n.º 8
0
class Targetimage(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    target_id = db.Column(db.Integer,
                          db.ForeignKey('target.id'),
                          nullable=False)
    file = db.Column(db.String(20), nullable=False, default='default.jpg')
    name = db.Column(db.String(100), nullable=False)
    thumbnail = db.Column(db.String(20), nullable=False, default='default.jpg')
    age = db.Column(db.Integer, nullable=False, default=999)
    persons = db.relationship('Person', backref='foundtargetimage', lazy=True)

    def __repr__(self):
        return f"Targetimage('{self.date_created, self.target_id, self.name}')"