feat(playlists): implement Playlist and PlaylistSound models; add seeding for default Main playlist
This commit is contained in:
@@ -2,14 +2,17 @@
|
||||
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.database import db
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models.playlist_sound import PlaylistSound
|
||||
|
||||
|
||||
class SoundType(Enum):
|
||||
"""Sound type enumeration."""
|
||||
@@ -87,6 +90,13 @@ class Sound(db.Model):
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
# Relationships
|
||||
playlist_sounds: Mapped[list["PlaylistSound"]] = relationship(
|
||||
"PlaylistSound",
|
||||
back_populates="sound",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""String representation of Sound."""
|
||||
return f"<Sound {self.name} ({self.type}) - {self.play_count} plays>"
|
||||
|
||||
Reference in New Issue
Block a user