예제 #1
0
class Download(db.Model):
    """Download record."""

    id = db.Column(db.Integer, primary_key=True)
    track_id = db.Column(db.Integer, db.ForeignKey("track.id"))
    track = db.relationship(Track, backref=db.backref("downloads"))
    date = db.Column(db.DateTime)

    def __repr__(self) -> str:
        """Download __repr__."""
        return f"Download({self.id}, {self.track.id}, {self.date})"
예제 #2
0
class Tag(db.Model):
    """Tag record."""

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), unique=True)
    track_id = db.Column(db.Integer, db.ForeignKey("track.id"))
    track = db.relationship(Track, backref=db.backref("tags"))

    def __repr__(self) -> str:
        """Tag __repr__."""
        return f"Tag({self.id}, {self.name})"
예제 #3
0
class Podcast(db.Model):

    """Podcast record."""

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), unique=True)
    title = db.Column(db.String(255), nullable=True)
    start_date = db.Column(db.Date, nullable=True)

    def __repr__(self) -> str:
        """Podcast __repr__."""
        return f"Podcast({self.id}, {self.name})"
예제 #4
0
class Reaction(db.Model):
    """Reaction record."""

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    user = db.relationship(User, backref=db.backref("users_reactions"))
    track_id = db.Column(db.Integer, db.ForeignKey("track.id"))
    track = db.relationship(Track, backref=db.backref("track_reactions"))
    deleted_on = db.Column(db.DateTime, nullable=True)
    code = db.Column(db.String(16))

    def __repr__(self) -> str:
        """Reaction __repr__."""
        return f"Reaction({self.id}, {self.code})"
예제 #5
0
class Track(db.Model):

    """Track record."""

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(255))
    podcast_id = db.Column(db.Integer, db.ForeignKey("podcast.id"))
    podcast = db.relationship(Podcast, backref=db.backref("tracks"))
    media_url = db.Column(db.String(255), nullable=True)
    release_date = db.Column(db.Date, nullable=True)
    duration = db.Column(db.DateTime, nullable=True)

    def __repr__(self) -> str:
        """Podcast __repr__."""
        return f"Track({self.id}, {self.title})"
예제 #6
0
class User(db.Model):
    """User record."""

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True)
    is_active = db.Column(db.Boolean, default=True)
    # TODO hash the password
    password = db.Column(db.String(255))
    # TODO make both created_on and updated_on generic for any model
    created_on = db.Column(db.DateTime, server_default=db.func.now())
    updated_on = db.Column(db.DateTime,
                           server_default=db.func.now(),
                           server_onupdate=db.func.now())

    def __repr__(self) -> str:
        """User __repr__."""
        return f"User({self.id}, {self.email})"