|
|
@ -56,13 +56,11 @@ class ShowDetailsScreen(Screen):
|
|
|
|
self.show_obj = show
|
|
|
|
self.show_obj = show
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def action_submit(self):
|
|
|
|
|
|
|
|
quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_mount(self):
|
|
|
|
def on_mount(self):
|
|
|
|
|
|
|
|
|
|
|
|
if self.show_obj:
|
|
|
|
if self.show_obj:
|
|
|
|
self.query_one("#id_input", Input).value = self.show_obj['id']
|
|
|
|
|
|
|
|
|
|
|
|
self.query_one("#id_wdg", Static).update(str(self.show_obj['id']))
|
|
|
|
self.query_one("#name_input", Input).value = self.show_obj['name']
|
|
|
|
self.query_one("#name_input", Input).value = self.show_obj['name']
|
|
|
|
self.query_one("#year_input", Input).value = self.show_obj['year']
|
|
|
|
self.query_one("#year_input", Input).value = self.show_obj['year']
|
|
|
|
|
|
|
|
|
|
|
@ -74,7 +72,12 @@ class ShowDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
|
|
yield Static("New Show" if self.show_obj else "Show", id="toplabel")
|
|
|
|
yield Static("New Show" if self.show_obj else "Show", id="toplabel")
|
|
|
|
yield Static("ID")
|
|
|
|
yield Static("ID")
|
|
|
|
yield Input(type="text", id="id_input")
|
|
|
|
|
|
|
|
|
|
|
|
if self.show_obj:
|
|
|
|
|
|
|
|
yield Static("", id="id_wdg")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
yield Input(type="text", id="id_wdg")
|
|
|
|
|
|
|
|
|
|
|
|
yield Static("Name")
|
|
|
|
yield Static("Name")
|
|
|
|
yield Input(type="text", id="name_input")
|
|
|
|
yield Input(type="text", id="name_input")
|
|
|
|
yield Static("Year")
|
|
|
|
yield Static("Year")
|
|
|
@ -89,13 +92,16 @@ class ShowDetailsScreen(Screen):
|
|
|
|
yield Button("Save", id="save_button")
|
|
|
|
yield Button("Save", id="save_button")
|
|
|
|
yield Button("Cancel", id="cancel_button")
|
|
|
|
yield Button("Cancel", id="cancel_button")
|
|
|
|
|
|
|
|
|
|
|
|
yield Static("", id="output_static")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yield Footer()
|
|
|
|
yield Footer()
|
|
|
|
|
|
|
|
|
|
|
|
def getValues(self):
|
|
|
|
def getValues(self):
|
|
|
|
showId = int(self.query_one("#id_input", Input).value)
|
|
|
|
|
|
|
|
|
|
|
|
if self.show_obj:
|
|
|
|
|
|
|
|
showId = int(self.show_obj['id'])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
showId = int(self.query_one("#id_wdg", Input).value)
|
|
|
|
|
|
|
|
|
|
|
|
showName = self.query_one("#name_input", Input).value
|
|
|
|
showName = self.query_one("#name_input", Input).value
|
|
|
|
showYear = self.query_one("#year_input", Input).value
|
|
|
|
showYear = self.query_one("#year_input", Input).value
|
|
|
|
return showId, showName, showYear
|
|
|
|
return showId, showName, showYear
|
|
|
@ -107,9 +113,8 @@ class ShowDetailsScreen(Screen):
|
|
|
|
if event.button.id == "save_button":
|
|
|
|
if event.button.id == "save_button":
|
|
|
|
|
|
|
|
|
|
|
|
showId, showName, showYear = self.getValues()
|
|
|
|
showId, showName, showYear = self.getValues()
|
|
|
|
self.query_one("#output_static", Static).update(f"{showId} - {showName} ({showYear})")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.addShow(showId, showName, showYear):
|
|
|
|
if self.updateShow(showId, showName, showYear):
|
|
|
|
|
|
|
|
|
|
|
|
screenResult = {}
|
|
|
|
screenResult = {}
|
|
|
|
screenResult['id'] = showId
|
|
|
|
screenResult['id'] = showId
|
|
|
@ -124,7 +129,7 @@ class ShowDetailsScreen(Screen):
|
|
|
|
if event.button.id == "cancel_button":
|
|
|
|
if event.button.id == "cancel_button":
|
|
|
|
self.app.pop_screen()
|
|
|
|
self.app.pop_screen()
|
|
|
|
|
|
|
|
|
|
|
|
def addShow(self, show_id, show_name, show_year):
|
|
|
|
def updateShow(self, show_id, show_name, show_year):
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
s = self.Session()
|
|
|
|
s = self.Session()
|
|
|
@ -138,10 +143,22 @@ class ShowDetailsScreen(Screen):
|
|
|
|
s.commit()
|
|
|
|
s.commit()
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
currentShow = q.first()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
if currentShow.name != show_name:
|
|
|
|
|
|
|
|
currentShow.name = show_name
|
|
|
|
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
if currentShow.year != show_year:
|
|
|
|
|
|
|
|
currentShow.year = show_year
|
|
|
|
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
if changed:
|
|
|
|
|
|
|
|
s.commit()
|
|
|
|
|
|
|
|
return changed
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
except Exception as ex:
|
|
|
|
click.ClickException(f"ShowDetailsScreen.addShow(): {repr(ex)}")
|
|
|
|
click.ClickException(f"ShowDetailsScreen.updateShow(): {repr(ex)}")
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
s.close()
|
|
|
|
s.close()
|
|
|
|
|
|
|
|
|
|
|
|