diff --git a/discodos/ctrl/collection.py b/discodos/ctrl/collection.py index 45c1367..67640f1 100644 --- a/discodos/ctrl/collection.py +++ b/discodos/ctrl/collection.py @@ -940,7 +940,7 @@ def tui_ls_releases(self, search_terms): "Cat. #", "Artist", "Title", - "D. Coll.", + "Is in C.", "For Sale", ], discogs=self.d diff --git a/discodos/model_collection.py b/discodos/model_collection.py index 1c9d4b2..dbf803b 100644 --- a/discodos/model_collection.py +++ b/discodos/model_collection.py @@ -882,7 +882,7 @@ def update_release_brainz(self, release_id, mbid, match_method): tuple_upd = (mbid, match_method, release_id) return self.execute_sql(sql_upd, tuple_upd) - # Newer fetchers and inserts + # Newer fetchers, inserts and helpers def create_sales_entry(self, listing_object): """Creates a single entry to sales table and ensures up to date data. @@ -909,6 +909,10 @@ def create_sales_entry(self, listing_object): log.error("MODEL: create_sales_entry: %s", e.args[0]) return False + def bool_to_yes_no(self, value): + """Convert 0/1 to 'No'/'Yes'.""" + return "Yes" if value == 1 else "No" + def key_value_search_releases( self, search_key_value=None, orderby="d_artist, discogs_title" ): @@ -927,7 +931,7 @@ def key_value_search_releases( ) join = [("LEFT", "sales", "discogs_id = d_sales_release_id")] - return self._select_simple( + rows = self._select_simple( [ "discogs_id", "d_catno", @@ -939,3 +943,13 @@ def key_value_search_releases( "release", fetchone=False, orderby=orderby, condition=where, join=join ) + human_readable_rows = [ + { + **row, + "in_d_collection": self.bool_to_yes_no( + row["in_d_collection"] + ) + } + for row in rows + ] + return human_readable_rows diff --git a/discodos/view/collection.py b/discodos/view/collection.py index 5eb4956..14800bf 100644 --- a/discodos/view/collection.py +++ b/discodos/view/collection.py @@ -82,8 +82,8 @@ def action_edit_sale(self): def _load_ls_results(self): table_widget = self.query_one(DataTable) for row in self.rows: - row_id, *_ = row - table_widget.add_row(*row, key=row_id) + row_id = row['discogs_id'] + table_widget.add_row(*row.values(), key=row_id) def on_mount(self): self.title = "DiscoDOS ls results"