slette lister
This commit is contained in:
@@ -71,11 +71,12 @@ class PlaylistData(BaseModel):
|
||||
songs: list[PlaylistSongData] = []
|
||||
|
||||
class PushPayload(BaseModel):
|
||||
songs: list[SongData] = []
|
||||
dances: list[DanceData] = []
|
||||
song_dances: list[SongDanceData] = []
|
||||
song_alts: list[SongAltDanceData] = []
|
||||
playlists: list[PlaylistData] = []
|
||||
songs: list[SongData] = []
|
||||
dances: list[DanceData] = []
|
||||
song_dances: list[SongDanceData] = []
|
||||
song_alts: list[SongAltDanceData] = []
|
||||
playlists: list[PlaylistData] = []
|
||||
deleted_playlists: list[str] = [] # navne på slettede playlister
|
||||
|
||||
|
||||
# ── Push ──────────────────────────────────────────────────────────────────────
|
||||
@@ -206,8 +207,9 @@ def push(
|
||||
if existing:
|
||||
existing.description = pl.description
|
||||
existing.visibility = pl.visibility
|
||||
# Slet og geninsert sange
|
||||
db.query(ProjectSong).filter_by(project_id=existing.id).delete()
|
||||
# Opdater kun sange hvis push faktisk har sange med
|
||||
if pl.songs:
|
||||
db.query(ProjectSong).filter_by(project_id=existing.id).delete()
|
||||
project = existing
|
||||
else:
|
||||
project = Project(
|
||||
@@ -238,6 +240,13 @@ def push(
|
||||
)
|
||||
db.add(proj_song)
|
||||
|
||||
# ── Slet playlister der er fjernet lokalt ─────────────────────────────────
|
||||
for name in payload.deleted_playlists:
|
||||
proj = db.query(Project).filter_by(owner_id=me.id, name=name).first()
|
||||
if proj:
|
||||
db.query(ProjectSong).filter_by(project_id=proj.id).delete()
|
||||
db.delete(proj)
|
||||
|
||||
db.commit()
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user