remove comments, unneeded functions

This commit is contained in:
WorldTeacher
2024-06-13 10:04:04 +02:00
parent f2f3c2e8d3
commit 4280a05c7d

View File

@@ -2,10 +2,8 @@
import atexit import atexit
import os import os
# import re
import sys import sys
import tempfile import tempfile
import time
import webbrowser import webbrowser
from pathlib import Path from pathlib import Path
@@ -98,16 +96,11 @@ class Ui(Ui_Semesterapparat):
MainWindow.setWindowIcon(Icon("logo").icon) MainWindow.setWindowIcon(Icon("logo").icon)
self.db = Database() self.db = Database()
# self.show()
# self.setWindowTitle("Semesterapparatsmanagement")
# self.setWindowIcon(QIcon("ui\icon.png"))
# self.sem_sommer.clicked.connect(self.buttonClicked)
self.btn_add_document.clicked.connect(self.add_document) self.btn_add_document.clicked.connect(self.add_document)
self.check_file.clicked.connect( self.check_file.clicked.connect(
self.btn_check_file_threaded self.btn_check_file_threaded
) # default: self.add_media_from_file) ) # default: self.add_media_from_file
self.create_new_app.clicked.connect(self.btn_create_new_apparat) self.create_new_app.clicked.connect(self.btn_create_new_apparat)
# self.load_app.clicked.connect(self.btn_load_apparat)
self.btn_apparat_save.clicked.connect(self.btn_save_apparat) self.btn_apparat_save.clicked.connect(self.btn_save_apparat)
self.btn_apparat_apply.clicked.connect(self.update_apparat) self.btn_apparat_apply.clicked.connect(self.update_apparat)
self.btn_open_document.clicked.connect(self.open_document) self.btn_open_document.clicked.connect(self.open_document)
@@ -166,10 +159,6 @@ class Ui(Ui_Semesterapparat):
self.tableWidget_apparate.addScrollBarWidget( self.tableWidget_apparate.addScrollBarWidget(
QtWidgets.QScrollBar(), QtCore.Qt.AlignmentFlag.AlignRight QtWidgets.QScrollBar(), QtCore.Qt.AlignmentFlag.AlignRight
) )
# connect contextmenuevent to tablewidget
# enable automatic resizing of columns for book_search_result
self.tableWidget_apparate.doubleClicked.connect(self.load_app_data) self.tableWidget_apparate.doubleClicked.connect(self.load_app_data)
self.load_app.hide() self.load_app.hide()
print(f"user:{self.active_user}") print(f"user:{self.active_user}")
@@ -590,20 +579,11 @@ class Ui(Ui_Semesterapparat):
else self.edit_faculty_member_title.setText("") else self.edit_faculty_member_title.setText("")
) )
# self.edit_faculty_member_name.setText(f"{data[3]} {data[2]}")
# self.edit_faculty_member_title.setCurrentText(data[1])
# self.edit_faculty_member_mail.setText(data[4])
# self.edit_faculty_member_tel.setText(data[5])
# self.edit_faculty_member_adis_id.setText(str(data[0]))
# self.edit_faculty_member_id.setText(str(data[6]))
def add_user(self): def add_user(self):
username = self.user_create_frame_username.text() username = self.user_create_frame_username.text()
password = self.user_create_frame_password.text() password = self.user_create_frame_password.text()
role = self.user_frame_userrole.currentText() role = self.user_frame_userrole.currentText()
if self.db.checkUsername(username): if self.db.checkUsername(username):
# ic("username already exists")
# self.user_create_frame_error.setText("Der Nutzername ist bereits vergeben")#TODO: implement error message
return return
userdata = AdminCommands().create_password(password) userdata = AdminCommands().create_password(password)
self.db.createUser( self.db.createUser(
@@ -629,7 +609,6 @@ class Ui(Ui_Semesterapparat):
self.user_delete_err_message.setText( self.user_delete_err_message.setText(
"Bitte bestätigen Sie die Löschung des Nutzers" "Bitte bestätigen Sie die Löschung des Nutzers"
) # TODO: implement error message ) # TODO: implement error message
# ic("please confirm the deletion of the user")
def update_user_data(self): def update_user_data(self):
username = self.user_edit_frame_user_select.currentText() username = self.user_edit_frame_user_select.currentText()
@@ -805,7 +784,6 @@ class Ui(Ui_Semesterapparat):
def populate_frame(self, appdata: ApparatData): def populate_frame(self, appdata: ApparatData):
# populate the frame with the data from the database # populate the frame with the data from the database
# ic(appdata)
self.drpdwn_app_nr.setCurrentText(str(appdata.appnr)) self.drpdwn_app_nr.setCurrentText(str(appdata.appnr))
self.prof_title.setText(appdata.prof_title) self.prof_title.setText(appdata.prof_title)
prof_name = appdata.profname.split(" ") prof_name = appdata.profname.split(" ")
@@ -1007,20 +985,6 @@ class Ui(Ui_Semesterapparat):
def validate_fields(self): def validate_fields(self):
return all(valid_input) return all(valid_input)
# def req_fields_filled(self):
# # check if all required fields are filled
# values = []
# for item in self.app_group_box.findChildren(QtWidgets.QLabel):
# # if label name contains "req" and the text is empty, return false
# if "mand" in item.objectName() and item.text() == "":
# values.append(True)
# elif "mand" in item.objectName() and item.text() != "":
# values.append(False)
# return all(values)
#
def buttonClicked(self):
print("Button clicked")
def set_prof_data(self): def set_prof_data(self):
if "," not in self.drpdwn_prof_name.currentText(): if "," not in self.drpdwn_prof_name.currentText():
self.prof_mail.clear() self.prof_mail.clear()
@@ -1090,14 +1054,6 @@ class Ui(Ui_Semesterapparat):
self.dokument_list.setItem(0, 2, QtWidgets.QTableWidgetItem("")) self.dokument_list.setItem(0, 2, QtWidgets.QTableWidgetItem(""))
self.dokument_list.setItem(0, 3, QtWidgets.QTableWidgetItem("Database")) self.dokument_list.setItem(0, 3, QtWidgets.QTableWidgetItem("Database"))
# def btn_load_apparat(self):
# # remove all rows from table
# #get all
# self.tableWidget_apparate.sortItems(0, QtCore.Qt.SortOrder.AscendingOrder)
# self.app_group_box.setDisabled(True)
# for child in self.app_group_box.findChildren(QtWidgets.QLineEdit):
# child.clear()
def btn_create_new_apparat(self): def btn_create_new_apparat(self):
self.groupBox.show() self.groupBox.show()
self.groupBox_2.show() self.groupBox_2.show()
@@ -1131,8 +1087,6 @@ class Ui(Ui_Semesterapparat):
valid_input = (0, 0, 0, 0, 0, 0) valid_input = (0, 0, 0, 0, 0, 0)
self.populate_prof_dropdown() self.populate_prof_dropdown()
# self.horizontalLayout_6.show()
# increase size by 300px
def update_progress_label(self, curr, total): def update_progress_label(self, curr, total):
text = f"Medium {curr}/{total}" text = f"Medium {curr}/{total}"
@@ -1181,28 +1135,12 @@ class Ui(Ui_Semesterapparat):
self.bookGrabber = BookGrabber( self.bookGrabber = BookGrabber(
mode=mode, app_id=app_id, prof_id=prof_id, data=data mode=mode, app_id=app_id, prof_id=prof_id, data=data
) )
# grabber.mode = mode
# grabber.data = data
# grabber.app_id = app_id
# grabber.prof_id = prof_id
self.bookGrabber.finished.connect(self.bookGrabber.deleteLater) self.bookGrabber.finished.connect(self.bookGrabber.deleteLater)
self.bookGrabber.finished.connect(self.hide_progress_label) self.bookGrabber.finished.connect(self.hide_progress_label)
self.bookGrabber.finished.connect(self.update_app_media_list) self.bookGrabber.finished.connect(self.update_app_media_list)
self.bookGrabber.updateSignal.connect(self.update_progress_label) self.bookGrabber.updateSignal.connect(self.update_progress_label)
self.bookGrabber.start() self.bookGrabber.start()
# run grabber.deletelater
# for book in data:
# # self.progress_label.setText(f"Medium {ct}/{len(data)}")
# # update the progress label
# self.logger.log_info(f"trying to add BookData for Signature {book}")
# webdata = WebRequest().get_ppn(book).get_data()
# bd: BookData = BibTextTransformer(mode).get_data(webdata).return_data()
# bd.signature = book
# self.db.addBookToDatabase(bookdata=bd, app_id=app_id, prof_id=prof_id)
# get all media list books
else: else:
return return
@@ -1813,34 +1751,12 @@ class Ui(Ui_Semesterapparat):
# print(selected_date) # print(selected_date)
messages = self.db.getMessages(selected_date) messages = self.db.getMessages(selected_date)
if messages == []: if messages == []:
# self.message_frame.hide() if self.message_frame.isVisible() else None
return return
# print(messages)
# message_count = len(messages)
# self.spin_select_message.setMaximum(message_count)
# self.message_frame.show()
# self.label_total_day_messages.setText("/ " + str(message_count))
# # if there is only one message, disable the spinbox
# (
# self.spin_select_message.setEnabled(False)
# if message_count == 1
# else self.spin_select_message.setEnabled(True)
# )
# self.spin_select_message.setValue(1)
# # load the first message
# __update_message()
# # on valuechanged, update the message
# self.spin_select_message.valueChanged.connect(__update_message)
# self.btn_delete_message.clicked.connect(__delete_message)
dialog = CalendarEntry(messages=messages, date=selected_date) dialog = CalendarEntry(messages=messages, date=selected_date)
# append dialog to self.frame_2 # append dialog to self.frame_2
self.calendarlayout.addWidget(dialog) self.calendarlayout.addWidget(dialog)
dialog.repaintSignal.connect(lambda: self.calendarWidget.reload(selected_date)) dialog.repaintSignal.connect(lambda: self.calendarWidget.reload(selected_date))
# dialog.deleteSignal.connect(__delete_message)
# if selected_date is not None:
# dialog.repaintSignal.connect(
# lambda: self.calendarWidget.redraw(selected_date)
# )
def open_settings(self): def open_settings(self):
settings = Settings(self.active_user) settings = Settings(self.active_user)
@@ -1964,14 +1880,7 @@ class Ui(Ui_Semesterapparat):
self.tableWidget_apparate.currentRow(), 0 self.tableWidget_apparate.currentRow(), 0
).text() ).text()
print(selected_apparat_id) print(selected_apparat_id)
# update self.apparats with the new data
# find matching apparat
# for apparat in self.apparats:
# if apparat[4] == int(selected_apparat_id):
# apparat[5]=data["semester"]
# apparat[7]=data["dauerapp"]
# break
# self.old_apparats = self.apparats
self.db.setNewSemesterDate( self.db.setNewSemesterDate(
selected_apparat_id, data["semester"], dauerapp=data["dauerapp"] selected_apparat_id, data["semester"], dauerapp=data["dauerapp"]
) )
@@ -2035,12 +1944,7 @@ class Ui(Ui_Semesterapparat):
def launch_gui(): def launch_gui():
print("trying to login") print("trying to login")
print("checking if database available") print("checking if database available")
# database = config.database.path + config.database.name
# print(database)
# if not os.path.exists(database):
# print("Database not found, creating new database")
# db = Database()
# db.create_database()
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
login_dialog = QtWidgets.QDialog() login_dialog = QtWidgets.QDialog()
ui = login_ui() ui = login_ui()