sort profs, add check to enable check_file only if all fields are set correctly

This commit is contained in:
WorldTeacher
2024-10-10 14:40:02 +02:00
parent ff8e6a1e58
commit 8b5c355bf1
2 changed files with 17 additions and 8 deletions

View File

@@ -66,7 +66,6 @@ class ElsaAddEntry(QtWidgets.QDialog, Ui_Dialog):
def copy_to_clipboard(self, field):
clipboard = QtWidgets.QApplication.clipboard()
# fields are textedits
clipboard.setText(field.toPlainText())
def discard(self):
for line in self.findChildren(QtWidgets.QLineEdit):
@@ -167,17 +166,19 @@ class ElsaAddEntry(QtWidgets.QDialog, Ui_Dialog):
param = self.searchIdent.text()
web = WebRequest()
web.get_ppn(param)
data = web.get_data()
data = web.get_data_elsa()
# if isinstance(data, list):
# data = data[0]
bib = BibTextTransformer("ARRAY")
bib.get_data(data)
data = bib.return_data()
print(data)
self.setdata(data)
def setdata(self, data):
# use field to set data in the correct fields
fields = self.findChildren(QtWidgets.QLineEdit)
self.source_pages = data.pages
# remove all fields from the list if they do not start with the mode and _
fields = [field for field in fields if field.objectName().startswith(self.mode)]
for field in fields:

View File

@@ -2,11 +2,12 @@
import atexit
import os
import subprocess
import sys
import tempfile
import time
import webbrowser
from pathlib import Path
import threading
from icecream import ic
from natsort import natsorted
@@ -54,7 +55,6 @@ from src.ui import (
UserCreate,
EditUser,
EditProf
)
config = OmegaConf.load("config.yaml")
@@ -237,7 +237,12 @@ class Ui(Ui_Semesterapparat):
self.elsatab.setLayout(QtWidgets.QVBoxLayout())
self.search_statistics.setLayout(QtWidgets.QVBoxLayout())
#once inputSignal emits, check state
def checkValidInput(self):
if valid_input == (1, 1, 1, 1, 1, 1):
self.check_file.setEnabled(True)
else:
self.check_file.setEnabled(False)
def setWidget(self, widget):
#remove all widgets from localwidget
@@ -542,7 +547,7 @@ class Ui(Ui_Semesterapparat):
valid_input = list(valid_input)
valid_input[index] = state
valid_input = tuple(valid_input)
self.checkValidInput()
def set_state(self):
# set state of semester and year
@@ -559,6 +564,7 @@ class Ui(Ui_Semesterapparat):
return all(valid_input)
def set_prof_data(self):
self.prof_title.clear()
if "," not in self.drpdwn_prof_name.currentText():
self.prof_mail.clear()
self.prof_tel_nr.clear()
@@ -648,7 +654,7 @@ class Ui(Ui_Semesterapparat):
self.drpdwn_app_nr.setEnabled(True)
self.app_fach.setEnabled(True)
self.check_send_mail.show()
self.check_file.setEnabled(False)
if self.tableWidget_apparat_media.rowCount() > 0:
self.tableWidget_apparat_media.setRowCount(0)
# clear all fields
@@ -908,8 +914,10 @@ class Ui(Ui_Semesterapparat):
profs = self.db.getProfs()
# add empty entry to dropdown and set it as current
self.drpdwn_prof_name.addItem("Kein Name")
profs = [f"{prof.lastname}, {prof.firstname}" for prof in profs]
profs.sort()
for prof in profs:
self.drpdwn_prof_name.addItem(f"{prof.lastname}, {prof.firstname}")
self.drpdwn_prof_name.addItem(prof)
def add_document(self):
# print("Add document")