Skip to content

Commit

Permalink
Dashboard fix, Register save
Browse files Browse the repository at this point in the history
  • Loading branch information
kanehekili committed Feb 29, 2024
1 parent dee4280 commit d12c0ff
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/TsvAuswertung.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ def visitorsSauna():
def dashboard():
logo_path = "tsv_logo_100.png"
#Zugang
entries=(('accessKR','Kraftraum '),('accessSA','Sauna '),('groupRooms','Fitness '))
entries=(('accessKR','Kraftraum '),('accessSA','Sauna '),('groupRooms','Group '))
listDataLeft=[]
for entry in entries:
data = {"href":entry[0],"title":entry[1]}
listDataLeft.append(data)

#Statistik
entries=(('Kraftraum','Kraftraum '),('Sauna','Sauna '),('groupStatistics','Fitness '))
entries=(('Kraftraum','Kraftraum '),('Sauna','Sauna '),('groupStatistics','Group '))
listDataRight=[]
for entry in entries:
data = {"href":entry[0],"title":entry[1]}
Expand Down
76 changes: 44 additions & 32 deletions src/TsvRegisterModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ def fillSearchCombo(self, memberList):
def updateAboButton(self, mbr):
self.ui_AboButton.setEnabled(mbr is not None)


def updateEditFields(self,isEnabled):
self.ui_IDEdit.setEnabled(isEnabled)
self.ui_FirstNameEdit.setEnabled(isEnabled)
self.ui_LastNameEdit.setEnabled(isEnabled)

def makeGridLayout(self):
# fromRow(y) - fromColumn(x) rowSpan(height) columnSpan(width), ggf alignment
gridLayout = QtWidgets.QGridLayout()
Expand Down Expand Up @@ -646,12 +652,11 @@ def _onSearchChanged(self, idx):
else:
self.photoTaken = False
self.updateAboButton(mbr)
self.updateEditFields(False)

@QtCore.pyqtSlot()
def _onNewClicked(self):
self.ui_SearchEdit.setCurrentIndex(-1)
self._clearFields()
self.controller.setInitialFocus()
self._resetInput()

@QtCore.pyqtSlot()
def _onRFIDDone(self):
Expand Down Expand Up @@ -736,35 +741,37 @@ def _onSaveMember(self):
self.getErrorDialog("Eingabefehler", "Bitte alle Felder ausfüllen", msg, mail=False).show()
Log.warning("Data error:%s", msg)
return

QApplication.setOverrideCursor(QtCore.Qt.CursorShape.WaitCursor)
mid = int(idstr)
rfid_int = int(rfid)
# we should update in the correct form
if mbr is not None:
bd = mbr.asDBDate(birthdate)
mbr.update(mid, firstName, lastName, access, bd, rfid_int)
self.ui_SearchEdit.setEditText(mbr.searchName())
else:
# create new member, update search box
mbr = Mitglied(mid, firstName, lastName, access, None, rfid_int)
entry = mbr.searchName()
self.ui_SearchEdit.addItem(entry, mbr)
# need a try catch.
if self.photoTaken:
res = self.model.savePicture(mbr) # scps the pic to remote and adds uri to db...
if not res:
self.getErrorDialog("Verbindungsfehler", "Bild konnte nicht gespeichert werden", "Der Fehler wurde per eMail gemeldet!").show()
self.photoTaken = False
QApplication.restoreOverrideCursor()
return # only all or nothing
QTimer.singleShot(0, lambda: self.model.updateMember(mbr))
# self.model.updateMember(mbr)
# self.model.printMemberCard(mbr)
QApplication.restoreOverrideCursor()
self._clearFields()
self.controller.setInitialFocus()

try:
self.ui_SaveButton.setEnabled(False)
QApplication.setOverrideCursor(QtCore.Qt.CursorShape.WaitCursor)
mid = int(idstr)
rfid_int = int(rfid)
# we should update in the correct form
if mbr is not None:
bd = mbr.asDBDate(birthdate)
mbr.update(mid, firstName, lastName, access, bd, rfid_int)
self.ui_SearchEdit.setEditText(mbr.searchName())
else:
# create new member, update search box
mbr = Mitglied(mid, firstName, lastName, access, None, rfid_int)
entry = mbr.searchName()
self.ui_SearchEdit.addItem(entry, mbr)
# need a try catch.
if self.photoTaken:
res = self.model.savePicture(mbr) # scps the pic to remote and adds uri to db...
if not res:
self.getErrorDialog("Verbindungsfehler", "Bild konnte nicht gespeichert werden", "Der Fehler wurde per eMail gemeldet!").show()
self.photoTaken = False
return # only all or nothing
QTimer.singleShot(0, lambda: self.model.updateMember(mbr))
# self.model.updateMember(mbr)
# self.model.printMemberCard(mbr)
self._resetInput()
finally:
QApplication.restoreOverrideCursor()
QtCore.QCoreApplication.processEvents()
self.ui_SaveButton.setEnabled(True)

@QtCore.pyqtSlot()
def _onOpenAboDialog(self):
mbr = self.ui_SearchEdit.currentData()
Expand Down Expand Up @@ -792,6 +799,11 @@ def _clearFields(self):
self.updateAboButton(None)
self.ui_VideoFrame.showFrame(None)

def _resetInput(self):
self.ui_SearchEdit.setCurrentIndex(-1)
self._clearFields()
self.controller.setInitialFocus()
self.updateEditFields(True)

# dialogs
def __getInfoDialog(self, text):
Expand Down

0 comments on commit d12c0ff

Please sign in to comment.