diff --git a/app/models.py b/app/models.py index a348e0c..275ca74 100644 --- a/app/models.py +++ b/app/models.py @@ -65,7 +65,8 @@ class NoteColours(dbtables.NoteColoursTable): Return all records """ - return session.scalars(select(cls)).all() + result = session.scalars(select(cls)).all() + return result @staticmethod def get_colour(session: Session, text: str) -> Optional[str]: @@ -167,6 +168,7 @@ class Playdates(dbtables.PlaydatesTable): class Playlists(dbtables.PlaylistsTable): def __init__(self, session: Session, name: str): self.name = name + self.last_used = dt.datetime.now() session.add(self) session.commit() @@ -192,10 +194,14 @@ class Playlists(dbtables.PlaylistsTable): ) -> Optional["Playlists"]: """Create a new playlist from template""" + # Sanity check + if not template.id: + return None + playlist = cls(session, playlist_name) # Sanity / mypy checks - if not playlist or not playlist.id or not template.id: + if not playlist or not playlist.id: return None PlaylistRows.copy_playlist(session, template.id, playlist.id)