rework prof data using dataclass, change database code, fix bugs
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .ValidatorButton import ValidatorButton
|
||||
|
||||
@@ -19,6 +19,7 @@ from src import Icon
|
||||
from src.backend import (
|
||||
Database,
|
||||
generateSemesterByDate,
|
||||
|
||||
recreateFile,
|
||||
tempdelete,
|
||||
)
|
||||
@@ -295,6 +296,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.app_fach.addItems([subject[1] for subject in self.db.getSubjects()])
|
||||
|
||||
def open_documentation(self):
|
||||
raise NotImplementedError("Documentation not implemented yet")
|
||||
# open the documentation in the default browser
|
||||
webbrowser.open("file:///" + os.path.abspath("docs/index.html"))
|
||||
# documentation = documentationview.DocumentationViewer()
|
||||
@@ -310,7 +312,7 @@ class Ui(Ui_Semesterapparat):
|
||||
widget.deleteLater()
|
||||
statistics = SearchStatisticPage()
|
||||
statistics.apparat_open.connect(self.open_apparat)
|
||||
statistics.reloadSignal.connect(self.reload)
|
||||
statistics.refreshSignal.connect(self.update_apparat_list)
|
||||
|
||||
stats_layout.addWidget(statistics)
|
||||
|
||||
@@ -431,7 +433,7 @@ class Ui(Ui_Semesterapparat):
|
||||
else self.sem_winter.text() + " " + self.sem_year.text()
|
||||
)
|
||||
appdata.prof_adis_id = self.prof_id_adis.text()
|
||||
prof_id = self.db.getProfByName(appdata.profname)[0]
|
||||
prof_id = self.db.getProfByName(appdata.prof_details.fullname).id
|
||||
self.add_files(prof_id)
|
||||
appdata.apparat_adis_id = self.apparat_id_adis.text()
|
||||
|
||||
@@ -443,6 +445,8 @@ class Ui(Ui_Semesterapparat):
|
||||
self.chkbx_show_del_media.show()
|
||||
self.cancel_active_selection.setEnabled(False)
|
||||
self.add_medium.setEnabled(False)
|
||||
#update apparat table
|
||||
self.get_apparats()
|
||||
|
||||
def confirm_popup(self, message: str, title: str):
|
||||
popup = popus_confirm(title=title)
|
||||
@@ -538,6 +542,7 @@ class Ui(Ui_Semesterapparat):
|
||||
valid_input = list(valid_input)
|
||||
valid_input[index] = state
|
||||
valid_input = tuple(valid_input)
|
||||
|
||||
|
||||
def set_state(self):
|
||||
# set state of semester and year
|
||||
@@ -561,12 +566,13 @@ class Ui(Ui_Semesterapparat):
|
||||
selected_prof = self.drpdwn_prof_name.currentText()
|
||||
data = self.db.getProfData(selected_prof)
|
||||
# ic(data)
|
||||
prof_title = data[2]
|
||||
prof_title = data.title
|
||||
if prof_title == "None":
|
||||
prof_title = "Kein Titel"
|
||||
self.prof_title.setText(prof_title)
|
||||
self.prof_tel_nr.setText(data[1])
|
||||
self.prof_mail.setText(data[0])
|
||||
self.prof_tel_nr.setText(data.telnr)
|
||||
self.prof_mail.setText(data.mail)
|
||||
self.app_name.setFocus()
|
||||
|
||||
def get_index_of_value(self, table_widget, value):
|
||||
for i in range(table_widget.rowCount()):
|
||||
@@ -614,7 +620,7 @@ class Ui(Ui_Semesterapparat):
|
||||
app_id = self.active_apparat
|
||||
prof_id = self.db.getProfByName(
|
||||
self.drpdwn_prof_name.currentText().replace(",","")
|
||||
)[0]
|
||||
).id
|
||||
files = self.db.getFiles(app_id, prof_id)
|
||||
for file in files:
|
||||
self.dokument_list.insertRow(0)
|
||||
@@ -887,7 +893,7 @@ class Ui(Ui_Semesterapparat):
|
||||
if columnname == "Link":
|
||||
link = __openLink(item.text())
|
||||
if link is not None:
|
||||
webbrowser.open(link)
|
||||
os.system("start " + link)
|
||||
return
|
||||
else:
|
||||
pass
|
||||
@@ -903,7 +909,7 @@ class Ui(Ui_Semesterapparat):
|
||||
# add empty entry to dropdown and set it as current
|
||||
self.drpdwn_prof_name.addItem("Kein Name")
|
||||
for prof in profs:
|
||||
self.drpdwn_prof_name.addItem(f"{prof[3]}, {prof[2]}")
|
||||
self.drpdwn_prof_name.addItem(f"{prof.lastname}, {prof.firstname}")
|
||||
|
||||
def add_document(self):
|
||||
# print("Add document")
|
||||
@@ -1113,6 +1119,8 @@ class Ui(Ui_Semesterapparat):
|
||||
# print("starting thread")
|
||||
if prof_id is None:
|
||||
prof_id = self.db.getProfId(self.profdata)
|
||||
|
||||
print("Prof ID is None", prof_id)
|
||||
autoGrabber = BookGrabber(self.active_apparat)
|
||||
autoGrabber.add_values(
|
||||
mode="ARRAY", app_id=app_id, prof_id=prof_id, data=signatures
|
||||
@@ -1188,8 +1196,7 @@ class Ui(Ui_Semesterapparat):
|
||||
appd.deleted = 0
|
||||
appd.prof_adis_id = self.prof_id_adis.text()
|
||||
appd.apparat_adis_id = self.apparat_id_adis.text()
|
||||
if not self.validate_fields():
|
||||
pass
|
||||
|
||||
error = self.db.createApparat(appd)
|
||||
|
||||
if self.dokument_list.rowCount() > 0:
|
||||
@@ -1260,6 +1267,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
def update_apparat_list(self):
|
||||
self.tableWidget_apparate.setRowCount(0)
|
||||
|
||||
for apparat in self.apparats:
|
||||
self.insert_apparat_into_table(apparat)
|
||||
|
||||
@@ -1387,14 +1395,6 @@ class Ui(Ui_Semesterapparat):
|
||||
self.reload()
|
||||
|
||||
def reload(self):
|
||||
# create a new connection to the database, refresh table data and replace the old connection
|
||||
# self.db = Database()
|
||||
# self.apparats = self.db.getAllAparats(deleted=0)
|
||||
# self.apparats = natsorted(self.apparats, key=lambda x: x[4], reverse=True)
|
||||
# self.tableWidget_apparate.setRowCount(0)
|
||||
# for apparat in self.apparats:
|
||||
# self.insert_apparat_into_table(apparat)
|
||||
# kill the process and restart the application
|
||||
state = self.confirm_popup(
|
||||
"Bitte das Programm neustarten, um Änderungen zu übernehemen",
|
||||
"Einstellungen geändert",
|
||||
@@ -1535,7 +1535,7 @@ class Ui(Ui_Semesterapparat):
|
||||
# if pid == "":
|
||||
# pid = profname
|
||||
# get the row of the clicked cell
|
||||
prof_id = self.db.getProfByName(pid)[0]
|
||||
prof_id = self.db.getProfByName(pid).id
|
||||
# if profname == "Name Kein":
|
||||
# profname = pid
|
||||
if self.app_name.text() != "":
|
||||
|
||||
@@ -2,10 +2,12 @@ from .widget_sources.Ui_search_statistic_page import Ui_Dialog
|
||||
from PyQt6 import QtWidgets, QtGui
|
||||
from PyQt6.QtCore import pyqtSignal
|
||||
from src.backend import Database, generateSemesterByDate
|
||||
from src.logic import custom_sort
|
||||
from src.logic import custom_sort, Prof
|
||||
from src import MyLogger
|
||||
from src.ui import ApparatExtendDialog
|
||||
from src.ui.dialogs import Mail_Dialog
|
||||
from src.ui.widgets import DataGraph, StatusWidget
|
||||
|
||||
from natsort import natsorted
|
||||
from icecream import ic
|
||||
|
||||
@@ -20,7 +22,7 @@ class MyComboBox(QtWidgets.QComboBox):
|
||||
class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
apparat_open = pyqtSignal(str)
|
||||
reloadSignal = pyqtSignal()
|
||||
|
||||
refreshSignal = pyqtSignal()
|
||||
def __init__(self):
|
||||
self.logger = MyLogger("SearchStatisticPage")
|
||||
self.logger.log_info("SearchStatisticPage started")
|
||||
@@ -65,10 +67,24 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
def statistics_table_context_menu(self, position):
|
||||
menu = QtWidgets.QMenu()
|
||||
restore_action = menu.addAction("Wiederherstellen")
|
||||
extend_action = menu.addAction("Verlängern")
|
||||
menu.addAction(restore_action)
|
||||
restore_action.triggered.connect(self.restore_apparat)
|
||||
extend_action.triggered.connect(self.extend_apparat)
|
||||
menu.exec(self.tableWidget.mapToGlobal(position))
|
||||
|
||||
def extend_apparat(self):
|
||||
extend = ApparatExtendDialog()
|
||||
extend.exec()
|
||||
if extend.result() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
data = extend.get_data()
|
||||
ic(data)
|
||||
app_name = self.tableWidget.item(self.tableWidget.currentRow(), 1).text()
|
||||
app_id = self.db.getApparatId(app_name)
|
||||
self.db.setNewSemesterDate(app_id, data["semester"], data["dauerapp"])
|
||||
#remove the row
|
||||
self.tableWidget.removeRow(self.tableWidget.currentRow())
|
||||
self.refreshSignal.emit()
|
||||
def tabW2_changed(self):
|
||||
|
||||
if self.tabWidget_2.currentIndex() == 0:
|
||||
@@ -204,7 +220,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
apparats = [str(apparat) for apparat in apparats]
|
||||
self.box_appnrs.addItems(apparats)
|
||||
persons = self.db.getProfs()
|
||||
self.box_person.addItems([f"{person[3]}, {person[2]}" for person in persons])
|
||||
self.box_person.addItems([f"{person.lastname}, {person.firstname}" for person in persons])
|
||||
self.box_fach.addItems(subject[1] for subject in self.db.getSubjects())
|
||||
semester = self.db.getSemersters()
|
||||
self.box_erstellsemester.addItems(semester)
|
||||
|
||||
Reference in New Issue
Block a user