示例#1
0
class Game(DB.Model):
    """Game database model"""
    __tablename__ = 'game'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    game_ext_id = DB.Column(DB.String(8), nullable=False)
    q_num = DB.Column(DB.Integer, nullable=False, default=0)
示例#2
0
class Account(DB.Model):
    """Account database model"""
    __tablename__ = 'accounts'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    device_key = DB.Column(DB.String(350), nullable=False)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
示例#3
0
class Location(DB.Model):
    """Location database model"""
    __tablename__ = 'locations'

    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    name = DB.Column(DB.String(120), nullable=False)
    user_id = DB.Column(DB.Integer,
                        DB.ForeignKey(User.__tablename__ + '.id'),
                        nullable=False)
示例#4
0
class Picture(DB.Model):
    """Picture database model"""
    __tablename__ = 'pictures'

    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    item_id = DB.Column(DB.Integer,
                        DB.ForeignKey(Item.__tablename__ + '.id'),
                        nullable=False)
    path = DB.Column(DB.Text, nullable=False)
示例#5
0
class User(DB.Model):
    """User database model"""
    __tablename__ = 'users'

    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    username = DB.Column(DB.String(80), unique=True, nullable=False)
    email = DB.Column(DB.String(120), nullable=False)
    password_hash = DB.Column(DB.String(64), nullable=False)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    items = DB.relationship('Item', backref='user', lazy=True)
示例#6
0
class Hype(DB.Model):
    """Hype database model"""
    __tablename__ = 'hypes'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    event_id = DB.Column(DB.Integer,
                         DB.ForeignKey(Event.__tablename__ + '.id',
                                       ondelete='CASCADE'),
                         nullable=False)
    account_id = DB.Column(DB.Integer,
                           DB.ForeignKey(Account.__tablename__ + '.id',
                                         ondelete='CASCADE'),
                           nullable=False)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    __table_args__ = (DB.UniqueConstraint(
        'event_id', 'account_id',
        name='_hype_event_account_unique_constraint'), )
示例#7
0
class PlayerSession(DB.Model):
    """Player->Game session database model"""
    __tablename__ = 'playersession'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    username = DB.Column(DB.String(64), nullable=False)
    session_key = DB.Column(DB.String(8), nullable=False)
    buzz_time = DB.Column(DB.DateTime, nullable=True)
    game_id = DB.Column(DB.Integer,
                        DB.ForeignKey(Game.__tablename__ + '.id',
                                      ondelete='CASCADE'),
                        nullable=False)
    is_creator = DB.Column(DB.Boolean, nullable=False, default=False)
示例#8
0
class Item(DB.Model):
    """Item database model"""
    __tablename__ = 'items'

    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    user_id = DB.Column(DB.Integer,
                        DB.ForeignKey(User.__tablename__ + '.id'),
                        nullable=False)
    location_id = DB.Column(DB.Integer,
                            DB.ForeignKey(Location.__tablename__ + '.id'),
                            nullable=True)
    description = DB.Column(DB.Text, nullable=True)
    name = DB.Column(DB.Text, nullable=False)

    purchase_date = DB.Column(DB.DateTime, nullable=True)
    purchase_price = DB.Column(DB.Numeric(precision=19,
                                          scale=4,
                                          asdecimal=True),
                               nullable=True)
    sell_date = DB.Column(DB.DateTime, nullable=True)
    sell_price = DB.Column(DB.Numeric(precision=19, scale=4, asdecimal=True),
                           nullable=True)
    listed_price = DB.Column(DB.Numeric(precision=19, scale=4, asdecimal=True),
                             nullable=True)

    pictures = DB.relationship("Picture", cascade="all,delete", backref="item")
示例#9
0
class Event(DB.Model):
    """Event database model"""
    __tablename__ = 'events'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    latitude = DB.Column(DB.Float(precision=32, asdecimal=True),
                         nullable=False)
    longitude = DB.Column(DB.Float(precision=32, asdecimal=True),
                          nullable=False)
    account_id = DB.Column(DB.Integer,
                           DB.ForeignKey(Account.__tablename__ + '.id',
                                         ondelete='CASCADE'),
                           nullable=False)
    time = DB.Column(DB.DateTime, nullable=False)
    group_size_max = DB.Column(DB.Integer, nullable=False)
    group_size_min = DB.Column(DB.Integer, nullable=False)
    title = DB.Column(DB.String(50), nullable=False)
    category = DB.Column(DB.String(50), nullable=False)
    description = DB.Column(DB.String(140), nullable=False)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)