update documentation, rework documentation thread, rework book dataclass, fix newentry bug
This commit is contained in:
@@ -9,7 +9,7 @@ __version__ = "0.2.18"
|
||||
__author__ = "Alexander Kirchner"
|
||||
__email__ = "alexander.kirchner@ph-freiburg.de"
|
||||
__license__ = "MIT"
|
||||
docport = 6543
|
||||
docport = 8000
|
||||
|
||||
|
||||
config = Config("config/settings.yaml")
|
||||
@@ -56,7 +56,6 @@ log.add(
|
||||
rotation="1 day",
|
||||
compression="zip",
|
||||
)
|
||||
print(config.debug)
|
||||
if config.debug:
|
||||
import sys
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from PyQt6.QtCore import QThread, pyqtSignal
|
||||
from src.utils import launch_documentation
|
||||
|
||||
from src.utils.documentation import run_mkdocs
|
||||
|
||||
class DocumentationThread(QThread):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def run(self):
|
||||
launch_documentation()
|
||||
# launch_documentation()
|
||||
run_mkdocs()
|
||||
|
||||
@@ -3,14 +3,14 @@ from dataclasses import dataclass
|
||||
|
||||
@dataclass
|
||||
class Book:
|
||||
title: str = ""
|
||||
ppn: int = ""
|
||||
signature: str = ""
|
||||
isbn: str = ""
|
||||
link: str = ""
|
||||
database_id: int = ""
|
||||
link: str = ""
|
||||
loan_from: str = ""
|
||||
loan_to: str = ""
|
||||
returned: int = ""
|
||||
returned_date: str = ""
|
||||
title: str | None = None
|
||||
ppn: int | None = None
|
||||
signature: str | None = None
|
||||
isbn: str | None = None
|
||||
link: str | None = None
|
||||
database_id: int | None = None
|
||||
link: str | None = None
|
||||
loan_from: str | None = None
|
||||
loan_to: str | None = None
|
||||
returned: int | None = None
|
||||
returned_date: str | None = None
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
import atexit
|
||||
import datetime
|
||||
@@ -281,9 +282,11 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
def createUser(self):
|
||||
log.info("Creating User")
|
||||
user = CreateUser(fieldname="id", data="")
|
||||
user.setWindowModality(
|
||||
QtCore.Qt.WindowModality.ApplicationModal
|
||||
) # Block MainUI fom being accessed
|
||||
user.exec()
|
||||
userid = user.userid
|
||||
print(userid)
|
||||
if userid:
|
||||
log.info(f"User created {userid}")
|
||||
data = self.db.getUserBy("user_id", userid)
|
||||
@@ -319,16 +322,13 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
multi.exec()
|
||||
self.activeUser = multi.userdata
|
||||
else:
|
||||
# print("User found", user[0])
|
||||
self.activeUser = user[0]
|
||||
|
||||
if self.activeUser is not None:
|
||||
log.info(f"User found {self.activeUser}")
|
||||
# print("User found", self.activeUser)
|
||||
self.setUserData()
|
||||
self.input_file_ident.setFocus()
|
||||
self.mode.setText("Ausleihe")
|
||||
# print(self.activeUser.__dict__)
|
||||
loans = self.db.getActiveLoans(self.activeUser.id)
|
||||
log.debug("Active Loans", loans)
|
||||
self.btn_show_lentmedia.setText(loans)
|
||||
@@ -416,8 +416,8 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
elif book_id:
|
||||
if isinstance(book_id, list) and len(book_id) > 1:
|
||||
# print("Multiple Books found")
|
||||
# TODO: implement book selection dialog
|
||||
raise NotImplementedError("Multiple books found")
|
||||
return
|
||||
else:
|
||||
if isinstance(book_id, int):
|
||||
@@ -456,8 +456,16 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
if newentries:
|
||||
for entry in newentries:
|
||||
book = self.db.getMedia(entry)
|
||||
self.loanMedia(user_id, [entry], book)
|
||||
log.debug(
|
||||
"Inserting duplicated book {} with id {} to user {}".format(
|
||||
book, entry, user_id
|
||||
)
|
||||
)
|
||||
self.loanMedia(user_id, [entry])
|
||||
log.info("inserted duplicated book into database")
|
||||
else:
|
||||
log.info("No new entry created")
|
||||
self.input_file_ident.setEnabled(True)
|
||||
return
|
||||
else:
|
||||
# print("Book not loaned, loaning now")
|
||||
@@ -559,7 +567,13 @@ def exit_handler():
|
||||
# set icon
|
||||
dialog.setWindowIcon(Icon("backup").icon)
|
||||
dialog.setWindowTitle("Backup")
|
||||
dialog.setText("Backup konnte nicht erstellt werden")
|
||||
errormsg = "Backup konnte nicht erstellt werden\nGrund: {}"
|
||||
files = os.listdir(config.database.backupLocation)
|
||||
if ".backup" in files:
|
||||
errormsg = errormsg.format("Normaler speicherort nicht gefunden")
|
||||
else:
|
||||
errormsg = errormsg.format("Backuppfad nicht gefunden")
|
||||
dialog.setText(errormsg)
|
||||
|
||||
dialog.exec()
|
||||
log.info("Exiting, backup:", state)
|
||||
|
||||
@@ -36,16 +36,27 @@ class NewEntry(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.tableWidget.setItem(
|
||||
row, i, QtWidgets.QTableWidgetItem(self.tableWidget.item(row - 1, i))
|
||||
)
|
||||
if i == 2 and "+" in self.tableWidget.item(row, i).text():
|
||||
entry = self.tableWidget.item(row, i).text().split("+")[1]
|
||||
entry = str(int(entry) + 1)
|
||||
self.tableWidget.setItem(
|
||||
row,
|
||||
i,
|
||||
QtWidgets.QTableWidgetItem(
|
||||
self.tableWidget.item(row, i).text().split("+")[0] + "+" + entry
|
||||
),
|
||||
)
|
||||
if i == 2:
|
||||
if "+" in self.tableWidget.item(row, i).text():
|
||||
entry = self.tableWidget.item(row, i).text().split("+")[1]
|
||||
entry = str(int(entry) + 1)
|
||||
self.tableWidget.setItem(
|
||||
row,
|
||||
i,
|
||||
QtWidgets.QTableWidgetItem(
|
||||
self.tableWidget.item(row, i).text().split("+")[0]
|
||||
+ "+"
|
||||
+ entry
|
||||
),
|
||||
)
|
||||
else:
|
||||
self.tableWidget.setItem(
|
||||
row,
|
||||
i,
|
||||
QtWidgets.QTableWidgetItem(
|
||||
self.tableWidget.item(row, i).text() + "+1"
|
||||
),
|
||||
)
|
||||
|
||||
def populateTable(self):
|
||||
for title in self.titles:
|
||||
@@ -61,7 +72,11 @@ class NewEntry(QtWidgets.QDialog, Ui_Dialog):
|
||||
0, 2, QtWidgets.QTableWidgetItem(entry.signature)
|
||||
)
|
||||
self.tableWidget.setItem(0, 3, QtWidgets.QTableWidgetItem(entry.ppn))
|
||||
|
||||
# set row to be not editable
|
||||
for i in range(4):
|
||||
self.tableWidget.item(0, i).setFlags(
|
||||
QtCore.Qt.ItemFlag.ItemIsEnabled
|
||||
)
|
||||
def insertEntry(self):
|
||||
# get all rows, convert them to Book and insert into database
|
||||
for row in range(self.tableWidget.rowCount()):
|
||||
|
||||
Reference in New Issue
Block a user