playlist edition
This commit is contained in:
35
app/playlists/playlist_page.py
Normal file
35
app/playlists/playlist_page.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# playlists/playlist_page.py
|
||||
import streamlit as st
|
||||
from playlists import playlist_db
|
||||
from playlists.playlist_model import Playlist
|
||||
from playlists.playlist_controller import playlist_manual_editor, playlist_dynamic_editor
|
||||
from playlists.playlist_controller import RuleSet
|
||||
|
||||
def main():
|
||||
st.title("🎵 Gestion des Playlists")
|
||||
|
||||
playlists = playlist_db.load_all_playlists()
|
||||
selected = st.selectbox("Playlists existantes", ["(Nouvelle)"] + [p.name for p in playlists])
|
||||
|
||||
# playlists/playlist_page.py (partie création)
|
||||
if selected == "(Nouvelle)":
|
||||
st.subheader("➕ Nouvelle playlist")
|
||||
name = st.text_input("Nom")
|
||||
desc = st.text_area("Description")
|
||||
type_choice = st.radio("Type", ["manual", "dynamic"])
|
||||
if st.button("Créer"):
|
||||
if not name.strip():
|
||||
st.error("Le nom ne peut pas être vide.")
|
||||
else:
|
||||
pl = Playlist(name=name.strip(), description=desc or "", type=type_choice, rules=RuleSet())
|
||||
pl.save()
|
||||
st.success("Playlist créée ✅")
|
||||
# Recharge immédiate : rerun force tout à re-exécuter
|
||||
st.rerun()
|
||||
|
||||
else:
|
||||
current = next(p for p in playlists if p.name == selected)
|
||||
if current.type == "manual":
|
||||
playlist_manual_editor(current)
|
||||
else:
|
||||
playlist_dynamic_editor(current)
|
||||
Reference in New Issue
Block a user