class Sound(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    sound_name = db.Column(db.String(20), index=True)
    file_uuid = db.Column(db.String(36), index=True, unique=True)
    private = db.Column(db.Boolean)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    users = db.relationship('User', secondary='sound_board')
Beispiel #2
0
class UserModel(db.Model):
    #set Table name
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(120), nullable=False)

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    @classmethod
    def find_by_username(cls, username):
        return cls.query.filter_by(username = username).first()
    
    @classmethod
    def return_all(cls):
        def to_json(x):
            return {
                'username': x.username,
                'password': x.password
            }
        return {'users': list(map(lambda x: to_json(x), UserModel.query.all()))}

    @classmethod
    def delete_all(cls):
        try:
            num_rows_deleted = db.session.query(cls).delete()
            db.session.commit()
            return {'message': '{} row(s) deleted'.format(num_rows_deleted)}
        except:
            return {'message': 'Something went wrong'}
Beispiel #3
0
class Feedback(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    message = db.Column(db.String(500))
    question = db.Column(db.String(300))
    answer = db.Column(db.String(300))
    datetime = db.Column(db.DateTime)

    def __init__(self, message, question, answer, datetime):
        self.message = message
        self.datetime = datetime
        self.question = question
        self.answer = answer

    def __repr__(self):
        return str(
            self.id
        ) + ", " + self.message + ", " + self.datetime + ", " + self.question + ", " + self.answer

    def get(self):
        return {
            "id": self.id,
            "message": self.message,
            "datetime": self.datetime,
            "question": self.question,
            "answer": self.answer
        }
Beispiel #4
0
class Enzyme(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True, nullable=False)
    catalogue_number = db.Column(db.String(64), index=True, unique=True, nullable=False)
    quantity = db.Column(db.Integer, nullable=False)

    def __repr__(self):
        return f'<Enzyme {self.name}>'
Beispiel #5
0
class ImageQueryResults(db.Model):
    __tablename__ = 'image_query_results'
    id = db.Column(db.Integer, primary_key=True)
    from_user = db.Column(db.String(20))
    chat_id = db.Column(db.String(64))
    image_results = db.Column(JSONB)

    def __init__(self, chat_id, from_user, image_results):
        self.from_user = from_user
        self.chat_id = chat_id
        self.image_results = image_results
Beispiel #6
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_viber_id = db.Column(db.String(150), unique=True)
    nickname = db.Column(db.String(50))
    quer = db.relationship('Query', backref='user', uselist=False)
    zakazi = db.relationship('Zakaz', backref='user', uselist=True)
    novaposhta = db.relationship('NP', backref='user', uselist=False)
    search = db.relationship('Search', backref='user', uselist=True)

    def __repr__(self):
        return f"User('{self.user_viber_id}')"
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    timeout = db.Column(db.DateTime)
    password_hash = db.Column(db.String(128))
    mumble_username = db.Column(db.String(128))
    admin = db.Column(db.Boolean, default=False)
    disabled = db.Column(db.Boolean, default=True)
    sounds = db.relationship('Sound', backref='owner', lazy='dynamic')
    sound_board_sounds = db.relationship('Sound', secondary='sound_board')

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Beispiel #8
0
class Datasets(db.Model):
    name = db.Column(db.String(50), primary_key=True)
    description = db.Column(db.String(300))
    features = db.Column(db.JSON)
    file = db.Column(db.String(100))

    def __init__(self, name, description, features, file):
        self.name = name
        self.description = description
        self.features = features
        self.file = file

    def __repr__(self):
        return self.name + ", " + self.description + ", " + self.features + ", " + self.file

    def set_description(self, description):
        self.description = description

    def set_features(self, features):
        self.features = features

    def set_file(self, file):
        self.file = file

    def get_info(self):
        features = self.features
        s = ""
        for feature in features:
            syns = "("
            for syn in feature["synonyms"]:
                if syn != "":
                    syns += syn + ", "
            if syns != "(":
                syns = syns[:-2] + ") "
            else:
                syns = ""
            s += "" + feature["name"] + " " + syns + "- " + feature[
                "type"] + ", "
        s = s[:-2]
        print(s)
        return [self.name, self.description, s]

    def get_values(self):
        return {
            "name": self.name,
            "description": self.description,
            "features": self.features,
            "file": self.file
        }
Beispiel #9
0
class Context(db.Model):
    __tablename__ = 'context_logs'
    id = db.Column(db.Integer, primary_key=True)
    from_user = db.Column(db.String(20))
    chat_id = db.Column(db.String(64))
    context = db.Column(JSONB)
    msg = db.Column(db.Text())
    action = db.Column(db.String(64))

    def __init__(self, chat_id, from_user, context, msg=None, action=None):
        self.from_user = from_user
        self.chat_id = chat_id
        self.context = context
        self.msg = msg
        self.action = action
Beispiel #10
0
class Statistics(db.Model):
    name = db.Column(db.String(50), primary_key=True)
    description = db.Column(db.String(300))
    templates = db.Column(db.JSON)
    file = db.Column(db.String(100))

    def __init__(self, name, description, templates, file):
        self.name = name
        self.description = description
        self.templates = templates
        self.file = file

    def __repr__(self):
        return self.name + ", " + self.description + ", " + self.templates + ", " + self.file

    def set_description(self, description):
        self.description = description

    def set_templates(self, templates):
        self.templates = templates

    def set_file(self, file):
        self.file = file

    def get_info(self):
        templates = self.templates
        s = ""
        for template in templates:
            s += template["question"] + "..."
            dels = ""
            for delimiter in template["delimiters"]:
                dels += delimiter + ", "
            dels = dels[:-2]
            if template["delimiters"] != ['']:
                s += " [" + dels + "] ..."
            s += "?, "
        s = s[:-2]
        return [self.name, self.description, s]

    def get_values(self):
        return {
            "name": self.name,
            "description": self.description,
            "templates": self.templates,
            "file": self.file
        }
Beispiel #11
0
class Query(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    query_number = db.Column(db.String(4))
    zakaz_num = db.Column(db.Integer)

    def __repr__(self):
        return f""
Beispiel #12
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(255), nullable=False)
    weather_id = db.Column(db.Integer,
                           db.ForeignKey('weather.id'),
                           nullable=False)
    weather = db.relationship('Weather', backref=db.backref('user', lazy=True))
    horoscope_id = db.Column(db.Integer,
                             db.ForeignKey('horoscope.id'),
                             nullable=False)
    horoscope = db.relationship('Horoscope',
                                backref=db.backref('user', lazy=True))
Beispiel #13
0
class RevokedTokenModel(db.Model):
    __tablename__ = 'revoked_tokens'
    id = db.Column(db.Integer, primary_key = True)
    jti = db.Column(db.String(120))
    
    def add(self):
        db.session.add(self)
        db.session.commit()
    
    @classmethod
    def is_jti_blacklisted(cls, jti):
        query = cls.query.filter_by(jti = jti).first()
        return bool(query)
Beispiel #14
0
class User(db.Model):
    '''
        Classe da entidade dos usuários no banco de dados
        :extends db.Model (Modelo)
    '''

    __tablename__ = 'users'

    # Colunas
    _id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(25))
    last_name = db.Column(db.String(25))
    gender = db.Column(db.String(6))

    # Definindo propriedades requiridas pelo SqlAlchemy
    @property
    def is_authenticated(self):
        return True

    @property
    def is_active(self):
        return True

    @property
    def get_id(self):
        return str(self._id)

    # Sobrescreve método de representação dos objetos
    def __repr__(self):
        return self.first_name

    def __init__(self, _id, first_name, last_name, gender):
        self._id = _id
        self.first_name = first_name
        self.last_name = last_name
        self.gender = gender
Beispiel #15
0
class Player(db.Model):
    pid = db.Column(db.String, primary_key=True)
    name = db.Column(db.String(120), nullable=False)
    admin = db.Column(db.Boolean, nullable=False)
    num_activities = db.Column(db.Integer, nullable=False, default=0)
    attendance = db.relationship("Attendance", backref="player")

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        db.session.add(self)
        db.session.commit()

    @staticmethod
    def is_admin(pid):
        if player := Player.query.filter_by(pid=pid).first():
            return player.admin
        return False
Beispiel #16
0
class Search(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    number = db.Column(db.String(10))
    description = db.Column(db.Text)
    ref = db.Column(db.Text)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
Beispiel #17
0
class Horoscope(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    emoji_id = db.Column(db.Integer, db.ForeignKey('emoji.id'), nullable=False)
    emoji = db.relationship('Emoji',
                            backref=db.backref('horoscope', lazy=True))
Beispiel #18
0
class Weather(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    link = db.Column(db.String(255))
Beispiel #19
0
class Emoji(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    symbol = db.Column(db.String(255))