add type checking, update deletion function in searchpage, add function to import apparat data from document
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
__all__ = ["__version__", "__author__", "Icon", "settings"]
|
||||||
from config import Config
|
from config import Config
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,9 @@ from loguru import logger as log
|
|||||||
|
|
||||||
logger = log
|
logger = log
|
||||||
logger.remove()
|
logger.remove()
|
||||||
logger.add("logs/database.log", rotation="1 week", enqueue=True)
|
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||||
log.add(
|
log.add(
|
||||||
"logs/application.log",
|
"logs/database.log",
|
||||||
rotation="1 day",
|
|
||||||
compression="zip",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||||
@@ -72,7 +70,7 @@ class Database:
|
|||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
# create path
|
# create path
|
||||||
# print(path)
|
# logger.debug(path)
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if self.get_db_contents() == []:
|
if self.get_db_contents() == []:
|
||||||
logger.critical("Database does not exist, creating tables")
|
logger.critical("Database does not exist, creating tables")
|
||||||
@@ -227,11 +225,11 @@ class Database:
|
|||||||
f"SELECT bookdata FROM media WHERE app_id={app_id} AND prof_id={prof_id}"
|
f"SELECT bookdata FROM media WHERE app_id={app_id} AND prof_id={prof_id}"
|
||||||
)
|
)
|
||||||
logger.debug(t_query)
|
logger.debug(t_query)
|
||||||
# # print(t_query)
|
# # logger.debug(t_query)
|
||||||
result = cursor.execute(t_query).fetchall()
|
result = cursor.execute(t_query).fetchall()
|
||||||
result = [load_pickle(i[0]) for i in result]
|
result = [load_pickle(i[0]) for i in result]
|
||||||
if bookdata in result:
|
if bookdata in result:
|
||||||
# print("Bookdata already in database")
|
# logger.debug("Bookdata already in database")
|
||||||
# check if the book was deleted in the apparat
|
# check if the book was deleted in the apparat
|
||||||
query = (
|
query = (
|
||||||
"SELECT deleted FROM media WHERE app_id=? AND prof_id=? AND bookdata=?"
|
"SELECT deleted FROM media WHERE app_id=? AND prof_id=? AND bookdata=?"
|
||||||
@@ -239,7 +237,7 @@ class Database:
|
|||||||
params = (app_id, prof_id, dump_pickle(bookdata))
|
params = (app_id, prof_id, dump_pickle(bookdata))
|
||||||
result = cursor.execute(query, params).fetchone()
|
result = cursor.execute(query, params).fetchone()
|
||||||
if result[0] == 1:
|
if result[0] == 1:
|
||||||
# print("Book was deleted, updating bookdata")
|
# logger.debug("Book was deleted, updating bookdata")
|
||||||
query = "UPDATE media SET deleted=0 WHERE app_id=? AND prof_id=? AND bookdata=?"
|
query = "UPDATE media SET deleted=0 WHERE app_id=? AND prof_id=? AND bookdata=?"
|
||||||
params = (app_id, prof_id, dump_pickle(bookdata))
|
params = (app_id, prof_id, dump_pickle(bookdata))
|
||||||
cursor.execute(query, params)
|
cursor.execute(query, params)
|
||||||
@@ -511,7 +509,7 @@ class Database:
|
|||||||
delete=False, dir=tempdir_path, mode="wb", suffix=f".{filetype}"
|
delete=False, dir=tempdir_path, mode="wb", suffix=f".{filetype}"
|
||||||
)
|
)
|
||||||
file.write(blob)
|
file.write(blob)
|
||||||
# print("file created")
|
# logger.debug("file created")
|
||||||
return file.name
|
return file.name
|
||||||
|
|
||||||
def getFiles(self, app_id: Union[str, int], prof_id: int) -> list[tuple]:
|
def getFiles(self, app_id: Union[str, int], prof_id: int) -> list[tuple]:
|
||||||
@@ -539,7 +537,7 @@ class Database:
|
|||||||
return [i[0] for i in data]
|
return [i[0] for i in data]
|
||||||
|
|
||||||
def insertSubjects(self):
|
def insertSubjects(self):
|
||||||
# print("Inserting subjects")
|
# logger.debug("Inserting subjects")
|
||||||
subjects = [
|
subjects = [
|
||||||
"Biologie",
|
"Biologie",
|
||||||
"Chemie",
|
"Chemie",
|
||||||
@@ -897,7 +895,7 @@ class Database:
|
|||||||
)
|
)
|
||||||
ret = []
|
ret = []
|
||||||
for i in data:
|
for i in data:
|
||||||
print(i)
|
logger.debug(i)
|
||||||
ret.append(Apparat().from_tuple(i))
|
ret.append(Apparat().from_tuple(i))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@@ -1110,9 +1108,9 @@ class Database:
|
|||||||
kwargs["dauer"] = kwargs["dauer"].replace("Ja", "1").replace("Nein", "0")
|
kwargs["dauer"] = kwargs["dauer"].replace("Ja", "1").replace("Nein", "0")
|
||||||
query = "SELECT * FROM semesterapparat WHERE "
|
query = "SELECT * FROM semesterapparat WHERE "
|
||||||
for key, value in kwargs.items() if kwargs.items() is not None else {}:
|
for key, value in kwargs.items() if kwargs.items() is not None else {}:
|
||||||
# print(key, value)
|
# logger.debug(key, value)
|
||||||
query += f"{key}='{value}' AND "
|
query += f"{key}='{value}' AND "
|
||||||
# print(query)
|
# logger.debug(query)
|
||||||
# remove deletesemester part from normal query, as this will be added to the database upon deleting the apparat
|
# remove deletesemester part from normal query, as this will be added to the database upon deleting the apparat
|
||||||
if "deletesemester" in kwargs.keys():
|
if "deletesemester" in kwargs.keys():
|
||||||
query = query.replace(
|
query = query.replace(
|
||||||
@@ -1128,7 +1126,7 @@ class Database:
|
|||||||
query = query.replace(
|
query = query.replace(
|
||||||
f"endsemester='{kwargs['endsemester']}' AND ", "xyz"
|
f"endsemester='{kwargs['endsemester']}' AND ", "xyz"
|
||||||
)
|
)
|
||||||
# print("replaced")
|
# logger.debug("replaced")
|
||||||
query = query.replace(
|
query = query.replace(
|
||||||
"xyz",
|
"xyz",
|
||||||
f"(erstellsemester='{kwargs['endsemester']}' OR verlängerung_bis='{kwargs['endsemester']}') AND ",
|
f"(erstellsemester='{kwargs['endsemester']}' OR verlängerung_bis='{kwargs['endsemester']}') AND ",
|
||||||
@@ -1143,9 +1141,9 @@ class Database:
|
|||||||
query = query[:-1]
|
query = query[:-1]
|
||||||
query = query.strip()
|
query = query.strip()
|
||||||
|
|
||||||
# print(query)
|
# logger.debug(query)
|
||||||
res = __query(query)
|
res = __query(query)
|
||||||
# print(res)
|
# logger.debug(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# Admin data
|
# Admin data
|
||||||
@@ -1314,15 +1312,15 @@ class Database:
|
|||||||
"""
|
"""
|
||||||
return self.query_db("SELECT titel, fname,lname,mail,telnr,fullname FROM prof")
|
return self.query_db("SELECT titel, fname,lname,mail,telnr,fullname FROM prof")
|
||||||
|
|
||||||
def restoreApparat(self, app_id: Union[str, int]):
|
def restoreApparat(self, app_id: Union[str, int], app_name: str):
|
||||||
"""restore an apparat from the database
|
"""restore an apparat from the database
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
app_id (Union[str, int]): the id of the apparat
|
app_id (Union[str, int]): the id of the apparat
|
||||||
"""
|
"""
|
||||||
return self.query_db(
|
return self.query_db(
|
||||||
"UPDATE semesterapparat SET deletion_status=0, deleted_date=NULL WHERE appnr=?",
|
"UPDATE semesterapparat SET deletion_status=0, deleted_date=NULL WHERE appnr=? and name=?",
|
||||||
(app_id,),
|
(app_id, app_name),
|
||||||
)
|
)
|
||||||
|
|
||||||
# ELSA
|
# ELSA
|
||||||
@@ -1433,7 +1431,7 @@ class Database:
|
|||||||
blob = self.query_db(
|
blob = self.query_db(
|
||||||
"SELECT fileblob FROM elsa_files WHERE filename=?", (filename,), one=True
|
"SELECT fileblob FROM elsa_files WHERE filename=?", (filename,), one=True
|
||||||
)[0]
|
)[0]
|
||||||
# print(blob)
|
# logger.debug(blob)
|
||||||
tempdir = self.database.tempdir
|
tempdir = self.database.tempdir
|
||||||
tempdir = tempdir.replace("~", str(Path.home()))
|
tempdir = tempdir.replace("~", str(Path.home()))
|
||||||
tempdir_path = Path(tempdir)
|
tempdir_path = Path(tempdir)
|
||||||
@@ -1443,7 +1441,7 @@ class Database:
|
|||||||
delete=False, dir=tempdir_path, mode="wb", suffix=f".{filetype}"
|
delete=False, dir=tempdir_path, mode="wb", suffix=f".{filetype}"
|
||||||
)
|
)
|
||||||
file.write(blob)
|
file.write(blob)
|
||||||
# print("file created")
|
# logger.debug("file created")
|
||||||
return file.name
|
return file.name
|
||||||
|
|
||||||
def getElsaApparats(self) -> ELSA:
|
def getElsaApparats(self) -> ELSA:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import pathlib
|
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 (
|
# from .dialogs import (
|
||||||
# ApparatExtendDialog,
|
# ApparatExtendDialog,
|
||||||
|
|||||||
@@ -595,67 +595,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
</widget>
|
</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">
|
<widget class="QLabel" name="appname_mand">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
@@ -1506,6 +1445,103 @@
|
|||||||
<string>Speichern und anlegen</string>
|
<string>Speichern und anlegen</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</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 tempfile
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any, Union
|
||||||
|
|
||||||
from natsort import natsorted
|
from natsort import natsorted
|
||||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||||
from PyQt6.QtCore import QThread
|
from PyQt6.QtCore import QThread
|
||||||
@@ -25,6 +26,7 @@ from src.logic import (
|
|||||||
BookData,
|
BookData,
|
||||||
csv_to_list,
|
csv_to_list,
|
||||||
word_to_semap,
|
word_to_semap,
|
||||||
|
SemapDocument,
|
||||||
Prof,
|
Prof,
|
||||||
Apparat,
|
Apparat,
|
||||||
)
|
)
|
||||||
@@ -87,6 +89,9 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.check_file.clicked.connect( # type:ignore
|
self.check_file.clicked.connect( # type:ignore
|
||||||
self.btn_check_file_threaded
|
self.btn_check_file_threaded
|
||||||
) # default: self.add_media_from_file
|
) # 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.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_save.clicked.connect(lambda: self.btn_save_apparat(True)) # type:ignore
|
||||||
self.btn_apparat_apply.clicked.connect(self.update_apparat) # 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(
|
self.prof_tel_nr.setValidator(
|
||||||
QtGui.QRegularExpressionValidator(QtCore.QRegularExpression(r"^\d{3,14}"))
|
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
|
self.app_fach.setValidator( # validator to allow typing in the app_fach field
|
||||||
QtGui.QRegularExpressionValidator(
|
QtGui.QRegularExpressionValidator(
|
||||||
QtCore.QRegularExpression(r"[a-zA-Z0-9\s\W]+")
|
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
|
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)
|
userrole = self.db.getRole(self.active_user)
|
||||||
# hide admin interface when non-admin is logged in
|
# hide admin interface when non-admin is logged in
|
||||||
if userrole == "admin":
|
if userrole == "admin":
|
||||||
@@ -201,7 +206,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.validate_thread.start()
|
self.validate_thread.start()
|
||||||
self.add_medium.setEnabled(False)
|
self.add_medium.setEnabled(False)
|
||||||
self.docu = DocumentationThread()
|
self.docu = DocumentationThread()
|
||||||
self.docu.start()
|
|
||||||
self.actionDokumentation_lokal.triggered.connect(self.open_documentation) # type:ignore
|
self.actionDokumentation_lokal.triggered.connect(self.open_documentation) # type:ignore
|
||||||
|
|
||||||
# get all current apparats and cache them in a list
|
# get all current apparats and cache them in a list
|
||||||
@@ -251,6 +256,8 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
self.steps.hide()
|
self.steps.hide()
|
||||||
|
|
||||||
|
self.valid_check_semester.clicked.connect(self.display_valid_semester) # type:ignore
|
||||||
|
|
||||||
def create_doc(self):
|
def create_doc(self):
|
||||||
result = self.confirm_popup(
|
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",
|
"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}")
|
logger.debug(f"Result: {result}")
|
||||||
if result == 1:
|
if result == 1:
|
||||||
# print("Creating document")
|
# logger.debug("Creating document")
|
||||||
apparats = self.apparats
|
apparats = self.apparats
|
||||||
apps = []
|
apps = []
|
||||||
for apparat in apparats:
|
for apparat in apparats:
|
||||||
prof = self.db.getProf(apparat[2])
|
prof = self.db.getProf(apparat[2])
|
||||||
data = (apparat[4], f"{prof.lastname} ({apparat[1]})")
|
data = (apparat[4], f"{prof.lastname} ({apparat[1]})")
|
||||||
apps.append(data)
|
apps.append(data)
|
||||||
# print(apps)
|
# logger.debug(apps)
|
||||||
logger.info("Using apparats: {}", apps)
|
logger.info("Using apparats: {}", apps)
|
||||||
doc = SemesterDocument(
|
doc = SemesterDocument(
|
||||||
semester=Semester().value,
|
semester=Semester().value,
|
||||||
@@ -350,6 +357,8 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
def open_documentation(self):
|
def open_documentation(self):
|
||||||
logger.info("Opening Documentation")
|
logger.info("Opening Documentation")
|
||||||
|
if not self.docu.isRunning():
|
||||||
|
self.docu.start()
|
||||||
webbrowser.open("http://localhost:8000")
|
webbrowser.open("http://localhost:8000")
|
||||||
|
|
||||||
def update_calendar(self, data):
|
def update_calendar(self, data):
|
||||||
@@ -372,7 +381,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
statistics.updateCalendar.connect(self.update_calendar)
|
statistics.updateCalendar.connect(self.update_calendar)
|
||||||
stats_layout.addWidget(statistics)
|
stats_layout.addWidget(statistics)
|
||||||
|
|
||||||
# #print("searchpage")
|
# #logger.debug("searchpage")
|
||||||
if self.tabWidget.currentIndex() == 0: # Apparate
|
if self.tabWidget.currentIndex() == 0: # Apparate
|
||||||
# clear all entries from the table
|
# clear all entries from the table
|
||||||
self.tableWidget_apparate.setRowCount(0)
|
self.tableWidget_apparate.setRowCount(0)
|
||||||
@@ -390,7 +399,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
widget.deleteLater()
|
widget.deleteLater()
|
||||||
|
|
||||||
elsa_layout.addWidget(ElsaDialog())
|
elsa_layout.addWidget(ElsaDialog())
|
||||||
# print("added")
|
# logger.debug("added")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def generateSemester(self, today=False):
|
def generateSemester(self, today=False):
|
||||||
@@ -433,9 +442,9 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.prof_mail.setText(appdata.prof.mail)
|
self.prof_mail.setText(appdata.prof.mail)
|
||||||
self.prof_tel_nr.setText(appdata.prof.telnr)
|
self.prof_tel_nr.setText(appdata.prof.telnr)
|
||||||
self.app_name.setText(appdata.apparat.name)
|
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)
|
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])
|
self.sem_year.setText(appdata.apparat.get_semester.split(" ")[1])
|
||||||
match appdata.apparat.get_semester.split(" ")[0]:
|
match appdata.apparat.get_semester.split(" ")[0]:
|
||||||
case "SoSe":
|
case "SoSe":
|
||||||
@@ -500,7 +509,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
return popup.result()
|
return popup.result()
|
||||||
|
|
||||||
def thread_check(self):
|
def thread_check(self):
|
||||||
# #print("Thread started")
|
# #logger.debug("Thread started")
|
||||||
self.prof_mail.textChanged.connect(self.validate_prof_mail)
|
self.prof_mail.textChanged.connect(self.validate_prof_mail)
|
||||||
self.drpdwn_prof_name.editTextChanged.connect(self.validate_prof_name)
|
self.drpdwn_prof_name.editTextChanged.connect(self.validate_prof_name)
|
||||||
self.prof_tel_nr.textChanged.connect(self.validate_prof_tel)
|
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)
|
self.__setValidState(self.valid_check_app_fach, 0, self.fach_mand, 4)
|
||||||
|
|
||||||
def validate_semester(self):
|
def validate_semester(self):
|
||||||
if (
|
valid = (self.sem_sommer.isChecked() or self.sem_winter.isChecked()) and len(
|
||||||
self.app_group_box.isEnabled()
|
self.sem_year.text()
|
||||||
and (
|
) >= 2
|
||||||
(self.sem_sommer.isChecked() or self.sem_winter.isChecked())
|
if valid or self.check_eternal_app.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()
|
|
||||||
):
|
|
||||||
self.__setValidState(self.valid_check_semester, 1, self._mand, 5)
|
self.__setValidState(self.valid_check_semester, 1, self._mand, 5)
|
||||||
self.check_eternal_app.setEnabled(True)
|
self.check_eternal_app.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
self.__setValidState(self.valid_check_semester, 0, self._mand, 5)
|
self.__setValidState(self.valid_check_semester, 0, self._mand, 5)
|
||||||
self.check_eternal_app.setEnabled(False)
|
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):
|
def change_state(self, index, state):
|
||||||
global valid_input
|
global valid_input
|
||||||
valid_input = list(valid_input)
|
valid_input = list(valid_input)
|
||||||
@@ -706,12 +717,12 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.drpdwn_prof_name.clear()
|
self.drpdwn_prof_name.clear()
|
||||||
# set drop down menu for apparat numbers to only available numbers
|
# set drop down menu for apparat numbers to only available numbers
|
||||||
taken_app_nrs = self.db.getUnavailableApparatNumbers()
|
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)
|
valid_input = (0, 0, 0, 0, 0, 0)
|
||||||
self.populate_prof_dropdown()
|
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}"
|
text = f"Medium {curr}/{total}"
|
||||||
logger.info(text)
|
logger.info(text)
|
||||||
self.progress_label.setText(text)
|
self.progress_label.setText(text)
|
||||||
@@ -769,7 +780,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
bookGrabber.start()
|
bookGrabber.start()
|
||||||
while bookGrabber.isRunning():
|
while bookGrabber.isRunning():
|
||||||
# #print("waiting for thread to finish")
|
# #logger.debug("waiting for thread to finish")
|
||||||
QtWidgets.QApplication.processEvents()
|
QtWidgets.QApplication.processEvents()
|
||||||
|
|
||||||
# self.__clear_fields()
|
# self.__clear_fields()
|
||||||
@@ -814,7 +825,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
# thread = QThread()
|
# thread = QThread()
|
||||||
appnumber = self.active_apparat
|
appnumber = self.active_apparat
|
||||||
# #print(links)
|
# #logger.debug(links)
|
||||||
self.availChecker = AvailChecker(links, appnumber, books=books)
|
self.availChecker = AvailChecker(links, appnumber, books=books)
|
||||||
# availcheck.moveToThread(thread)
|
# availcheck.moveToThread(thread)
|
||||||
# availcheck.finished.connect(thread.quit)
|
# availcheck.finished.connect(thread.quit)
|
||||||
@@ -863,7 +874,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
app_id, prof_id, deleted
|
app_id, prof_id, deleted
|
||||||
)
|
)
|
||||||
|
|
||||||
# # #print(books)
|
# # #logger.debug(books)
|
||||||
# take the dataclass from the tuple
|
# take the dataclass from the tuple
|
||||||
# booklist:list[BookData]=[book[0] for book in books]
|
# booklist:list[BookData]=[book[0] for book in books]
|
||||||
self.tableWidget_apparat_media.setRowCount(0)
|
self.tableWidget_apparat_media.setRowCount(0)
|
||||||
@@ -872,7 +883,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
book_data = book["bookdata"]
|
book_data = book["bookdata"]
|
||||||
availability = book["available"]
|
availability = book["available"]
|
||||||
# bd = BookData().from_string(book)
|
# bd = BookData().from_string(book)
|
||||||
# # #print(bd, type(bd))
|
# # #logger.debug(bd, type(bd))
|
||||||
# create a new row below the last one
|
# create a new row below the last one
|
||||||
self.tableWidget_apparat_media.insertRow(
|
self.tableWidget_apparat_media.insertRow(
|
||||||
self.tableWidget_apparat_media.rowCount()
|
self.tableWidget_apparat_media.rowCount()
|
||||||
@@ -966,11 +977,11 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.drpdwn_prof_name.addItem(prof)
|
self.drpdwn_prof_name.addItem(prof)
|
||||||
|
|
||||||
def add_document(self):
|
def add_document(self):
|
||||||
# #print("Add document")
|
# #logger.debug("Add document")
|
||||||
picker = FilePicker()
|
picker = FilePicker()
|
||||||
files = picker.pick_files()
|
files = picker.pick_files()
|
||||||
for file in files:
|
for file in files:
|
||||||
# #print(file)
|
# #logger.debug(file)
|
||||||
filename = file.split("/")[-1]
|
filename = file.split("/")[-1]
|
||||||
filetype = filename.split(".")[-1]
|
filetype = filename.split(".")[-1]
|
||||||
self.document_list.insertRow(0)
|
self.document_list.insertRow(0)
|
||||||
@@ -1022,7 +1033,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
dialog = QtWidgets.QDialog()
|
dialog = QtWidgets.QDialog()
|
||||||
frame = parsed_titles_ui()
|
frame = parsed_titles_ui()
|
||||||
frame.setupUi(dialog)
|
frame.setupUi(dialog)
|
||||||
dialogger.show()
|
dialog.show()
|
||||||
frame.signatures = signatures
|
frame.signatures = signatures
|
||||||
frame.populate_table()
|
frame.populate_table()
|
||||||
frame.progressBar.setMaximum(len(signatures))
|
frame.progressBar.setMaximum(len(signatures))
|
||||||
@@ -1042,7 +1053,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
else:
|
else:
|
||||||
# if file is selected, check for books in the file
|
# if file is selected, check for books in the file
|
||||||
if self.document_list.currentRow() != -1:
|
if self.document_list.currentRow() != -1:
|
||||||
# #print("File selected")
|
# #logger.debug("File selected")
|
||||||
file = self.document_list.item(
|
file = self.document_list.item(
|
||||||
self.document_list.currentRow(), 3
|
self.document_list.currentRow(), 3
|
||||||
).text()
|
).text()
|
||||||
@@ -1096,10 +1107,53 @@ class Ui(Ui_Semesterapparat):
|
|||||||
bookdata=book, app_id=app_id, prof_id=prof_id
|
bookdata=book, app_id=app_id, prof_id=prof_id
|
||||||
)
|
)
|
||||||
self.update_app_media_list()
|
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):
|
def btn_check_file_threaded(self):
|
||||||
# #print("Checking file")
|
# #logger.debug("Checking file")
|
||||||
# get active app_id and prof_id
|
# get active app_id and prof_id
|
||||||
self.tableWidget_apparate.setEnabled(False)
|
self.tableWidget_apparate.setEnabled(False)
|
||||||
self.tableWidget_apparate.setToolTip(
|
self.tableWidget_apparate.setToolTip(
|
||||||
@@ -1109,18 +1163,25 @@ class Ui(Ui_Semesterapparat):
|
|||||||
logger.debug(self.profdata)
|
logger.debug(self.profdata)
|
||||||
prof_id = self.db.getProfId(self.profdata)
|
prof_id = self.db.getProfId(self.profdata)
|
||||||
|
|
||||||
logger.debug(prof_id)
|
logger.debug("Prof id: {}", prof_id)
|
||||||
# check if apparat in database
|
# 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
|
# if app_id not in database, create apparat
|
||||||
created = False
|
|
||||||
if not self.db.checkApparatExistsById(app_id):
|
if not self.db.checkApparatExistsById(app_id):
|
||||||
logger.info("Apparat does not exist, creating new apparat")
|
logger.info("Apparat does not exist, creating new apparat")
|
||||||
# create apparat
|
# create apparat
|
||||||
# #print("Creating apparat")
|
# #logger.debug("Creating apparat")
|
||||||
if not self.btn_save_apparat(False):
|
if not self.btn_save_apparat(False):
|
||||||
return
|
return
|
||||||
created = True
|
|
||||||
if self.document_list.rowCount() == 0:
|
if self.document_list.rowCount() == 0:
|
||||||
logger.info("No file selected")
|
logger.info("No file selected")
|
||||||
self.tableWidget_apparate.setEnabled(True)
|
self.tableWidget_apparate.setEnabled(True)
|
||||||
@@ -1128,48 +1189,27 @@ class Ui(Ui_Semesterapparat):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# if file is selected, check for books in the file
|
# if file is selected, check for books in the file
|
||||||
# #print("File selected")
|
# #logger.debug("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)
|
|
||||||
if prof_id is None:
|
if prof_id is None:
|
||||||
prof_id = self.db.getProfId(self.profdata)
|
prof_id = self.db.getProfId(self.profdata)
|
||||||
|
|
||||||
# print("Prof ID is None", prof_id)
|
# logger.debug("Prof ID is None", prof_id)
|
||||||
autoGrabber = BookGrabber(self.active_apparat)
|
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(
|
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.label_info.show()
|
||||||
self.progress_label.show()
|
self.progress_label.show()
|
||||||
@@ -1178,15 +1218,13 @@ class Ui(Ui_Semesterapparat):
|
|||||||
# self.autoGrabber.finished.connect(self.autoGrabber.deleteLater)
|
# self.autoGrabber.finished.connect(self.autoGrabber.deleteLater)
|
||||||
autoGrabber.finished.connect(self.hide_progress_label)
|
autoGrabber.finished.connect(self.hide_progress_label)
|
||||||
autoGrabber.finished.connect(self.unlock_apparate)
|
autoGrabber.finished.connect(self.unlock_apparate)
|
||||||
|
|
||||||
autoGrabber.updateSignal.connect(self.update_progress_label)
|
autoGrabber.updateSignal.connect(self.update_progress_label)
|
||||||
# worker.finished.connect(worker.deleteLater)
|
# worker.finished.connect(worker.deleteLater)
|
||||||
|
|
||||||
autoGrabber.start()
|
autoGrabber.start()
|
||||||
while autoGrabber.isRunning():
|
self.bookGrabber.append(autoGrabber)
|
||||||
QtWidgets.QApplication.processEvents()
|
|
||||||
# refresh book table
|
# refresh book table
|
||||||
self.update_app_media_list()
|
logger.debug("Finished adding media")
|
||||||
# end of thread
|
# end of thread
|
||||||
# self.autoGrabber.exit()
|
# self.autoGrabber.exit()
|
||||||
# self.__clear_fields()
|
# self.__clear_fields()
|
||||||
@@ -1271,7 +1309,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
pid=appd.prof.fullname,
|
pid=appd.prof.fullname,
|
||||||
)
|
)
|
||||||
if clear_fields:
|
if clear_fields:
|
||||||
# #print("clearing fields")
|
# #logger.debug("clearing fields")
|
||||||
self.__clear_fields()
|
self.__clear_fields()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -1398,7 +1436,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
appnr = self.tableWidget_apparate.item(tableposition, 0).text()
|
appnr = self.tableWidget_apparate.item(tableposition, 0).text()
|
||||||
if reminder.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
if reminder.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||||
data = reminder.return_message()
|
data = reminder.return_message()
|
||||||
# #print(data)
|
# #logger.debug(data)
|
||||||
self.db.addMessage(
|
self.db.addMessage(
|
||||||
data,
|
data,
|
||||||
self.active_user,
|
self.active_user,
|
||||||
@@ -1418,7 +1456,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
def open_reminder(self):
|
def open_reminder(self):
|
||||||
selected_date = self.calendarWidget.selectedDate().toString("yyyy-MM-dd")
|
selected_date = self.calendarWidget.selectedDate().toString("yyyy-MM-dd")
|
||||||
# # #print(selected_date)
|
# # #logger.debug(selected_date)
|
||||||
messages = self.db.getMessages(selected_date)
|
messages = self.db.getMessages(selected_date)
|
||||||
if messages == []:
|
if messages == []:
|
||||||
return
|
return
|
||||||
@@ -1431,13 +1469,13 @@ class Ui(Ui_Semesterapparat):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def open_settings(self):
|
def open_settings(self):
|
||||||
# print(settings.dict())
|
# logger.debug(settings.dict())
|
||||||
settingsUI = Settings(self.active_user)
|
settingsUI = Settings(self.active_user)
|
||||||
settingsUI.exec()
|
settingsUI.exec()
|
||||||
|
|
||||||
if settingsUI.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
if settingsUI.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||||
settingsUI.save()
|
settingsUI.save()
|
||||||
# print(settings.dict())
|
# logger.debug(settings.dict())
|
||||||
|
|
||||||
# self.reload()
|
# self.reload()
|
||||||
|
|
||||||
@@ -1563,7 +1601,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
signature=signature,
|
signature=signature,
|
||||||
prof_id=self.db.getProfId(self.profdata),
|
prof_id=self.db.getProfId(self.profdata),
|
||||||
)
|
)
|
||||||
# print(medium.adis_idn, medium.signature)
|
# logger.debug(medium.adis_idn, medium.signature)
|
||||||
|
|
||||||
def edit_medium(self):
|
def edit_medium(self):
|
||||||
book = self.tableWidget_apparat_media.item(
|
book = self.tableWidget_apparat_media.item(
|
||||||
@@ -1590,10 +1628,10 @@ class Ui(Ui_Semesterapparat):
|
|||||||
widget.exec()
|
widget.exec()
|
||||||
if widget.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
if widget.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||||
data = bookedit.get_data()
|
data = bookedit.get_data()
|
||||||
# #print(data)
|
# #logger.debug(data)
|
||||||
self.db.updateBookdata(bookdata=data, book_id=book_id)
|
self.db.updateBookdata(bookdata=data, book_id=book_id)
|
||||||
# self.db.update_bookdata(data)
|
# self.db.update_bookdata(data)
|
||||||
# #print("accepted")
|
# #logger.debug("accepted")
|
||||||
self.update_app_media_list()
|
self.update_app_media_list()
|
||||||
else:
|
else:
|
||||||
return
|
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?'
|
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?")
|
state = self.confirm_popup(message, title="Löschen?")
|
||||||
# #print(state)
|
# #logger.debug(state)
|
||||||
if state == 1:
|
if state == 1:
|
||||||
self.db.deleteBook(book_id)
|
self.db.deleteBook(book_id)
|
||||||
self.update_app_media_list()
|
self.update_app_media_list()
|
||||||
@@ -1629,7 +1667,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
for r in ranges:
|
for r in ranges:
|
||||||
for row in range(r.topRow(), r.bottomRow() + 1):
|
for row in range(r.topRow(), r.bottomRow() + 1):
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
# #print(rows)
|
# #logger.debug(rows)
|
||||||
message = f"Sollen die {len(rows)} Medien wirklich gelöscht werden?"
|
message = f"Sollen die {len(rows)} Medien wirklich gelöscht werden?"
|
||||||
state = self.confirm_popup(message, title="Löschen?")
|
state = self.confirm_popup(message, title="Löschen?")
|
||||||
if state == 1:
|
if state == 1:
|
||||||
@@ -1649,12 +1687,12 @@ class Ui(Ui_Semesterapparat):
|
|||||||
# return data from dialog if ok is pressed
|
# return data from dialog if ok is pressed
|
||||||
if framework.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
if framework.result() == QtWidgets.QDialogger.DialogCode.Accepted:
|
||||||
data = framework.get_data()
|
data = framework.get_data()
|
||||||
# #print(data)
|
# #logger.debug(data)
|
||||||
# return data
|
# return data
|
||||||
selected_apparat_id = self.tableWidget_apparate.item(
|
selected_apparat_id = self.tableWidget_apparate.item(
|
||||||
self.tableWidget_apparate.currentRow(), 0
|
self.tableWidget_apparate.currentRow(), 0
|
||||||
).text()
|
).text()
|
||||||
# #print(selected_apparat_id)
|
# #logger.debug(selected_apparat_id)
|
||||||
|
|
||||||
self.db.setNewSemesterDate(
|
self.db.setNewSemesterDate(
|
||||||
selected_apparat_id, data["semester"], dauerapp=data["dauerapp"]
|
selected_apparat_id, data["semester"], dauerapp=data["dauerapp"]
|
||||||
@@ -1725,7 +1763,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
).text()
|
).text()
|
||||||
message = f"Soll der Apparat {selected_apparat_id} wirklich gelöscht werden?"
|
message = f"Soll der Apparat {selected_apparat_id} wirklich gelöscht werden?"
|
||||||
state = self.confirm_popup(message, title="Löschen?")
|
state = self.confirm_popup(message, title="Löschen?")
|
||||||
# #print(state)
|
# #logger.debug(state)
|
||||||
logger.info("Result state: {}", state)
|
logger.info("Result state: {}", state)
|
||||||
if state == 1:
|
if state == 1:
|
||||||
logger.debug("Deleting apparat {}", selected_apparat_id)
|
logger.debug("Deleting apparat {}", selected_apparat_id)
|
||||||
@@ -1737,7 +1775,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.apparats.remove(apparat)
|
self.apparats.remove(apparat)
|
||||||
break
|
break
|
||||||
self.old_apparats = self.apparats
|
self.old_apparats = self.apparats
|
||||||
# #print(self.apparats)
|
# #logger.debug(self.apparats)
|
||||||
# remove the row from the table
|
# remove the row from the table
|
||||||
self.tableWidget_apparate.removeRow(self.tableWidget_apparate.currentRow())
|
self.tableWidget_apparate.removeRow(self.tableWidget_apparate.currentRow())
|
||||||
# send mail to prof
|
# send mail to prof
|
||||||
@@ -1745,8 +1783,8 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
|
|
||||||
def launch_gui():
|
def launch_gui():
|
||||||
# #print("trying to login")
|
# #logger.debug("trying to login")
|
||||||
# #print("checking if database available")
|
# #logger.debug("checking if database available")
|
||||||
|
|
||||||
logger.info("Starting login dialog")
|
logger.info("Starting login dialog")
|
||||||
app = QtWidgets.QApplication(sys.argv)
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
@@ -1758,11 +1796,11 @@ def launch_gui():
|
|||||||
if ui.lresult == 1:
|
if ui.lresult == 1:
|
||||||
# if login is successful, open main window
|
# if login is successful, open main window
|
||||||
# show login dialog
|
# show login dialog
|
||||||
# #print(ui.lusername)
|
# #logger.debug(ui.lusername)
|
||||||
MainWindow = QtWidgets.QMainWindow()
|
MainWindow = QtWidgets.QMainWindow()
|
||||||
aui = Ui(MainWindow, username=ui.lusername)
|
aui = Ui(MainWindow, username=ui.lusername)
|
||||||
|
|
||||||
# #print(aui.active_user)
|
# #logger.debug(aui.active_user)
|
||||||
MainWindow.show()
|
MainWindow.show()
|
||||||
# atexit.register()
|
# atexit.register()
|
||||||
atexit.register(tempdelete)
|
atexit.register(tempdelete)
|
||||||
@@ -1779,7 +1817,7 @@ def launch_gui():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# #print("This is the main window")
|
# #logger.debug("This is the main window")
|
||||||
# app = QtWidgets.QApplication(sys.argv)
|
# app = QtWidgets.QApplication(sys.argv)
|
||||||
# window = MainWindow()
|
# window = MainWindow()
|
||||||
# app.exec()
|
# app.exec()
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
apparats.append(self.tableWidget.item(row.row(), 1).text())
|
apparats.append(self.tableWidget.item(row.row(), 1).text())
|
||||||
for apparat in apparats:
|
for apparat in apparats:
|
||||||
apparat_id = self.db.getApparatId(apparat)
|
apparat_id = self.db.getApparatId(apparat)
|
||||||
self.db.restoreApparat(apparat_id)
|
self.db.restoreApparat(apparat_id, apparat)
|
||||||
# remove the red color from the row
|
# remove the red color from the row
|
||||||
# get row where the apparat is
|
# get row where the apparat is
|
||||||
row = self.tableWidget.findItems(apparat, QtCore.Qt.MatchFlag.MatchExactly)[
|
row = self.tableWidget.findItems(apparat, QtCore.Qt.MatchFlag.MatchExactly)[
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
def create_blob(file):
|
def create_blob(file: str):
|
||||||
"""
|
"""
|
||||||
Creates a blob from a file.
|
Creates a blob from a file.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import pickle
|
import pickle
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def load_pickle(data):
|
def load_pickle(data: Any):
|
||||||
return pickle.loads(data)
|
return pickle.loads(data)
|
||||||
|
|
||||||
|
|
||||||
def dump_pickle(data):
|
def dump_pickle(data: Any):
|
||||||
return pickle.dumps(data)
|
return pickle.dumps(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user