class Team (BaseModel, db.Model): __tablename__ = 'team' __searchable__ = ['name', 'info'] # Changed the constructor for Python 2 compatibility def __init__(self, id=None, name=None, info=None, image_url=None, created=None, updated=None, user_ids=None, game_ids=None, *args): super(Team, self).__init__(*args) self.id = id self.name = name self.info = info self.image_url = image_url self.created = created self.updated = updated self.user_ids = user_ids self.game_ids = game_ids id = db.Column(db.Integer, primary_key = True) # Attributes name = db.Column(db.TEXT) info = db.Column(db.TEXT) image_url = db.Column(db.TEXT) created = db.Column(db.DateTime) updated = db.Column(db.DateTime) # Connection to other models user_ids = db.Column(db.ARRAY(db.String)) game_ids = db.Column(db.ARRAY(db.Integer))
class Items(db.Model): __tablename__ = 'items' item_id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('users.user_id'), unique=False, nullable=False) type = db.Column(db.String(50), nullable=False) location = db.Column(db.String(50), nullable=False) timestamp = db.Column(db.TIMESTAMP, nullable=False, default=datetime.now) image_path = db.Column(db.String(50), unique=True, nullable=False) caption = db.Column(db.String(50), unique=False, nullable=False) feature_vector = db.Column(db.ARRAY(db.FLOAT), nullable=False) word_vector = db.Column(db.ARRAY(db.FLOAT), nullable=False) active = db.Column(db.Boolean, default=True) user = db.relationship("Users", backref=db.backref("users", uselist=False)) def __init__(self, user_id, item_type, location, filename, description, timestamp, feature_vector, word_vector): self.user_id = user_id, self.type = item_type, self.location = location, self.filename = filename, self.caption = description, self.image_path = filename, if item_type in ['lost', 'found']: self.timestamp = datetime.fromtimestamp(timestamp) self.feature_vector = feature_vector self.word_vector = word_vector
class Paths(db.Model): __table_args__ = {'extend_existing': True} path_id = db.Column(db.Integer, primary_key=True, unique=True) name = db.Column(db.String(100), nullable=True) description = db.Column(db.String(1000000), nullable=False) checkpoints = db.Column(db.ARRAY( db.Integer)) # Array of checkpoint id values within Path interactions = db.Column(db.ARRAY( db.Integer)) # Array of interaction id values within Path pathmaker = db.Column(db.String(100), nullable=False) status = db.Column(db.String(50), nullable=False) base_format = db.Column(db.String(20), nullable=False)
class WordVector(db.Model): __tablename__ = 'word_vector' word_id = db.Column(db.Integer, primary_key=True) word = db.Column(db.String(50), nullable=False) vector = db.Column(db.ARRAY(db.FLOAT), nullable=False) def __init__(self, word, vector): self.word = word, self.vector = vector
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) card_number = db.Column(db.String(19), unique=True, nullable=False) password = db.Column(db.String(255), nullable=False) total = db.Column(db.Integer) active = db.Column(db.Boolean(), nullable=False) roles = db.Column(db.ARRAY(db.Integer), default=[]) invalid_pass_inputs = db.Column(db.Integer, default=0) def __repr__(self): return f'<User {self.card_number}>'
class Checkpoints(db.Model): __table_args__ = {'extend_existing': True} checkpoint_id = db.Column(db.Integer, primary_key=True, unique=True) text = db.Column(db.String(750), nullable=False) animation = db.Column(db.String(100), nullable=False) color = db.Column(db.String(100)) geolocation = db.Column(db.ARRAY(db.Float)) # Latitude and Longitude font = db.Column(db.String(200)) marker = db.Column(db.String(200)) # Name of associated Marker path_id = db.Column(db.Integer, db.ForeignKey('paths.path_id'), nullable=False)
class Game (BaseModel, db.Model): __tablename__ = 'game' __searchable__ = ['name', 'description', 'rating'] # Changed the constructor for Python 2 compatibility def __init__(self, id=None, name=None, description=None, genres=None, platforms=None, release_date=None, image_url=None, rating=None, user_ids=None, team_ids=None, community_ids=None, *args): super(Game, self).__init__(*args) self.id = id self.name = name self.description = description self.genres = genres self.platforms = platforms self.release_date = release_date self.image_url = image_url self.rating = rating self.user_ids = user_ids self.team_ids = team_ids self.community_ids = community_ids id = db.Column(db.Integer, primary_key = True) # Attributes name = db.Column(db.TEXT) description = db.Column(db.TEXT) genres = db.Column(db.ARRAY(db.TEXT)) platforms = db.Column(db.ARRAY(db.TEXT)) release_date = db.Column(db.DateTime) image_url = db.Column(db.TEXT) rating = db.Column(db.String) # Connections to other models user_ids = db.Column(db.ARRAY(db.String)) team_ids = db.Column(db.ARRAY(db.Integer)) community_ids = db.Column(db.ARRAY(db.String))
class AllItems(db.Model): __tablename__ = "allitems" item_id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer) first_name = db.Column(db.String(50)) last_name = db.Column(db.String(50)) email = db.Column(db.String(50)) location = db.Column(db.String(50)) caption = db.Column(db.String(500)) timestamp = db.Column(db.TIMESTAMP) image_path = db.Column(db.String(300)) active = db.Column(db.Boolean) type = db.Column(db.String(50)) feature_vector = db.Column(db.ARRAY(db.FLOAT))
class MemoryDraft(db.Model): """Model for MemoryDraft.""" __tablename__ = "memoriesDrafts" # Columns id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String, nullable=False, unique=False) description = db.Column(db.String, nullable=False, unique=False) image = db.Column(db.String, nullable=False, unique=False) user_id = db.Column(db.Integer, db.ForeignKey('users.id')) friends = db.Column(db.ARRAY(db.String)) # Relations localization = db.relationship("Localization", backref="memoriesDrafts", uselist=False) def __repr__(self): return '<Memory Draft: {}>'.format(self.title)
class User (BaseModel, db.Model): __tablename__ = 'user' __searchable__ = ['name', 'description', 'language'] # Changed the constructor for Python 2 compatibility def __init__(self, id='-1', name=None, description=None, language=None, views=None, followers=None, url=None, created=None, updated=None, image_url=None, game_id=None, community_id=None, team_ids=None, *args): super(User, self).__init__(*args) self.id = id self.name = name self.description = description self.language = language self.views = views self.followers = followers self.url = url self.created = created self.updated = updated self.image_url = image_url self.game_id = game_id self.community_id = community_id self.team_ids = team_ids id = db.Column(db.String, primary_key = True) # Attributes name = db.Column(db.TEXT) description = db.Column(db.TEXT) language = db.Column(db.TEXT) views = db.Column(db.Integer) followers = db.Column(db.Integer) url = db.Column(db.TEXT) created = db.Column(db.DateTime) updated = db.Column(db.DateTime) image_url = db.Column(db.TEXT) # Connections to other models game_id = db.Column(db.Integer) community_id = db.Column(db.String) team_ids = db.Column(db.ARRAY(db.Integer))