update documentation, rework documentation thread, rework book dataclass, fix newentry bug
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user