Feat: add delete edition dialog with fuzzy search
This commit is contained in:
@@ -544,7 +544,15 @@ class Database:
|
||||
ret_result.append(data)
|
||||
return ret_result
|
||||
|
||||
def getAllBooks(self):
|
||||
def getAllBooks(self) -> list[dict[str, Union[int, BookData]]]:
|
||||
"""
|
||||
Get all books in the database that are not set as deleted
|
||||
|
||||
Returns
|
||||
-------
|
||||
list[dict[str, Union[int, BookData]]]
|
||||
A list of dictionaries containing the id and the metadata of the book
|
||||
"""
|
||||
# return all books in the database
|
||||
qdata = self.query_db("SELECT id,bookdata FROM media WHERE deleted=0")
|
||||
ret_result: list[dict[str, Any]] = []
|
||||
@@ -558,6 +566,14 @@ class Database:
|
||||
ret_result.append(data)
|
||||
return ret_result
|
||||
|
||||
def getApparatNrByBookId(self, book_id):
|
||||
appNr = self.query_db(
|
||||
"SELECT appnr FROM semesterapparat WHERE id IN (SELECT app_id FROM media WHERE id=?)",
|
||||
(book_id,),
|
||||
one=True,
|
||||
)
|
||||
return appNr[0] if appNr else None
|
||||
|
||||
def getBooksByProfId(
|
||||
self, prof_id: int, deleted: int = 0
|
||||
) -> list[dict[str, Union[int, BookData]]]:
|
||||
@@ -611,6 +627,16 @@ class Database:
|
||||
"""
|
||||
self.query_db("UPDATE media SET deleted=1 WHERE id=?", (book_id,))
|
||||
|
||||
def deleteBooks(self, ids: list[int]):
|
||||
"""
|
||||
Delete multiple books from the database
|
||||
|
||||
Args:
|
||||
ids (list[int]): A list of book ids to be deleted
|
||||
"""
|
||||
query = f"UPDATE media SET deleted=1 WHERE id IN ({','.join(['?'] * len(ids))})"
|
||||
self.query_db(query, tuple(ids))
|
||||
|
||||
# File Interactions
|
||||
def getBlob(self, filename: str, app_id: Union[str, int]) -> bytes:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user