[main] Fixed book editing not working
This commit is contained in:
parent
516639ef9d
commit
79ca9f2e6f
@ -45,7 +45,7 @@ def update_book(book: Book):
|
|||||||
existing_book.isbn = book.isbn
|
existing_book.isbn = book.isbn
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
logger.info("Book successfully updated")
|
logger.info(f"{book.title} successfully updated")
|
||||||
except IntegrityError as e:
|
except IntegrityError as e:
|
||||||
logger.warning("Data already exists")
|
logger.warning("Data already exists")
|
||||||
session.rollback()
|
session.rollback()
|
||||||
|
@ -28,8 +28,7 @@ class DatabaseManager():
|
|||||||
database_config.host,
|
database_config.host,
|
||||||
database_config.port,
|
database_config.port,
|
||||||
database_config.name),
|
database_config.name),
|
||||||
pool_pre_ping=True,
|
pool_pre_ping=True)
|
||||||
echo=True)
|
|
||||||
if self.test_connection():
|
if self.test_connection():
|
||||||
self.Session = sessionmaker(bind=self.engine)
|
self.Session = sessionmaker(bind=self.engine)
|
||||||
|
|
||||||
|
@ -87,20 +87,21 @@ class BookEditor(QDialog):
|
|||||||
self.year_input.setText(self.book.year_published)
|
self.year_input.setText(self.book.year_published)
|
||||||
self.isbn_input.setText(self.book.isbn)
|
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} {
|
full_author_name = f"{self.book.author.first_name} {
|
||||||
self.book.author.last_name}"
|
self.book.author.last_name}"
|
||||||
self.author_label.setText(full_author_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(
|
all_categories = ", ".join(
|
||||||
category.name for category in self.book.categories)
|
category.name for category in self.book.categories)
|
||||||
self.categories_input.setText(all_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:
|
try:
|
||||||
if self.create_new:
|
if self.create_new:
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user