rework logging, add more dataclasses, reworked config
This commit is contained in:
@@ -52,6 +52,7 @@ from src.ui import (
|
||||
EditUser,
|
||||
EditProf
|
||||
)
|
||||
from src.utils import SemesterDocument
|
||||
|
||||
valid_input = (0, 0, 0, 0, 0, 0)
|
||||
|
||||
@@ -139,7 +140,7 @@ class Ui(Ui_Semesterapparat):
|
||||
QtWidgets.QScrollBar(), QtCore.Qt.AlignmentFlag.AlignRight
|
||||
)
|
||||
self.tableWidget_apparate.doubleClicked.connect(self.load_app_data)
|
||||
self.load_app.hide()
|
||||
|
||||
# print(f"user:{self.active_user}")
|
||||
userrole = self.db.getRole(self.active_user)
|
||||
# hide admin interface when non-admin is logged in
|
||||
@@ -163,7 +164,6 @@ class Ui(Ui_Semesterapparat):
|
||||
self.sem_year.textChanged.connect(self.validate_semester)
|
||||
self.check_eternal_app.stateChanged.connect(self.validate_semester)
|
||||
self.chkbx_show_del_media.stateChanged.connect(self.update_app_media_list)
|
||||
|
||||
self.progress_label.setText("Bitte warten...")
|
||||
|
||||
# Set visibility/enabled state of certain entries
|
||||
@@ -188,6 +188,9 @@ class Ui(Ui_Semesterapparat):
|
||||
self.validate_thread.started.connect(self.thread_check)
|
||||
self.validate_thread.start()
|
||||
self.add_medium.setEnabled(False)
|
||||
self.docuthread = QThread()
|
||||
self.docuthread.started.connect(self.create_doc)
|
||||
self.create_document.clicked.connect(self.docuthread.start)
|
||||
|
||||
# get all current apparats and cache them in a list
|
||||
self.apparats = self.get_apparats()
|
||||
@@ -229,6 +232,32 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
self.steps.hide()
|
||||
|
||||
def create_doc(self):
|
||||
result = self.confirm_popup(
|
||||
"Mit dem Klick auf Okay wird eine Übersicht aller aktiven Semesterapparate erstellt und an den FollowME Drucker gesendet. Es kann bis zu 10 Minuten dauern, bis das Dokument im Drucker angezeigt wird",
|
||||
"Dokument erstellen?",
|
||||
)
|
||||
if result == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
print("Creating document")
|
||||
apparats = self.apparats
|
||||
apps = []
|
||||
for apparat in apparats:
|
||||
prof = self.db.getProf(apparat[2])
|
||||
data = (apparat[4], f"{prof.lastname} ({apparat[1]})")
|
||||
apps.append(data)
|
||||
print(apps)
|
||||
doc = SemesterDocument(
|
||||
semester=self.generateSemester(today=True),
|
||||
filename="Semesterapparate",
|
||||
apparats=apps,
|
||||
)
|
||||
doc.make_document()
|
||||
doc.create_pdf()
|
||||
doc.print_document()
|
||||
doc.cleanup()
|
||||
|
||||
# kill thread after execution done
|
||||
|
||||
def checkValidInput(self):
|
||||
if valid_input == (1, 1, 1, 1, 1, 1):
|
||||
self.check_file.setEnabled(True)
|
||||
@@ -475,11 +504,11 @@ class Ui(Ui_Semesterapparat):
|
||||
# Validators
|
||||
def __setValidState(self, widget, state, mand, index):
|
||||
if state:
|
||||
Icon("valid_true", widget)
|
||||
Icon("valid_true", widget, True, color="success")
|
||||
mand.setText("")
|
||||
self.change_state(index, 1)
|
||||
else:
|
||||
Icon("valid_false", widget)
|
||||
Icon("valid_false", widget, recolor=True, color="warning")
|
||||
mand.setText("*")
|
||||
self.change_state(index, 0)
|
||||
|
||||
@@ -1191,9 +1220,7 @@ class Ui(Ui_Semesterapparat):
|
||||
return False
|
||||
appd = ApparatData()
|
||||
appd.appnr = self.active_apparat
|
||||
appd.prof_title = (
|
||||
None if self.prof_title.text() == "" else self.prof_title.text()
|
||||
)
|
||||
appd.prof_title = self.prof_title.text()
|
||||
appd.profname = self.drpdwn_prof_name.currentText()
|
||||
appd.appname = self.app_name.text()
|
||||
appd.semester = self.generateSemester()
|
||||
@@ -1344,13 +1371,15 @@ class Ui(Ui_Semesterapparat):
|
||||
self.logger.log_info("Opening reminder dialog")
|
||||
reminder = reminder_ui()
|
||||
reminder.exec()
|
||||
tableposition = self.tableWidget_apparate.currentRow()
|
||||
appnr = self.tableWidget_apparate.item(tableposition, 0).text()
|
||||
if reminder.result() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
data = reminder.return_message()
|
||||
# print(data)
|
||||
self.db.addMessage(
|
||||
data,
|
||||
self.active_user,
|
||||
self.active_apparat if self.active_apparat != "" else None,
|
||||
self.active_apparat if self.active_apparat != "" else appnr,
|
||||
)
|
||||
self.calendarWidget.setMessages([data])
|
||||
self.calendarWidget.updateCells()
|
||||
@@ -1366,6 +1395,8 @@ class Ui(Ui_Semesterapparat):
|
||||
self.calendarWidget.updateCells()
|
||||
|
||||
def open_reminder(self):
|
||||
if settings.mail.use_user_name == False:
|
||||
print("False")
|
||||
selected_date = self.calendarWidget.selectedDate().toString("yyyy-MM-dd")
|
||||
# # print(selected_date)
|
||||
messages = self.db.getMessages(selected_date)
|
||||
@@ -1685,7 +1716,7 @@ class Ui(Ui_Semesterapparat):
|
||||
# print(state)
|
||||
pid = self.__get_table_data_field(self.tableWidget_apparate, position[0], 2)
|
||||
if state == 1:
|
||||
self.db.deleteApparat(selected_apparat_id, generateSemesterByDate())
|
||||
self.db.deleteApparat(selected_apparat_id)
|
||||
# delete the corresponding entry from self.apparats
|
||||
for apparat in self.apparats:
|
||||
if apparat[4] == int(selected_apparat_id):
|
||||
|
||||
Reference in New Issue
Block a user