[main] Fixed a bug with editing existing books

This commit is contained in:
Thastertyn 2025-01-16 20:07:47 +01:00
parent d7ee79f7e9
commit 85382ee616
3 changed files with 15 additions and 2 deletions

View File

@ -0,0 +1,9 @@
from sqlalchemy.orm import Session
from sqlalchemy import update
from models import BookCategoryStatistics, Book
def update_category_statistics(session: Session, book_id: int):
statistics = session.query(BookCategoryStatistics).get(book_id)

View File

@ -22,6 +22,7 @@ class BookEditor(QDialog):
self.create_layout()
if book:
self.book_id = book.id
self.logger.debug(f"Editing existing book {book.title}")
self.create_new = False
self.fill_with_existing_data(book)
@ -100,6 +101,7 @@ class BookEditor(QDialog):
if self.create_new:
create_book(book_object)
else:
book_object["id"] = self.book_id
update_book(book_object)
QMessageBox.information(None,

View File

@ -78,8 +78,10 @@ class UserConfig:
return cls._instance
def __init__(self):
self._transaction_level = TransactionLevel.insecure
self._simulate_slowdown = False
if not hasattr(self, "_transaction_level"):
self._transaction_level = TransactionLevel.insecure
if not hasattr(self, "_simulate_slowdown"):
self._simulate_slowdown = False
@property
def transaction_level(self) -> TransactionLevel: