[main] Fixed a bug with editing existing books
This commit is contained in:
parent
d7ee79f7e9
commit
85382ee616
9
src/database/book_category_statistics.py
Normal file
9
src/database/book_category_statistics.py
Normal 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)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user