parent
faf18f431e
commit
7a6c8a0f95
@ -65,7 +65,8 @@ class NoteColours(dbtables.NoteColoursTable):
|
|||||||
Return all records
|
Return all records
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return session.scalars(select(cls)).all()
|
result = session.scalars(select(cls)).all()
|
||||||
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_colour(session: Session, text: str) -> Optional[str]:
|
def get_colour(session: Session, text: str) -> Optional[str]:
|
||||||
@ -167,6 +168,7 @@ class Playdates(dbtables.PlaydatesTable):
|
|||||||
class Playlists(dbtables.PlaylistsTable):
|
class Playlists(dbtables.PlaylistsTable):
|
||||||
def __init__(self, session: Session, name: str):
|
def __init__(self, session: Session, name: str):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.last_used = dt.datetime.now()
|
||||||
session.add(self)
|
session.add(self)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@ -192,10 +194,14 @@ class Playlists(dbtables.PlaylistsTable):
|
|||||||
) -> Optional["Playlists"]:
|
) -> Optional["Playlists"]:
|
||||||
"""Create a new playlist from template"""
|
"""Create a new playlist from template"""
|
||||||
|
|
||||||
|
# Sanity check
|
||||||
|
if not template.id:
|
||||||
|
return None
|
||||||
|
|
||||||
playlist = cls(session, playlist_name)
|
playlist = cls(session, playlist_name)
|
||||||
|
|
||||||
# Sanity / mypy checks
|
# Sanity / mypy checks
|
||||||
if not playlist or not playlist.id or not template.id:
|
if not playlist or not playlist.id:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
PlaylistRows.copy_playlist(session, template.id, playlist.id)
|
PlaylistRows.copy_playlist(session, template.id, playlist.id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user