update code, switch to loguru
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
from .sources.Ui_main_Loans import Ui_MainWindow
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from src import log
|
||||
from .user import UserUI
|
||||
from src.logic import Database
|
||||
from src.utils import stringToDate, Icon
|
||||
from src.utils import debugMessage as dbg
|
||||
from icecream import ic
|
||||
|
||||
TABLETOFIELDTRANSLATE = {
|
||||
@@ -23,8 +23,7 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
QtWidgets.QHeaderView.ResizeMode.Stretch
|
||||
)
|
||||
self.db = Database()
|
||||
self.loans = []
|
||||
self.loadLoans()
|
||||
self.loans = self.loadLoans()
|
||||
|
||||
# lineedits
|
||||
self.searchbar.textChanged.connect(self.limitResults)
|
||||
@@ -37,6 +36,7 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
# table
|
||||
self.loanTable.doubleClicked.connect(self.showUser)
|
||||
log.info("Loan history window opened")
|
||||
self.show()
|
||||
|
||||
def selfpass(self):
|
||||
@@ -44,7 +44,7 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
|
||||
def insertRow(self, data):
|
||||
dbg(contents=data)
|
||||
log.debug(f"Inserting row: {data}")
|
||||
|
||||
retdate = ""
|
||||
if data.returned_date != "":
|
||||
@@ -77,9 +77,10 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
def loadLoans(self):
|
||||
loans = self.db.getAllLoans()
|
||||
loanlist = []
|
||||
for loan in loans:
|
||||
self.insertRow(loan)
|
||||
self.loans = loans
|
||||
return loanlist
|
||||
|
||||
def filterResults(self):
|
||||
mode = (
|
||||
@@ -112,7 +113,7 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
limiter = str(limiter)
|
||||
searchfield = self.searchFields.currentText()
|
||||
searchfield = TABLETOFIELDTRANSLATE[searchfield]
|
||||
dbg(limiter=limiter, search=searchfield)
|
||||
log.debug(f"Searching for: {limiter} in {searchfield}")
|
||||
self.loanTable.setRowCount(0)
|
||||
for loan in self.loans:
|
||||
fielddata = eval(f"loan.{searchfield}")
|
||||
|
||||
Reference in New Issue
Block a user