[main] Fixed book editing not working

This commit is contained in:
Thastertyn 2025-01-15 17:16:31 +01:00
parent 516639ef9d
commit 79ca9f2e6f
3 changed files with 9 additions and 9 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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