rest of files, not sorted
This commit is contained in:
@@ -16,8 +16,6 @@ from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from PyQt6.QtCore import QDate, QThread
|
||||
from PyQt6.QtGui import QColor, QRegularExpressionValidator
|
||||
|
||||
# from src.logic.webrequest import BibTextTransformer, WebRequest
|
||||
# from src.utils import documentationview
|
||||
from src.backend.admin_console import AdminCommands
|
||||
from src.backend.create_file import recreateFile
|
||||
from src.backend.database import Database
|
||||
@@ -29,7 +27,7 @@ from src.logic.csvparser import csv_to_list
|
||||
from src.logic.dataclass import ApparatData, BookData
|
||||
from src.logic.log import MyLogger
|
||||
from src.logic.wordparser import word_docx_to_csv
|
||||
from src.ui import ( # Mail_Dialog,
|
||||
from src.ui import (
|
||||
App_Ext_Dialog,
|
||||
FilePicker,
|
||||
GraphWidget,
|
||||
@@ -63,7 +61,6 @@ class Medien(medienadder_ui):
|
||||
return self.comboBox.currentText()
|
||||
|
||||
|
||||
|
||||
class MyComboBox(QtWidgets.QComboBox):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
@@ -184,18 +181,7 @@ class Ui(Ui_Semesterapparat):
|
||||
QtWidgets.QScrollBar(), QtCore.Qt.AlignmentFlag.AlignRight
|
||||
)
|
||||
# connect contextmenuevent to tablewidget
|
||||
self.tableWidget_apparate.setContextMenuPolicy(
|
||||
QtCore.Qt.ContextMenuPolicy.CustomContextMenu
|
||||
)
|
||||
self.tableWidget_apparate.customContextMenuRequested.connect(
|
||||
self.open_context_menu
|
||||
)
|
||||
self.tableWidget_apparat_media.setContextMenuPolicy(
|
||||
QtCore.Qt.ContextMenuPolicy.CustomContextMenu
|
||||
)
|
||||
self.tableWidget_apparat_media.customContextMenuRequested.connect(
|
||||
self.media_context_menu
|
||||
)
|
||||
|
||||
# enable automatic resizing of columns for book_search_result
|
||||
self.book_search_result.horizontalHeader().setSectionResizeMode(
|
||||
QtWidgets.QHeaderView.ResizeMode.Stretch
|
||||
@@ -235,6 +221,9 @@ class Ui(Ui_Semesterapparat):
|
||||
self.label_20.hide()
|
||||
self.line_3.hide()
|
||||
self.avail_status.hide()
|
||||
self.chkbx_show_del_media.hide()
|
||||
self.groupBox_2.hide()
|
||||
self.groupBox.hide()
|
||||
self.check_deletable.stateChanged.connect(self.gridchange)
|
||||
self.tableWidget.horizontalHeader().setSectionResizeMode(
|
||||
QtWidgets.QHeaderView.ResizeMode.Stretch
|
||||
@@ -247,6 +236,9 @@ class Ui(Ui_Semesterapparat):
|
||||
self.tableWidget.resizeColumnsToContents()
|
||||
self.tableWidget.resizeRowsToContents()
|
||||
# set self.app_fach viable inputs to be
|
||||
# self.app_fach.addItems([subject[1] for subject in self.db.getSubjects()])
|
||||
# self.app_fach.addItem("")
|
||||
# self.app_fach.setCurrentText("")
|
||||
|
||||
# create a thread, that continually checks the validity of the inputs
|
||||
|
||||
@@ -269,10 +261,6 @@ class Ui(Ui_Semesterapparat):
|
||||
# self.thread_check()
|
||||
|
||||
### Admin interface ###
|
||||
#!admin - create user
|
||||
#!admin - delete user
|
||||
#!admin - change user
|
||||
# TODO:admin - change faculty
|
||||
self.select_action_box.addItem("")
|
||||
self.select_action_box.setCurrentText("")
|
||||
self.hide_all()
|
||||
@@ -282,7 +270,22 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
self.book_search.clicked.connect(self.search_book)
|
||||
|
||||
# enable click functionality for the combobox to allow selection of roles
|
||||
# Context Menus
|
||||
self.tableWidget_apparate.setContextMenuPolicy(
|
||||
QtCore.Qt.ContextMenuPolicy.CustomContextMenu
|
||||
)
|
||||
self.tableWidget_apparat_media.setContextMenuPolicy(
|
||||
QtCore.Qt.ContextMenuPolicy.CustomContextMenu
|
||||
)
|
||||
self.tableWidget_apparate.customContextMenuRequested.connect(
|
||||
self.open_context_menu
|
||||
)
|
||||
self.tableWidget_apparat_media.customContextMenuRequested.connect(
|
||||
self.media_context_menu
|
||||
)
|
||||
self.tableWidget.customContextMenuRequested.connect(
|
||||
self.statistics_table_context_menu
|
||||
)
|
||||
|
||||
# admin buttons
|
||||
self.user_frame_addUser.clicked.connect(self.add_user)
|
||||
@@ -290,6 +293,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.update_user.clicked.connect(self.update_user_data)
|
||||
self.update_faculty_member.clicked.connect(self.edit_faculty_member_action)
|
||||
|
||||
# Create instances to be used by the threads in the application
|
||||
self.bookGrabber = None
|
||||
self.availChecker = None
|
||||
self.mail_thread = None
|
||||
@@ -322,7 +326,7 @@ class Ui(Ui_Semesterapparat):
|
||||
"title": title if title != "" else None,
|
||||
}
|
||||
params = {key: value for key, value in params.items() if value is not None}
|
||||
#ic(params)
|
||||
# ic(params)
|
||||
retdata = self.db.searchBook(params)
|
||||
if retdata is None:
|
||||
return
|
||||
@@ -378,7 +382,7 @@ class Ui(Ui_Semesterapparat):
|
||||
password = self.user_create_frame_password.text()
|
||||
role = self.user_frame_userrole.currentText()
|
||||
if self.db.checkUsername(username):
|
||||
#ic("username already exists")
|
||||
# ic("username already exists")
|
||||
# self.user_create_frame_error.setText("Der Nutzername ist bereits vergeben")#TODO: implement error message
|
||||
return
|
||||
userdata = AdminCommands().create_password(password)
|
||||
@@ -402,8 +406,10 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
self.user_delete_confirm.setChecked(False)
|
||||
else:
|
||||
self.user_delete_err_message.setText("Bitte bestätigen Sie die Löschung des Nutzers") # TODO: implement error message
|
||||
#ic("please confirm the deletion of the user")
|
||||
self.user_delete_err_message.setText(
|
||||
"Bitte bestätigen Sie die Löschung des Nutzers"
|
||||
) # TODO: implement error message
|
||||
# ic("please confirm the deletion of the user")
|
||||
|
||||
def update_user_data(self):
|
||||
username = self.user_edit_frame_user_select.currentText()
|
||||
@@ -752,15 +758,21 @@ class Ui(Ui_Semesterapparat):
|
||||
def delete_selected_apparats(self):
|
||||
# get all selected apparats
|
||||
selected_apparats = []
|
||||
selected_apparat_rows = []
|
||||
for i in range(self.tableWidget.rowCount()):
|
||||
if self.tableWidget.cellWidget(i, 0).isChecked():
|
||||
selected_apparats.append(self.tableWidget.item(i, 2).text())
|
||||
selected_apparat_rows.append(i)
|
||||
# delete all selected apparats
|
||||
print(selected_apparats)
|
||||
for apparat in selected_apparats:
|
||||
self.db.deleteApparat(apparat, self.generateSemester(today=True))
|
||||
for row in selected_apparat_rows:
|
||||
# set the background of the row to red
|
||||
for j in range(5):
|
||||
self.tableWidget.item(row, j).setBackground(QtGui.QColor(235, 74, 71))
|
||||
# refresh the table
|
||||
self.tab_changed()
|
||||
self.populate_tab()
|
||||
self.btn_del_select_apparats.setEnabled(False)
|
||||
|
||||
def statistics(self):
|
||||
@@ -842,7 +854,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
def populate_frame(self, appdata: ApparatData):
|
||||
# populate the frame with the data from the database
|
||||
#ic(appdata)
|
||||
# ic(appdata)
|
||||
self.drpdwn_app_nr.setCurrentText(str(appdata.appnr))
|
||||
self.prof_title.setText(appdata.prof_title)
|
||||
prof_name = appdata.profname.split(" ")
|
||||
@@ -912,6 +924,8 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
self.update_app_media_list()
|
||||
self.cancel_active_selection.click()
|
||||
self.check_send_mail.show()
|
||||
self.chkbx_show_del_media.show()
|
||||
|
||||
def confirm_popup(self, message: str):
|
||||
dial = QtWidgets.QDialog()
|
||||
@@ -1052,7 +1066,7 @@ class Ui(Ui_Semesterapparat):
|
||||
return
|
||||
selected_prof = self.drpdwn_prof_name.currentText()
|
||||
data = self.db.getProfData(selected_prof)
|
||||
#ic(data)
|
||||
# ic(data)
|
||||
prof_title = data[2]
|
||||
if prof_title == "None":
|
||||
prof_title = "Kein Titel"
|
||||
@@ -1071,12 +1085,13 @@ class Ui(Ui_Semesterapparat):
|
||||
return None
|
||||
|
||||
def load_app_data(self, app_id=None):
|
||||
print(type(app_id))
|
||||
|
||||
if isinstance(app_id, str):
|
||||
# double click the tableWidget_apparate row with the given app_id
|
||||
row, column = self.get_index_of_value(self.tableWidget_apparate, app_id)
|
||||
# set the current index to the row
|
||||
self.tableWidget_apparate.setCurrentCell(row, 0)
|
||||
self.check_send_mail.hide()
|
||||
app_pos = self.tableWidget_apparate.currentIndex()
|
||||
appnr = self.tableWidget_apparate.item(app_pos.row(), 0).text()
|
||||
appname = self.tableWidget_apparate.item(app_pos.row(), 1).text()
|
||||
@@ -1089,6 +1104,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.populate_frame(appdata)
|
||||
self.btn_apparat_save.hide()
|
||||
self.btn_reserve.show()
|
||||
self.chkbx_show_del_media.show()
|
||||
self.drpdwn_app_nr.setDisabled(True)
|
||||
self.update_app_media_list()
|
||||
self.update_documemt_list()
|
||||
@@ -1128,9 +1144,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.chkbx_show_del_media.setEnabled(True)
|
||||
self.drpdwn_app_nr.setEnabled(True)
|
||||
self.app_fach.setEnabled(True)
|
||||
self.app_fach.addItems([subject[1] for subject in self.db.getSubjects()])
|
||||
self.app_fach.addItem("")
|
||||
self.app_fach.setCurrentText("")
|
||||
|
||||
if self.tableWidget_apparat_media.rowCount() > 0:
|
||||
self.tableWidget_apparat_media.setRowCount(0)
|
||||
# clear all fields
|
||||
@@ -1281,6 +1295,9 @@ class Ui(Ui_Semesterapparat):
|
||||
self.dokument_list.setRowCount(0)
|
||||
self.frame.setEnabled(False)
|
||||
self.app_fach.setCurrentText("")
|
||||
self.chkbx_show_del_media.hide()
|
||||
self.check_send_mail.hide()
|
||||
self.btn_reserve.hide()
|
||||
for child in self.frame.findChildren(QtWidgets.QLineEdit):
|
||||
child.clear()
|
||||
|
||||
@@ -1297,7 +1314,7 @@ class Ui(Ui_Semesterapparat):
|
||||
# booklist:list[BookData]=[book[0] for book in books]
|
||||
self.tableWidget_apparat_media.setRowCount(0)
|
||||
for book in books:
|
||||
book_id = book["id"]
|
||||
book["id"]
|
||||
book_data = book["bookdata"]
|
||||
availability = book["available"]
|
||||
# bd = BookData().from_string(book)
|
||||
@@ -1587,7 +1604,7 @@ class Ui(Ui_Semesterapparat):
|
||||
]
|
||||
|
||||
signatures = [i for i in signatures if i != ""]
|
||||
#ic(signatures)
|
||||
# ic(signatures)
|
||||
print("starting thread")
|
||||
self.autoGrabber = BookGrabber(
|
||||
mode="ARRAY", app_id=app_id, prof_id=prof_id, data=signatures
|
||||
@@ -1638,6 +1655,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.drpdwn_prof_name.clear()
|
||||
self.tableWidget_apparat_media.setRowCount(0)
|
||||
self.frame.setEnabled(False)
|
||||
self.check_send_mail.setChecked(False)
|
||||
|
||||
if not self.validate_fields():
|
||||
self.confirm_popup("Bitte alle Pflichtfelder ausfüllen!")
|
||||
@@ -1718,7 +1736,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.old_apparats = self.apparats
|
||||
|
||||
def insert_apparat_into_table(self, apparat):
|
||||
#ic(apparat)
|
||||
# ic(apparat)
|
||||
|
||||
def __dauer_check(apparat):
|
||||
return "Ja" if apparat[7] == 1 else "Nein"
|
||||
@@ -1741,7 +1759,7 @@ class Ui(Ui_Semesterapparat):
|
||||
0,
|
||||
3,
|
||||
QtWidgets.QTableWidgetItem(
|
||||
str(apparat[8]) if apparat[8] != None else apparat[5]
|
||||
str(apparat[8]) if apparat[8] is not None else apparat[5]
|
||||
),
|
||||
)
|
||||
self.tableWidget_apparate.setItem(
|
||||
@@ -1766,6 +1784,23 @@ class Ui(Ui_Semesterapparat):
|
||||
remind_action.triggered.connect(self.reminder)
|
||||
menu.exec(self.tableWidget_apparate.mapToGlobal(position))
|
||||
|
||||
def statistics_table_context_menu(self, position):
|
||||
menu = QtWidgets.QMenu()
|
||||
restore_action = menu.addAction("Wiederherstellen")
|
||||
menu.addAction(restore_action)
|
||||
restore_action.triggered.connect(self.restore_apparat)
|
||||
menu.exec(self.tableWidget.mapToGlobal(position))
|
||||
|
||||
def restore_apparat(self):
|
||||
row = self.tableWidget.currentRow()
|
||||
apparat = self.tableWidget.item(row, 1).text()
|
||||
ic(apparat)
|
||||
apparat_id = self.db.getApparatId(apparat)
|
||||
# restore the apparat
|
||||
self.db.restoreApparat(apparat_id)
|
||||
# update the table
|
||||
self.reload()
|
||||
|
||||
def reminder(self):
|
||||
self.logger.log_info("Opening reminder dialog")
|
||||
dialog = QtWidgets.QDialog()
|
||||
@@ -1850,7 +1885,7 @@ class Ui(Ui_Semesterapparat):
|
||||
print(data)
|
||||
OmegaConf.save(data, "config.yaml")
|
||||
# re-load the config
|
||||
config = OmegaConf.load("config.yaml")
|
||||
OmegaConf.load("config.yaml")
|
||||
self.logger.log_info("Saved settings to config.yaml")
|
||||
self.reload()
|
||||
|
||||
@@ -2080,43 +2115,3 @@ if __name__ == "__main__":
|
||||
# app.exec()
|
||||
# open login screen
|
||||
launch_gui()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user