class User(db.Model, UserMixin):
    #__tablename__ = "User"

    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)
    posts = db.relationship('Post', backref='author', lazy=True)
    api_keys = db.relationship('API_Key', backref='keyowner', lazy=True)
    emotion_predictions = db.relationship('EmotionPrediction',
                                          backref='uploader',
                                          lazy=True)

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

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(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}')"
Пример #2
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)
    posts = db.relationship('Post', backref='author', lazy=True)
    packings = db.relationship('Packing', backref='author', lazy=True)

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

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

    #testin fix this when ready

    def __repr__(self):
        return f"User('{self.username}','{self.email}', '{self.image_file}')"
Пример #3
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=False, nullable=False)

    first_name = db.Column(db.String(50), unique=False, nullable=False)
    last_name = db.Column(db.String(50), unique=False, nullable=False)
    postal_code = db.Column(db.Integer, unique=False, nullable=False)
    prefecture = db.Column(db.String(120),
                           unique=False,
                           nullable=False,
                           default='Tokyo')
    my_number = db.Column(db.Integer, unique=False, nullable=False)

    email = db.Column(db.String(120), unique=False, nullable=False)
    image_file = db.Column(db.String(20),
                           unique=False,
                           nullable=False,
                           default="default.jpg")
    password = db.Column(db.String(60), nullable=False)

    location_id = db.Column(db.Integer,
                            db.ForeignKey('park.id'),
                            unique=False,
                            nullable=True,
                            default=0)
    posts = db.relationship('Post', backref='author', lazy=True)
    reservations = db.relationship('Reservation', backref='creator', lazy=True)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Пример #4
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)
    posts = db.relationship('Post', backref='author', lazy=True)
    selections = db.relationship('Selection', backref='user', lazy=True)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Пример #5
0
class Packing(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)

    containers = db.relationship('Container', backref='packing', lazy=True)
    boxes = db.relationship('Box', backref='packing', lazy=True)

    def __repr__(self):
        return f"Packing('{self.name}', '{self.date_created}', id: '{self.id}')"
Пример #6
0
class Sala(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    Numero = db.Column(db.Integer, nullable=False)
    estantes = db.relationship('Estante', backref='owner', lazy=True)

    def __repr__(self):
        return '<Sala %r>' % self.id
Пример #7
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)
    # One-to-many connection to Post, backref as the connecting data
    posts = db.relationship('Post', backref='author', lazy=True)

    # The method to get the password reset token that's valid for 30 minutes
    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')

    # A static method for verifying the reset token
    @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}')"
Пример #8
0
class Estante(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    Patrimonio = db.Column(db.String(200), nullable=False)
    Sala_id = db.Column(db.Integer, db.ForeignKey('sala.id'), nullable=True)
    caixas = db.relationship('Caixa', backref='owner', lazy=True)

    def __repr__(self):
        return '<Estante %r>' % self.id
Пример #9
0
class Pessoa(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nome = db.Column(db.String(200), nullable=False)
    telefone = db.Column(db.Integer, nullable=False)
    email = db.Column(db.String(200), nullable=False)
    date_created = db.Column(db.DateTime, default=datetime.utcnow)
    responsabilidade = db.relationship('Sala',
                                       secondary=responsavel,
                                       backref=db.backref('responsaveis',
                                                          lazy='dynamic'))
    encarregar = db.relationship('Projeto',
                                 secondary=encarregado,
                                 backref=db.backref('encarregados',
                                                    lazy='dynamic'))

    #TYPE ENUM - PESQUISADOR, ALUNO RESPONSAVEL, OUTROS COLABORADORES, ADMIN
    def __repr__(self):
        return '<Pessoa %r>' % self.id
Пример #10
0
class Park(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    prefecture = db.Column(db.String(100), nullable=False)
    area = db.Column(db.Float, nullable=False)
    lat = db.Column(db.Float, nullable=False)
    lon = db.Column(db.Float, nullable=False)
    capacity = db.Column(db.Integer, nullable=False, default=0)
    count = db.Column(db.Integer, nullable=False, default=0)
    image_file = db.Column(db.String(100),
                           unique=False,
                           nullable=False,
                           default="default.jpg")
    fake_distance = db.Column(db.Integer, nullable=False, default=69)
    people = db.relationship('User', backref='location', lazy=True)
    reservations = db.relationship('Reservation', backref='place', lazy=True)

    def __repr__(self):
        return f"Post('{self.name}', '{self.prefecture}', '{self.area}', {self.lat}', '{self.lon}', '{self.capacity}', '{self.present}')"
Пример #11
0
class Caixa(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    Patrimonio = db.Column(db.String(200), nullable=False)
    Estante_id = db.Column(db.Integer,
                           db.ForeignKey('estante.id'),
                           nullable=True)
    animais = db.relationship('Animal', backref='owner', lazy=True)
    Projeto_id = db.Column(db.Integer,
                           db.ForeignKey('projeto.id'),
                           nullable=True)

    def __repr__(self):
        return '<Caixa %r>' % self.id
Пример #12
0
class Projeto(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    CEUA = db.Column(db.Integer)
    Data_Exp_CEUA = db.Column(db.Integer)
    N_Animais_Aprovados = db.Column(db.Integer)
    N_Animais_Bioterio = db.Column(db.Integer)
    Data_Ent_Bioterio = db.Column(db.Integer)
    Data_Saida = db.Column(db.Integer)
    Motivo_Saida = db.Column(db.String(200), nullable=False)
    Status = db.Column(db.String(200), nullable=False)
    Nome = db.Column(db.String(200), nullable=False)
    Descricao = db.Column(db.String(200), nullable=False)

    caixas_projeto = db.relationship('Caixa', backref='Projeto', lazy=True)

    def __repr__(self):
        return '<Caixa %r>' % self.id