From 79ca9f2e6f9873f2003636e059ed274c53fe1b28 Mon Sep 17 00:00:00 2001 From: Thastertyn Date: Wed, 15 Jan 2025 17:16:31 +0100 Subject: [PATCH] [main] Fixed book editing not working --- src/database/book.py | 2 +- src/database/manager.py | 3 +-- src/ui/editor/book_editor.py | 13 +++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/database/book.py b/src/database/book.py index afe2319..a34c8a8 100644 --- a/src/database/book.py +++ b/src/database/book.py @@ -45,7 +45,7 @@ def update_book(book: Book): existing_book.isbn = book.isbn session.commit() - logger.info("Book successfully updated") + logger.info(f"{book.title} successfully updated") except IntegrityError as e: logger.warning("Data already exists") session.rollback() diff --git a/src/database/manager.py b/src/database/manager.py index 55ac10a..558a079 100644 --- a/src/database/manager.py +++ b/src/database/manager.py @@ -28,8 +28,7 @@ class DatabaseManager(): database_config.host, database_config.port, database_config.name), - pool_pre_ping=True, - echo=True) + pool_pre_ping=True) if self.test_connection(): self.Session = sessionmaker(bind=self.engine) diff --git a/src/ui/editor/book_editor.py b/src/ui/editor/book_editor.py index e59ec45..f8f1edc 100644 --- a/src/ui/editor/book_editor.py +++ b/src/ui/editor/book_editor.py @@ -87,20 +87,21 @@ class BookEditor(QDialog): self.year_input.setText(self.book.year_published) self.isbn_input.setText(self.book.isbn) - def save_book(self): - # Update book object with input values - self.book.title = self.title_input.text() full_author_name = f"{self.book.author.first_name} { self.book.author.last_name}" self.author_label.setText(full_author_name) - self.book.description = self.description_input.toPlainText() - self.book.year_published = self.year_input.text() - self.book.isbn = self.isbn_input.text() all_categories = ", ".join( category.name for category in self.book.categories) self.categories_input.setText(all_categories) + def save_book(self): + # Update book object with input values + self.book.title = self.title_input.text() + self.book.description = self.description_input.toPlainText() + self.book.year_published = self.year_input.text() + self.book.isbn = self.isbn_input.text() + try: if self.create_new: pass