add explanation about auto signature generation, fix loan ui bug

loan UI now colors rows correctly and data is being displayed on change
This commit is contained in:
2025-01-27 10:53:55 +01:00
parent 20b53cea69
commit c427202b2a
2 changed files with 40 additions and 2 deletions

View File

@@ -73,13 +73,45 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
),
)
self.loanTable.setItem(0, 6, QtWidgets.QTableWidgetItem(retdate))
book = data.book
book.loan_to = data.return_date
book.load_from = data.loan_date
book.returned = data.returned
match self.check_book(book):
case "overdue":
for i in range(7):
self.loanTable.item(0, i).setBackground(
QtGui.QColor(255, 0, 0, 100)
)
case "ok":
for i in range(7):
self.loanTable.item(0, i).setBackground(
QtGui.QColor(105, 255, 51, 100)
)
case "returned":
for i in range(7):
self.loanTable.item(0, i).setBackground(
QtGui.QColor(102, 153, 153, 100)
)
def check_book(self, book):
today = QtCore.QDate.currentDate().toString("yyyy-MM-dd")
returnDate = stringToDate(book.loan_to).toString("yyyy-MM-dd")
returned = book.returned
if returned == 1:
return "returned"
else:
if returnDate < today:
return "overdue"
else:
return "ok"
def loadLoans(self):
loans = self.db.getAllLoans()
loanlist = []
for loan in loans:
self.insertRow(loan)
return loanlist
return loans
def filterResults(self):
mode = (
@@ -89,6 +121,7 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
if self.radio_current.isChecked()
else "overdue"
)
log.debug("Switching mode to {}", mode)
self.loanTable.setRowCount(0)
today = QtCore.QDate.currentDate()
for loan in self.loans: