示例#1
0
class ContestInitialCrosswords(SurrogatePK, Model):
    __tablename__ = 'contest_crossword'
    contest_id = reference_col('contests', nullable=False)
    contest = relationship('Contest', backref='initial_crosswords')

    crossword_id = reference_col('crosswords', nullable=False)
    crossword = relationship('Crossword')

    order = Column(db.Integer(), nullable=False, default=0)

    __table_args__ = (
        UniqueConstraint('contest_id', 'crossword_id'),
        UniqueConstraint('contest_id', 'order'),
    )
示例#2
0
class UserStats(SurrogatePK, Model):
    """Crossword challenge."""

    __tablename__ = 'user_stats'
    user_id = reference_col('users', nullable=False)
    user = relationship('User', backref='stats')

    contest_id = reference_col('contests', nullable=False)
    contest = relationship('Contest', backref='stats')

    score = Column(db.Float(), nullable=False, default=0.0)

    __table_args__ = (
        UniqueConstraint('contest_id', 'user_id'),
    )
示例#3
0
class ContestStageWinner(SurrogatePK, Model):
    """Crossword challenge."""

    __tablename__ = 'contests_stage_winners'
    user_id = reference_col('users', nullable=False)
    user = relationship('User', backref='contest_stage_wins')

    score = Column(db.Float(), nullable=False)

    contest_stage_id = reference_col('contests_stages', nullable=False)
    contest_stage = relationship('ContestStage', backref='winners')

    __table_args__ = (
        UniqueConstraint('contest_stage_id', 'user_id'),
    )
示例#4
0
class UserCrossword(SurrogatePK, Model):
    user_id = reference_col('users', nullable=False)
    user = relationship('User')

    contest_id = reference_col('contests', nullable=False)
    contest = relationship('Contest')

    crossword_id = reference_col('crosswords', nullable=False)
    crossword = relationship('Crossword', lazy='joined')

    solved = Column(ArrowType(), nullable=True, default=None)
    solution = deferred(Column(db.Text(), nullable=True, default=True))

    __table_args__ = (
        UniqueConstraint('user_id', 'contest_id', 'crossword_id'),
    )
示例#5
0
class ContestStage(SurrogatePK, Model):
    """Crossword challenge."""

    __tablename__ = 'contests_stages'
    name = Column(db.String(150), nullable=False)
    finish = Column(ArrowType(), nullable=True, default=None)

    contest_id = reference_col('contests', nullable=False)
    contest = relationship('Contest', backref='stages')

    __table_args__ = (
        UniqueConstraint('contest_id', 'name'),
    )
示例#6
0
class Role(SurrogatePK, Model):
    """A role for a user."""

    __tablename__ = 'roles'
    name = Column(db.String(80), unique=True, nullable=False)
    user_id = reference_col('users', nullable=True)
    user = relationship('User', backref='roles')

    def __init__(self, name, **kwargs):
        """Create instance."""
        db.Model.__init__(self, name=name, **kwargs)

    def __repr__(self):
        """Represent instance as a unique string."""
        return '<Role({name})>'.format(name=self.name)