Compare commits
4 Commits
ea4d7693ef
...
ece6723211
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ece6723211 | ||
|
|
a56cdea207 | ||
|
|
683e76f9a0 | ||
|
|
abd6ad0a64 |
6
.envrc
6
.envrc
@ -8,12 +8,6 @@ branch=$(git branch --show-current)
|
|||||||
if on_git_branch master; then
|
if on_git_branch master; then
|
||||||
export MM_ENV="PRODUCTION"
|
export MM_ENV="PRODUCTION"
|
||||||
export MM_DB="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod"
|
export MM_DB="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod"
|
||||||
elif on_git_branch carts; then
|
|
||||||
export MM_ENV="DEVELOPMENT"
|
|
||||||
export MM_DB="mysql+mysqldb://dev_musicmuster:dev_musicmuster@localhost/dev_musicmuster_carts"
|
|
||||||
elif on_git_branch newcarts; then
|
|
||||||
export MM_ENV="DEVELOPMENT"
|
|
||||||
export MM_DB="mysql+mysqldb://dev_musicmuster:dev_musicmuster@localhost/dev_musicmuster_carts"
|
|
||||||
else
|
else
|
||||||
export MM_ENV="DEVELOPMENT"
|
export MM_ENV="DEVELOPMENT"
|
||||||
export MM_DB="mysql+mysqldb://dev_musicmuster:dev_musicmuster@localhost/dev_musicmuster"
|
export MM_DB="mysql+mysqldb://dev_musicmuster:dev_musicmuster@localhost/dev_musicmuster"
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import stackprinter
|
import os
|
||||||
|
import stackprinter # type: ignore
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ def log_uncaught_exceptions(_ex_cls, ex, tb):
|
|||||||
logging.critical(''.join(traceback.format_tb(tb)))
|
logging.critical(''.join(traceback.format_tb(tb)))
|
||||||
print("\033[1;37;40m")
|
print("\033[1;37;40m")
|
||||||
print(stackprinter.format(ex, style="darkbg2", add_summary=True))
|
print(stackprinter.format(ex, style="darkbg2", add_summary=True))
|
||||||
if os.environ("MM_ENV") != "DEVELOPMENT":
|
if os.environ["MM_ENV"] != "DEVELOPMENT":
|
||||||
msg = stackprinter.format(ex)
|
msg = stackprinter.format(ex)
|
||||||
send_mail(Config.ERRORS_TO, Config.ERRORS_FROM,
|
send_mail(Config.ERRORS_TO, Config.ERRORS_FROM,
|
||||||
"Exception from musicmuster", msg)
|
"Exception from musicmuster", msg)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import stackprinter
|
import stackprinter # type: ignore
|
||||||
|
|
||||||
from dbconfig import Session
|
from dbconfig import Session
|
||||||
|
|
||||||
@ -224,11 +224,14 @@ class Playlists(Base):
|
|||||||
|
|
||||||
__tablename__ = "playlists"
|
__tablename__ = "playlists"
|
||||||
|
|
||||||
id: int = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
name: str = Column(String(32), nullable=False, unique=True)
|
name = Column(String(32), nullable=False, unique=True)
|
||||||
last_used = Column(DateTime, default=None, nullable=True)
|
last_used = Column(DateTime, default=None, nullable=True)
|
||||||
tab = Column(Integer, default=False, nullable=True, unique=True)
|
tab = Column(Integer, default=None, nullable=True, unique=True)
|
||||||
|
sort_column = Column(Integer, default=None, nullable=True, unique=False)
|
||||||
is_template = Column(Boolean, default=False, nullable=False)
|
is_template = Column(Boolean, default=False, nullable=False)
|
||||||
|
query = Column(String(256), default=None, nullable=True, unique=False)
|
||||||
|
deleted = Column(Boolean, default=False, nullable=False)
|
||||||
rows = relationship(
|
rows = relationship(
|
||||||
"PlaylistRows",
|
"PlaylistRows",
|
||||||
back_populates="playlist",
|
back_populates="playlist",
|
||||||
@ -263,8 +266,17 @@ class Playlists(Base):
|
|||||||
def close(self, session: Session) -> None:
|
def close(self, session: Session) -> None:
|
||||||
"""Mark playlist as unloaded"""
|
"""Mark playlist as unloaded"""
|
||||||
|
|
||||||
|
# Closing this tab will mean all higher-number tabs have moved
|
||||||
|
# down by one
|
||||||
|
closed_idx = self.tab
|
||||||
self.tab = None
|
self.tab = None
|
||||||
|
|
||||||
|
session.execute(
|
||||||
|
update(Playlists)
|
||||||
|
.where(Playlists.tab > closed_idx)
|
||||||
|
.values(tab=Playlists.tab - 1)
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_playlist_from_template(cls,
|
def create_playlist_from_template(cls,
|
||||||
session: Session,
|
session: Session,
|
||||||
|
|||||||
@ -358,7 +358,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
def close_tab(self, tab_index: int) -> None:
|
def close_tab(self, tab_index: int) -> None:
|
||||||
"""
|
"""
|
||||||
Close active playlist tab unless it holds the curren or next track.
|
Close playlist tab unless it holds the current or next track.
|
||||||
Called from close_playlist_tab() or by clicking close button on tab.
|
Called from close_playlist_tab() or by clicking close button on tab.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -375,6 +375,12 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
"Can't close next track playlist", 5000)
|
"Can't close next track playlist", 5000)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Record playlist as closed and update remaining playlist tabs
|
||||||
|
with Session() as session:
|
||||||
|
playlist_id = self.tabPlaylist.widget(tab_index).playlist_id
|
||||||
|
playlist = session.get(Playlists, playlist_id)
|
||||||
|
playlist.close(session)
|
||||||
|
|
||||||
# Close playlist and remove tab
|
# Close playlist and remove tab
|
||||||
self.tabPlaylist.widget(tab_index).close()
|
self.tabPlaylist.widget(tab_index).close()
|
||||||
self.tabPlaylist.removeTab(tab_index)
|
self.tabPlaylist.removeTab(tab_index)
|
||||||
@ -420,8 +426,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.btnStop.clicked.connect(self.stop)
|
self.btnStop.clicked.connect(self.stop)
|
||||||
self.hdrCurrentTrack.clicked.connect(self.show_current)
|
self.hdrCurrentTrack.clicked.connect(self.show_current)
|
||||||
self.hdrNextTrack.clicked.connect(self.show_next)
|
self.hdrNextTrack.clicked.connect(self.show_next)
|
||||||
self.tabPlaylist.currentChanged.connect(
|
self.tabPlaylist.currentChanged.connect(self.tab_change)
|
||||||
lambda: self.tabPlaylist.currentWidget().tab_visible())
|
|
||||||
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
|
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
|
||||||
self.tabBar = self.tabPlaylist.tabBar()
|
self.tabBar = self.tabPlaylist.tabBar()
|
||||||
self.tabBar.tabMoved.connect(self.move_tab)
|
self.tabBar.tabMoved.connect(self.move_tab)
|
||||||
@ -1207,6 +1212,15 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# Run end-of-track actions
|
# Run end-of-track actions
|
||||||
self.end_of_track_actions()
|
self.end_of_track_actions()
|
||||||
|
|
||||||
|
def tab_change(self):
|
||||||
|
"""Called when active tab changed"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.tabPlaylist.currentWidget().tab_visible()
|
||||||
|
except AttributeError:
|
||||||
|
# May also be called when last tab is closed
|
||||||
|
pass
|
||||||
|
|
||||||
def this_is_the_next_track(self, session: Session,
|
def this_is_the_next_track(self, session: Session,
|
||||||
playlist_tab: PlaylistTab,
|
playlist_tab: PlaylistTab,
|
||||||
track: Tracks) -> None:
|
track: Tracks) -> None:
|
||||||
|
|||||||
@ -203,16 +203,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
# ########## Events other than cell editing ##########
|
# ########## Events other than cell editing ##########
|
||||||
|
|
||||||
def closeEvent(self, event) -> None:
|
|
||||||
"""Handle closing playist tab"""
|
|
||||||
|
|
||||||
with Session() as session:
|
|
||||||
# Record playlist as closed
|
|
||||||
playlist = session.get(Playlists, self.playlist_id)
|
|
||||||
playlist.close(session)
|
|
||||||
|
|
||||||
event.accept()
|
|
||||||
|
|
||||||
def dropEvent(self, event: QDropEvent) -> None:
|
def dropEvent(self, event: QDropEvent) -> None:
|
||||||
"""
|
"""
|
||||||
Handle drag/drop of rows
|
Handle drag/drop of rows
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
"""Add sort_column, deleted and query to playlists table
|
||||||
|
|
||||||
|
Revision ID: 07dcbe6c4f0e
|
||||||
|
Revises: 4a7b4ab3354f
|
||||||
|
Create Date: 2022-12-25 10:26:38.200941
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '07dcbe6c4f0e'
|
||||||
|
down_revision = '4a7b4ab3354f'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('playlists', sa.Column('sort_column', sa.Integer(), nullable=True))
|
||||||
|
op.add_column('playlists', sa.Column('query', sa.String(length=256), nullable=True))
|
||||||
|
op.add_column('playlists', sa.Column('deleted', sa.Boolean(), nullable=False))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('playlists', 'deleted')
|
||||||
|
op.drop_column('playlists', 'query')
|
||||||
|
op.drop_column('playlists', 'sort_column')
|
||||||
|
# ### end Alembic commands ###
|
||||||
Loading…
Reference in New Issue
Block a user