Ejemplo n.º 1
0
class WorkoutTypes(db.Model):
    __tablename__ = 'workout_types'

    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.Enum(WorkoutTypeEnum))
    label = db.Column(db.String(64), index=True, unique=True)
    category = db.Column(db.Enum(WorkoutCategoryEnum))
    description = db.Column(db.String(64), index=False, unique=False)

    def __init__(self, code, label, category, description = None):
        self.code = code
        self.label = label
        self.category = category
        self.description = description

    def __repr__(self):
        return '<id {}>'.format(self.id)
Ejemplo n.º 2
0
class Message(db.Model):
    created_at = db.Column(db.DateTime, nullable=False, default=lambda: datetime.utcnow())
    updated_at = db.Column(
        db.DateTime, nullable=False, default=lambda: datetime.utcnow(), onupdate=lambda: datetime.utcnow()
    )
    status = db.Column(
        db.Enum(MessageStatus, values_callable=lambda enum: [e.value for e in enum], native_enum=False),
        default=MessageStatus.CONFIRMED)
    id = db.Column(db.Integer, primary_key=True)
    payload = db.Column(db.JSON)

    def __repr__(self):
        return f'<Message id:{self.id}>'
Ejemplo n.º 3
0
class Movement(db.Model):
    __tablename__ = 'movement'

    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(5))
    label = db.Column(db.String(64), index=True, unique=True)
    standard = db.Column(db.String(64))
    load_measurement = db.Column(db.Enum(MeasurementEnum))

    def __init__(self, code, label, load=None):
        self.code = code
        self.label = label
        self.load_measurement = load

    def __repr__(self):
        return '<id {}>'.format(self.id)
Ejemplo n.º 4
0
class Friendship(db.Model):
    __tablename__ = 'friendship'

    id = db.Column(db.Integer, primary_key=True)
    requester_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    target_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    status = db.Column(db.Enum(FriendshipStatus),
                       default=FriendshipStatus.requested)

    def serialize_short(self):
        return {
            'user':
            User.query.filter(
                or_(User.id == self.target_id,
                    User.id == self.requester_id)).first().serialize_short(),
            'status':
            self.status.name
        }