add type checking, update deletion function in searchpage, add function to import apparat data from document
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import pathlib
|
||||
|
||||
from .Ui_semesterapparat_ui import Ui_MainWindow as Ui_Semesterapparat
|
||||
from .semesterapparat_ui_ui import Ui_MainWindow as Ui_Semesterapparat
|
||||
|
||||
# from .dialogs import (
|
||||
# ApparatExtendDialog,
|
||||
|
||||
@@ -595,67 +595,6 @@
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="check_file">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1110</x>
|
||||
<y>120</y>
|
||||
<width>131</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Abhängig von der Anzahl der Medien kann die Suche sehr lange dauern</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Medien aus Dokument
|
||||
hinzufügen</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_open_document">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1110</x>
|
||||
<y>80</y>
|
||||
<width>131</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dokument öffnen</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_add_document">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1110</x>
|
||||
<y>40</y>
|
||||
<width>131</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dokument hinzufügen</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="appname_mand">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@@ -1506,6 +1445,103 @@
|
||||
<string>Speichern und anlegen</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1110</x>
|
||||
<y>17</y>
|
||||
<width>131</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8" stretch="1,1,2,2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_add_document">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dokument hinzufügen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_open_document">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dokument öffnen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="check_file">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Abhängig von der Anzahl der Medien kann die Suche sehr lange dauern</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Medien aus Dokument
|
||||
hinzufügen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_extract_data_from_document">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Die Apparatsdetails werden aus dem Dokument gelesen und eingetragen
|
||||
Einige Angaben müssen ggf angepasst werden</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Daten aus Dokument
|
||||
übernehmen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
1002
src/ui/semesterapparat_ui_ui.py
Normal file
1002
src/ui/semesterapparat_ui_ui.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,8 @@ import sys
|
||||
import tempfile
|
||||
import webbrowser
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from typing import Any, Union
|
||||
|
||||
from natsort import natsorted
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from PyQt6.QtCore import QThread
|
||||
@@ -25,6 +26,7 @@ from src.logic import (
|
||||
BookData,
|
||||
csv_to_list,
|
||||
word_to_semap,
|
||||
SemapDocument,
|
||||
Prof,
|
||||
Apparat,
|
||||
)
|
||||
@@ -87,6 +89,9 @@ class Ui(Ui_Semesterapparat):
|
||||
self.check_file.clicked.connect( # type:ignore
|
||||
self.btn_check_file_threaded
|
||||
) # default: self.add_media_from_file
|
||||
self.btn_extract_data_from_document.clicked.connect( # type:ignore
|
||||
self.import_data_from_document
|
||||
)
|
||||
self.create_new_app.clicked.connect(self.btn_create_new_apparat) # type:ignore
|
||||
self.btn_apparat_save.clicked.connect(lambda: self.btn_save_apparat(True)) # type:ignore
|
||||
self.btn_apparat_apply.clicked.connect(self.update_apparat) # type:ignore
|
||||
@@ -136,7 +141,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.prof_tel_nr.setValidator(
|
||||
QtGui.QRegularExpressionValidator(QtCore.QRegularExpression(r"^\d{3,14}"))
|
||||
)
|
||||
# #print(self.prof_tel_nr.maxLength())
|
||||
# #logger.debug(self.prof_tel_nr.maxLength())
|
||||
self.app_fach.setValidator( # validator to allow typing in the app_fach field
|
||||
QtGui.QRegularExpressionValidator(
|
||||
QtCore.QRegularExpression(r"[a-zA-Z0-9\s\W]+")
|
||||
@@ -154,7 +159,7 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
self.tableWidget_apparate.doubleClicked.connect(self.load_app_data) # type:ignore
|
||||
|
||||
# #print(f"user:{self.active_user}")
|
||||
# #logger.debug(f"user:{self.active_user}")
|
||||
userrole = self.db.getRole(self.active_user)
|
||||
# hide admin interface when non-admin is logged in
|
||||
if userrole == "admin":
|
||||
@@ -201,7 +206,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.validate_thread.start()
|
||||
self.add_medium.setEnabled(False)
|
||||
self.docu = DocumentationThread()
|
||||
self.docu.start()
|
||||
|
||||
self.actionDokumentation_lokal.triggered.connect(self.open_documentation) # type:ignore
|
||||
|
||||
# get all current apparats and cache them in a list
|
||||
@@ -251,6 +256,8 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
self.steps.hide()
|
||||
|
||||
self.valid_check_semester.clicked.connect(self.display_valid_semester) # type:ignore
|
||||
|
||||
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 document im Drucker angezeigt wird",
|
||||
@@ -258,14 +265,14 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
logger.debug(f"Result: {result}")
|
||||
if result == 1:
|
||||
# print("Creating document")
|
||||
# logger.debug("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)
|
||||
# logger.debug(apps)
|
||||
logger.info("Using apparats: {}", apps)
|
||||
doc = SemesterDocument(
|
||||
semester=Semester().value,
|
||||
@@ -350,6 +357,8 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
def open_documentation(self):
|
||||
logger.info("Opening Documentation")
|
||||
if not self.docu.isRunning():
|
||||
self.docu.start()
|
||||
webbrowser.open("http://localhost:8000")
|
||||
|
||||
def update_calendar(self, data):
|
||||
@@ -372,7 +381,7 @@ class Ui(Ui_Semesterapparat):
|
||||
statistics.updateCalendar.connect(self.update_calendar)
|
||||
stats_layout.addWidget(statistics)
|
||||
|
||||
# #print("searchpage")
|
||||
# #logger.debug("searchpage")
|
||||
if self.tabWidget.currentIndex() == 0: # Apparate
|
||||
# clear all entries from the table
|
||||
self.tableWidget_apparate.setRowCount(0)
|
||||
@@ -390,7 +399,7 @@ class Ui(Ui_Semesterapparat):
|
||||
widget.deleteLater()
|
||||
|
||||
elsa_layout.addWidget(ElsaDialog())
|
||||
# print("added")
|
||||
# logger.debug("added")
|
||||
pass
|
||||
|
||||
def generateSemester(self, today=False):
|
||||
@@ -433,9 +442,9 @@ class Ui(Ui_Semesterapparat):
|
||||
self.prof_mail.setText(appdata.prof.mail)
|
||||
self.prof_tel_nr.setText(appdata.prof.telnr)
|
||||
self.app_name.setText(appdata.apparat.name)
|
||||
# #print("changing dropdown app_fach from '' to ", appdata.app_fach)
|
||||
# #logger.debug("changing dropdown app_fach from '' to ", appdata.app_fach)
|
||||
self.app_fach.setCurrentText(appdata.apparat.subject)
|
||||
# #print("changed dropdown app_fach to ", self.app_fach.currentText())
|
||||
# #logger.debug("changed dropdown app_fach to ", self.app_fach.currentText())
|
||||
self.sem_year.setText(appdata.apparat.get_semester.split(" ")[1])
|
||||
match appdata.apparat.get_semester.split(" ")[0]:
|
||||
case "SoSe":
|
||||
@@ -500,7 +509,7 @@ class Ui(Ui_Semesterapparat):
|
||||
return popup.result()
|
||||
|
||||
def thread_check(self):
|
||||
# #print("Thread started")
|
||||
# #logger.debug("Thread started")
|
||||
self.prof_mail.textChanged.connect(self.validate_prof_mail)
|
||||
self.drpdwn_prof_name.editTextChanged.connect(self.validate_prof_name)
|
||||
self.prof_tel_nr.textChanged.connect(self.validate_prof_tel)
|
||||
@@ -564,22 +573,24 @@ class Ui(Ui_Semesterapparat):
|
||||
self.__setValidState(self.valid_check_app_fach, 0, self.fach_mand, 4)
|
||||
|
||||
def validate_semester(self):
|
||||
if (
|
||||
self.app_group_box.isEnabled()
|
||||
and (
|
||||
(self.sem_sommer.isChecked() or self.sem_winter.isChecked())
|
||||
and self.sem_year.text() != ""
|
||||
and len(self.sem_year.text())
|
||||
>= 2 # check if the year is at least 2 digits long
|
||||
)
|
||||
or self.check_eternal_app.isChecked()
|
||||
):
|
||||
valid = (self.sem_sommer.isChecked() or self.sem_winter.isChecked()) and len(
|
||||
self.sem_year.text()
|
||||
) >= 2
|
||||
if valid or self.check_eternal_app.isChecked():
|
||||
self.__setValidState(self.valid_check_semester, 1, self._mand, 5)
|
||||
self.check_eternal_app.setEnabled(True)
|
||||
else:
|
||||
self.__setValidState(self.valid_check_semester, 0, self._mand, 5)
|
||||
self.check_eternal_app.setEnabled(False)
|
||||
|
||||
def display_valid_semester(self):
|
||||
print(f"""
|
||||
Semester: {self.sem_year.text()}
|
||||
Sommer: {self.sem_sommer.isChecked()}
|
||||
Winter: {self.sem_winter.isChecked()}
|
||||
Eternal: {self.check_eternal_app.isChecked()}
|
||||
""")
|
||||
|
||||
def change_state(self, index, state):
|
||||
global valid_input
|
||||
valid_input = list(valid_input)
|
||||
@@ -706,12 +717,12 @@ class Ui(Ui_Semesterapparat):
|
||||
self.drpdwn_prof_name.clear()
|
||||
# set drop down menu for apparat numbers to only available numbers
|
||||
taken_app_nrs = self.db.getUnavailableApparatNumbers()
|
||||
self.drpdwn_app_nr.addItems([str(i) for i in APP_NRS if i not in taken_app_nrs])
|
||||
self.drpdwn_app_nr.addItems([str(i) for i in APP_NRS if i not in taken_app_nrs]) # type:ignore
|
||||
|
||||
valid_input = (0, 0, 0, 0, 0, 0)
|
||||
self.populate_prof_dropdown()
|
||||
|
||||
def update_progress_label(self, curr, total):
|
||||
def update_progress_label(self, curr: int, total: int):
|
||||
text = f"Medium {curr}/{total}"
|
||||
logger.info(text)
|
||||
self.progress_label.setText(text)
|
||||
@@ -769,7 +780,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
bookGrabber.start()
|
||||
while bookGrabber.isRunning():
|
||||
# #print("waiting for thread to finish")
|
||||
# #logger.debug("waiting for thread to finish")
|
||||
QtWidgets.QApplication.processEvents()
|
||||
|
||||
# self.__clear_fields()
|
||||
@@ -814,7 +825,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
# thread = QThread()
|
||||
appnumber = self.active_apparat
|
||||
# #print(links)
|
||||
# #logger.debug(links)
|
||||
self.availChecker = AvailChecker(links, appnumber, books=books)
|
||||
# availcheck.moveToThread(thread)
|
||||
# availcheck.finished.connect(thread.quit)
|
||||
@@ -863,7 +874,7 @@ class Ui(Ui_Semesterapparat):
|
||||
app_id, prof_id, deleted
|
||||
)
|
||||
|
||||
# # #print(books)
|
||||
# # #logger.debug(books)
|
||||
# take the dataclass from the tuple
|
||||
# booklist:list[BookData]=[book[0] for book in books]
|
||||
self.tableWidget_apparat_media.setRowCount(0)
|
||||
@@ -872,7 +883,7 @@ class Ui(Ui_Semesterapparat):
|
||||
book_data = book["bookdata"]
|
||||
availability = book["available"]
|
||||
# bd = BookData().from_string(book)
|
||||
# # #print(bd, type(bd))
|
||||
# # #logger.debug(bd, type(bd))
|
||||
# create a new row below the last one
|
||||
self.tableWidget_apparat_media.insertRow(
|
||||
self.tableWidget_apparat_media.rowCount()
|
||||
@@ -966,11 +977,11 @@ class Ui(Ui_Semesterapparat):
|
||||
self.drpdwn_prof_name.addItem(prof)
|
||||
|
||||
def add_document(self):
|
||||
# #print("Add document")
|
||||
# #logger.debug("Add document")
|
||||
picker = FilePicker()
|
||||
files = picker.pick_files()
|
||||
for file in files:
|
||||
# #print(file)
|
||||
# #logger.debug(file)
|
||||
filename = file.split("/")[-1]
|
||||
filetype = filename.split(".")[-1]
|
||||
self.document_list.insertRow(0)
|
||||
@@ -1022,7 +1033,7 @@ class Ui(Ui_Semesterapparat):
|
||||
dialog = QtWidgets.QDialog()
|
||||
frame = parsed_titles_ui()
|
||||
frame.setupUi(dialog)
|
||||
dialogger.show()
|
||||
dialog.show()
|
||||
frame.signatures = signatures
|
||||
frame.populate_table()
|
||||
frame.progressBar.setMaximum(len(signatures))
|
||||
@@ -1042,7 +1053,7 @@ class Ui(Ui_Semesterapparat):
|
||||
else:
|
||||
# if file is selected, check for books in the file
|
||||
if self.document_list.currentRow() != -1:
|
||||
# #print("File selected")
|
||||
# #logger.debug("File selected")
|
||||
file = self.document_list.item(
|
||||
self.document_list.currentRow(), 3
|
||||
).text()
|
||||
@@ -1096,10 +1107,53 @@ class Ui(Ui_Semesterapparat):
|
||||
bookdata=book, app_id=app_id, prof_id=prof_id
|
||||
)
|
||||
self.update_app_media_list()
|
||||
# #print(len(signatures))
|
||||
# #logger.debug(len(signatures))
|
||||
|
||||
def extract_document_data(self) -> Union[None, list[str], SemapDocument]:
|
||||
file_type = self.document_list.item(self.document_list.currentRow(), 1).text()
|
||||
file_location = self.document_list.item(
|
||||
self.document_list.currentRow(), 3
|
||||
).text()
|
||||
file_name = self.document_list.item(self.document_list.currentRow(), 0).text()
|
||||
file = file_location
|
||||
logger.info("File selected: {}, {}", file_name, file_location)
|
||||
if file_location == "Database":
|
||||
# create warning, then return
|
||||
self.confirm_popup(
|
||||
"Dateien aus der Datenbank werden nicht unterstützt!",
|
||||
title="Fehler",
|
||||
)
|
||||
return None
|
||||
if file_type == "pdf":
|
||||
# Todo: implement parser here
|
||||
self.confirm_popup("PDF Dateien werden nicht unterstützt!", title="Fehler")
|
||||
return
|
||||
if file_type == "csv":
|
||||
signatures = csv_to_list(file)
|
||||
# add the data to the database
|
||||
return signatures
|
||||
if file_type == "docx":
|
||||
data = word_to_semap(file)
|
||||
logger.info("Converted data from semap file")
|
||||
logger.debug("Got the data: {}", data)
|
||||
|
||||
return data
|
||||
|
||||
def import_data_from_document(self):
|
||||
global valid_input
|
||||
data = self.extract_document_data()
|
||||
if data is None:
|
||||
return
|
||||
if isinstance(data, list):
|
||||
return
|
||||
|
||||
self.prof_mail.setText(data.mail)
|
||||
self.prof_tel_nr.setText(str(data.phoneNumber))
|
||||
self.app_name.setText(data.title)
|
||||
self.app_fach.setCurrentText(data.subject)
|
||||
|
||||
def btn_check_file_threaded(self):
|
||||
# #print("Checking file")
|
||||
# #logger.debug("Checking file")
|
||||
# get active app_id and prof_id
|
||||
self.tableWidget_apparate.setEnabled(False)
|
||||
self.tableWidget_apparate.setToolTip(
|
||||
@@ -1109,18 +1163,25 @@ class Ui(Ui_Semesterapparat):
|
||||
logger.debug(self.profdata)
|
||||
prof_id = self.db.getProfId(self.profdata)
|
||||
|
||||
logger.debug(prof_id)
|
||||
logger.debug("Prof id: {}", prof_id)
|
||||
# check if apparat in database
|
||||
|
||||
if prof_id is None:
|
||||
prof = Prof(
|
||||
fullname=self.drpdwn_prof_name.currentText(),
|
||||
telnr=self.prof_tel_nr.text(),
|
||||
mail=self.prof_mail.text(),
|
||||
firstname=self.drpdwn_prof_name.currentText().split(", ")[1],
|
||||
lastname=self.drpdwn_prof_name.currentText().split(", ")[0],
|
||||
)
|
||||
self.db.createProf(prof)
|
||||
# if app_id not in database, create apparat
|
||||
created = False
|
||||
if not self.db.checkApparatExistsById(app_id):
|
||||
logger.info("Apparat does not exist, creating new apparat")
|
||||
# create apparat
|
||||
# #print("Creating apparat")
|
||||
# #logger.debug("Creating apparat")
|
||||
if not self.btn_save_apparat(False):
|
||||
return
|
||||
created = True
|
||||
|
||||
if self.document_list.rowCount() == 0:
|
||||
logger.info("No file selected")
|
||||
self.tableWidget_apparate.setEnabled(True)
|
||||
@@ -1128,48 +1189,27 @@ class Ui(Ui_Semesterapparat):
|
||||
return
|
||||
else:
|
||||
# if file is selected, check for books in the file
|
||||
# #print("File selected")
|
||||
file_type = self.document_list.item(
|
||||
self.document_list.currentRow(), 1
|
||||
).text()
|
||||
file_location = self.document_list.item(
|
||||
self.document_list.currentRow(), 3
|
||||
).text()
|
||||
file_name = self.document_list.item(
|
||||
self.document_list.currentRow(), 0
|
||||
).text()
|
||||
logger.info("File selected: {}, {}", file_name, file_location)
|
||||
if file_location == "Database":
|
||||
logger.debug("Using file from database")
|
||||
file = recreateFile(file_name, app_id, file_type, open=False)
|
||||
logger.debug("recreated file from database")
|
||||
else:
|
||||
logger.debug("File not in database")
|
||||
if not created:
|
||||
logger.debug("File was not created, ")
|
||||
self.add_files(prof_id)
|
||||
if file_type == "pdf":
|
||||
# Todo: implement parser here
|
||||
self.confirm_popup(
|
||||
"PDF Dateien werden nicht unterstützt!", title="Fehler"
|
||||
)
|
||||
return
|
||||
if file_type == "csv":
|
||||
signatures = csv_to_list(file)
|
||||
# add the data to the database
|
||||
if file_type == "docx":
|
||||
data = word_to_semap(file)
|
||||
logger.info("Converted data from semap file")
|
||||
logger.debug("Got the data: {}", data)
|
||||
signatures = data.signatures
|
||||
logger.info("Got the signatures: {}", signatures)
|
||||
# #logger.debug("File selected")
|
||||
|
||||
if prof_id is None:
|
||||
prof_id = self.db.getProfId(self.profdata)
|
||||
|
||||
# print("Prof ID is None", prof_id)
|
||||
autoGrabber = BookGrabber(self.active_apparat)
|
||||
# logger.debug("Prof ID is None", prof_id)
|
||||
document = self.extract_document_data()
|
||||
if document is None:
|
||||
logger.error("Document is None")
|
||||
elif isinstance(document, SemapDocument):
|
||||
signatures = document.signatures
|
||||
else:
|
||||
signatures = document
|
||||
autoGrabber = BookGrabber()
|
||||
autoGrabber.add_values(
|
||||
mode="ARRAY", app_id=app_id, prof_id=prof_id, data=signatures
|
||||
mode="ARRAY",
|
||||
app_id=int(app_id),
|
||||
prof_id=int(prof_id),
|
||||
data=signatures,
|
||||
any_book=True,
|
||||
exact=True,
|
||||
)
|
||||
self.label_info.show()
|
||||
self.progress_label.show()
|
||||
@@ -1178,15 +1218,13 @@ class Ui(Ui_Semesterapparat):
|
||||
# self.autoGrabber.finished.connect(self.autoGrabber.deleteLater)
|
||||
autoGrabber.finished.connect(self.hide_progress_label)
|
||||
autoGrabber.finished.connect(self.unlock_apparate)
|
||||
|
||||
autoGrabber.updateSignal.connect(self.update_progress_label)
|
||||
# worker.finished.connect(worker.deleteLater)
|
||||
|
||||
autoGrabber.start()
|
||||
while autoGrabber.isRunning():
|
||||
QtWidgets.QApplication.processEvents()
|
||||
self.bookGrabber.append(autoGrabber)
|
||||
# refresh book table
|
||||
self.update_app_media_list()
|
||||
logger.debug("Finished adding media")
|
||||
# end of thread
|
||||
# self.autoGrabber.exit()
|
||||
# self.__clear_fields()
|
||||
@@ -1271,7 +1309,7 @@ class Ui(Ui_Semesterapparat):
|
||||
pid=appd.prof.fullname,
|
||||
)
|
||||
if clear_fields:
|
||||
# #print("clearing fields")
|
||||
# #logger.debug("clearing fields")
|
||||
self.__clear_fields()
|
||||
return True
|
||||
|
||||
@@ -1398,7 +1436,7 @@ class Ui(Ui_Semesterapparat):
|
||||
appnr = self.tableWidget_apparate.item(tableposition, 0).text()
|
||||
if reminder.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||
data = reminder.return_message()
|
||||
# #print(data)
|
||||
# #logger.debug(data)
|
||||
self.db.addMessage(
|
||||
data,
|
||||
self.active_user,
|
||||
@@ -1418,7 +1456,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
def open_reminder(self):
|
||||
selected_date = self.calendarWidget.selectedDate().toString("yyyy-MM-dd")
|
||||
# # #print(selected_date)
|
||||
# # #logger.debug(selected_date)
|
||||
messages = self.db.getMessages(selected_date)
|
||||
if messages == []:
|
||||
return
|
||||
@@ -1431,13 +1469,13 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
|
||||
def open_settings(self):
|
||||
# print(settings.dict())
|
||||
# logger.debug(settings.dict())
|
||||
settingsUI = Settings(self.active_user)
|
||||
settingsUI.exec()
|
||||
|
||||
if settingsUI.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||
settingsUI.save()
|
||||
# print(settings.dict())
|
||||
# logger.debug(settings.dict())
|
||||
|
||||
# self.reload()
|
||||
|
||||
@@ -1563,7 +1601,7 @@ class Ui(Ui_Semesterapparat):
|
||||
signature=signature,
|
||||
prof_id=self.db.getProfId(self.profdata),
|
||||
)
|
||||
# print(medium.adis_idn, medium.signature)
|
||||
# logger.debug(medium.adis_idn, medium.signature)
|
||||
|
||||
def edit_medium(self):
|
||||
book = self.tableWidget_apparat_media.item(
|
||||
@@ -1590,10 +1628,10 @@ class Ui(Ui_Semesterapparat):
|
||||
widget.exec()
|
||||
if widget.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||
data = bookedit.get_data()
|
||||
# #print(data)
|
||||
# #logger.debug(data)
|
||||
self.db.updateBookdata(bookdata=data, book_id=book_id)
|
||||
# self.db.update_bookdata(data)
|
||||
# #print("accepted")
|
||||
# #logger.debug("accepted")
|
||||
self.update_app_media_list()
|
||||
else:
|
||||
return
|
||||
@@ -1617,7 +1655,7 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
message = f'Soll das Medium "{self.tableWidget_apparat_media.item(self.tableWidget_apparat_media.currentRow(), 0).text()}" wirklich gelöscht werden?'
|
||||
state = self.confirm_popup(message, title="Löschen?")
|
||||
# #print(state)
|
||||
# #logger.debug(state)
|
||||
if state == 1:
|
||||
self.db.deleteBook(book_id)
|
||||
self.update_app_media_list()
|
||||
@@ -1629,7 +1667,7 @@ class Ui(Ui_Semesterapparat):
|
||||
for r in ranges:
|
||||
for row in range(r.topRow(), r.bottomRow() + 1):
|
||||
rows.append(row)
|
||||
# #print(rows)
|
||||
# #logger.debug(rows)
|
||||
message = f"Sollen die {len(rows)} Medien wirklich gelöscht werden?"
|
||||
state = self.confirm_popup(message, title="Löschen?")
|
||||
if state == 1:
|
||||
@@ -1649,12 +1687,12 @@ class Ui(Ui_Semesterapparat):
|
||||
# return data from dialog if ok is pressed
|
||||
if framework.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||
data = framework.get_data()
|
||||
# #print(data)
|
||||
# #logger.debug(data)
|
||||
# return data
|
||||
selected_apparat_id = self.tableWidget_apparate.item(
|
||||
self.tableWidget_apparate.currentRow(), 0
|
||||
).text()
|
||||
# #print(selected_apparat_id)
|
||||
# #logger.debug(selected_apparat_id)
|
||||
|
||||
self.db.setNewSemesterDate(
|
||||
selected_apparat_id, data["semester"], dauerapp=data["dauerapp"]
|
||||
@@ -1725,7 +1763,7 @@ class Ui(Ui_Semesterapparat):
|
||||
).text()
|
||||
message = f"Soll der Apparat {selected_apparat_id} wirklich gelöscht werden?"
|
||||
state = self.confirm_popup(message, title="Löschen?")
|
||||
# #print(state)
|
||||
# #logger.debug(state)
|
||||
logger.info("Result state: {}", state)
|
||||
if state == 1:
|
||||
logger.debug("Deleting apparat {}", selected_apparat_id)
|
||||
@@ -1737,7 +1775,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.apparats.remove(apparat)
|
||||
break
|
||||
self.old_apparats = self.apparats
|
||||
# #print(self.apparats)
|
||||
# #logger.debug(self.apparats)
|
||||
# remove the row from the table
|
||||
self.tableWidget_apparate.removeRow(self.tableWidget_apparate.currentRow())
|
||||
# send mail to prof
|
||||
@@ -1745,8 +1783,8 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
|
||||
def launch_gui():
|
||||
# #print("trying to login")
|
||||
# #print("checking if database available")
|
||||
# #logger.debug("trying to login")
|
||||
# #logger.debug("checking if database available")
|
||||
|
||||
logger.info("Starting login dialog")
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
@@ -1758,11 +1796,11 @@ def launch_gui():
|
||||
if ui.lresult == 1:
|
||||
# if login is successful, open main window
|
||||
# show login dialog
|
||||
# #print(ui.lusername)
|
||||
# #logger.debug(ui.lusername)
|
||||
MainWindow = QtWidgets.QMainWindow()
|
||||
aui = Ui(MainWindow, username=ui.lusername)
|
||||
|
||||
# #print(aui.active_user)
|
||||
# #logger.debug(aui.active_user)
|
||||
MainWindow.show()
|
||||
# atexit.register()
|
||||
atexit.register(tempdelete)
|
||||
@@ -1779,7 +1817,7 @@ def launch_gui():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# #print("This is the main window")
|
||||
# #logger.debug("This is the main window")
|
||||
# app = QtWidgets.QApplication(sys.argv)
|
||||
# window = MainWindow()
|
||||
# app.exec()
|
||||
|
||||
@@ -83,7 +83,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
apparats.append(self.tableWidget.item(row.row(), 1).text())
|
||||
for apparat in apparats:
|
||||
apparat_id = self.db.getApparatId(apparat)
|
||||
self.db.restoreApparat(apparat_id)
|
||||
self.db.restoreApparat(apparat_id, apparat)
|
||||
# remove the red color from the row
|
||||
# get row where the apparat is
|
||||
row = self.tableWidget.findItems(apparat, QtCore.Qt.MatchFlag.MatchExactly)[
|
||||
|
||||
Reference in New Issue
Block a user