format code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# LibrarySystem
|
||||
|
||||
universal library system for facilities in the university. Currently hard-coded for the Library of the University of Education in Freiburg, Germany.
|
||||
universal library system for facilities in the university. Currently hard-coded for the Library of the University of Education in Freiburg, Germany, but can be adapted to fit other libraries as long as the catalogue has a suitable format, or an open API
|
||||
|
||||
Other Libraries can be supported by rewriting the catalog and it's corresponding functions.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "librarysystem"
|
||||
version = "0.2.3"
|
||||
description = "Add your description here"
|
||||
description = "A library system for loaning books and managing the users."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
@@ -23,4 +23,17 @@ dev = [
|
||||
"bump-my-version>=0.29.0",
|
||||
"icecream>=2.1.4",
|
||||
"nuitka>=2.5.9",
|
||||
"ruff>=0.9.2",
|
||||
]
|
||||
[tool.ruff]
|
||||
exclude = [
|
||||
"dist",
|
||||
".git",
|
||||
".vscode",
|
||||
|
||||
]
|
||||
indent-width = 4
|
||||
include = ["pyproject.toml", "src/**/*.py", "scripts/**/*.py","tests/**/*.py"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
fixable = ["ALL"]
|
||||
@@ -4,6 +4,7 @@ from loguru import logger
|
||||
from datetime import datetime
|
||||
import atexit
|
||||
import argparse
|
||||
|
||||
__version__ = "0.2.5"
|
||||
__author__ = "Alexander Kirchner"
|
||||
__email__ = "alexander.kirchner@ph-freiburg.de"
|
||||
@@ -66,9 +67,10 @@ if config.debug:
|
||||
|
||||
def restore_config():
|
||||
log.debug("Restoring configuration")
|
||||
print("Changes made: ", changes_made)
|
||||
|
||||
if not changes_made:
|
||||
return
|
||||
values = config.get_changes(_config)
|
||||
config._config = _config
|
||||
config.save()
|
||||
log.info("Restored configuration, changed values: {config.get_changes(_config)}")
|
||||
log.debug(f"Restored configuration, changed values: {values}")
|
||||
|
||||
@@ -2,6 +2,7 @@ import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from src import config, log
|
||||
from src.schemas import Book
|
||||
|
||||
URL = "https://rds.ibs-bw.de/phfreiburg/opac/RDSIndex/Search?type0%5B%5D=allfields&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=au&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=ti&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=ct&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=isn&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=ta&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=co&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=py&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=pp&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=pu&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=si&lookfor0%5B%5D={}&join=AND&bool0%5B%5D=AND&type0%5B%5D=zr&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND&type0%5B%5D=cc&lookfor0%5B%5D=&join=AND&bool0%5B%5D=AND"
|
||||
BASE = "https://rds.ibs-bw.de"
|
||||
|
||||
@@ -22,6 +23,7 @@ class Catalogue:
|
||||
return True
|
||||
except requests.exceptions.RequestException as e:
|
||||
log.error(f"Could not connect to google.com: {e}")
|
||||
|
||||
def search_book(self, searchterm: str):
|
||||
response = requests.get(URL.format(searchterm), timeout=self.timeout)
|
||||
return response.text
|
||||
|
||||
@@ -7,16 +7,20 @@ from src.utils import stringToDate
|
||||
from PyQt6 import QtCore
|
||||
|
||||
FILE = config.database.name
|
||||
|
||||
|
||||
class Database:
|
||||
def __init__(self, db_path: str = None):
|
||||
'''
|
||||
"""
|
||||
Default constructor for the database class
|
||||
|
||||
Args:
|
||||
db_path (str, optional): Optional Path for testing / specific purposes. Defaults to None.
|
||||
'''
|
||||
"""
|
||||
if db_path is None:
|
||||
self.db_path = self.handle_folder_reachability(config.database.path, config.database.backupLocation)
|
||||
self.db_path = self.handle_folder_reachability(
|
||||
config.database.path, config.database.backupLocation
|
||||
)
|
||||
else:
|
||||
self.db_path = db_path
|
||||
|
||||
@@ -28,7 +32,7 @@ class Database:
|
||||
if not os.path.exists(config.database.backupLocation):
|
||||
os.makedirs(config.database.backupLocation)
|
||||
|
||||
#if main path does not exist, try to create it. if that fails, use the backuplocation
|
||||
# if main path does not exist, try to create it. if that fails, use the backuplocation
|
||||
log.debug("Checking Database Path {}", self.db_path)
|
||||
self.checkDatabaseStatus()
|
||||
|
||||
@@ -48,50 +52,59 @@ class Database:
|
||||
backup_file = os.path.join(backup_path, ".backup")
|
||||
|
||||
if not os.path.exists(original_path):
|
||||
#original folder not reachable, use backup path and create .backup file
|
||||
# original folder not reachable, use backup path and create .backup file
|
||||
if not os.path.exists(backup_path):
|
||||
os.makedirs(backup_path)
|
||||
with open(backup_file, "w") as f:
|
||||
f.write("")
|
||||
|
||||
# Create an empty backup file as a marker
|
||||
return backup_path +"/" + FILE
|
||||
return backup_path + "/" + FILE
|
||||
|
||||
else:
|
||||
log.info("Original Path Exists, using this path")
|
||||
# Original folder is reachable, check for backup
|
||||
if os.path.exists(backup_file):
|
||||
# Restore backup
|
||||
shutil.rmtree(original_path) # Remove original folder to avoid conflicts
|
||||
shutil.rmtree(
|
||||
original_path
|
||||
) # Remove original folder to avoid conflicts
|
||||
os.rename(backup_path, original_path)
|
||||
# (backup_path, original_path)
|
||||
#os.remove(backup_file)
|
||||
#remove backup file from original path
|
||||
# os.remove(backup_file)
|
||||
# remove backup file from original path
|
||||
os.remove(original_path + "/.backup")
|
||||
os.makedirs(backup_path)
|
||||
return original_path +"/" + FILE
|
||||
return original_path + "/" + FILE
|
||||
|
||||
def checkDatabasePath(self):
|
||||
self.db_path = config.database.path + "/" + config.database.name
|
||||
#if backup file in backup location, move database to main location, delete backup file
|
||||
# if backup file in backup location, move database to main location, delete backup file
|
||||
if os.path.exists(config.database.backupLocation + "/backup"):
|
||||
if os.path.exists(self.db_path):
|
||||
os.remove(self.db_path)
|
||||
os.rename(f"{config.database.backupLocation}/{config.database.name}", self.db_path)
|
||||
#remove backup file
|
||||
os.rename(
|
||||
f"{config.database.backupLocation}/{config.database.name}",
|
||||
self.db_path,
|
||||
)
|
||||
# remove backup file
|
||||
os.remove(config.database.backupLocation + "/backup")
|
||||
return self.db_path
|
||||
else:
|
||||
#keep using backup file
|
||||
self.db_path = config.database.backupLocation + "/" + config.database.name
|
||||
# keep using backup file
|
||||
self.db_path = (
|
||||
config.database.backupLocation + "/" + config.database.name
|
||||
)
|
||||
if not os.path.exists(config.database.path):
|
||||
try:
|
||||
os.makedirs(config.database.path)
|
||||
except:
|
||||
self.db_path = config.database.backupLocation + "/" + config.database.name
|
||||
self.db_path = (
|
||||
config.database.backupLocation + "/" + config.database.name
|
||||
)
|
||||
if not os.path.exists(config.database.backupLocation):
|
||||
os.makedirs(config.database.backupLocation)
|
||||
#create a backup file in the backup location
|
||||
# create a backup file in the backup location
|
||||
with open(f"{config.database.backupLocation}/backup.txt", "w") as f:
|
||||
f.write("Backup File")
|
||||
return self.db_path
|
||||
@@ -104,27 +117,27 @@ class Database:
|
||||
# self.insertSubjects()
|
||||
|
||||
def connect(self) -> sql.Connection:
|
||||
'''
|
||||
"""
|
||||
Connect to the database
|
||||
|
||||
Returns:
|
||||
sql.Connection: The active connection to the database
|
||||
'''
|
||||
"""
|
||||
return sql.connect(self.db_path)
|
||||
|
||||
def close_connection(self, conn: sql.Connection):
|
||||
'''
|
||||
"""
|
||||
closes the connection to the database
|
||||
|
||||
Args:
|
||||
----
|
||||
- conn (sql.Connection): the connection to be closed
|
||||
'''
|
||||
"""
|
||||
conn.close()
|
||||
|
||||
def createDatabase(self):
|
||||
log.info("Creating Database")
|
||||
#print("Creating Database")
|
||||
# print("Creating Database")
|
||||
if not os.path.exists(self.db_path):
|
||||
os.makedirs(self.db_path)
|
||||
conn = self.connect()
|
||||
@@ -149,12 +162,12 @@ class Database:
|
||||
|
||||
def tableCheck(self):
|
||||
# check if database has tables
|
||||
'''
|
||||
"""
|
||||
Get the contents of the
|
||||
|
||||
Returns:
|
||||
Union[List[Tuple], None]: Returns a list of tuples containing the table names or None if no tables are present
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
with sql.connect(self.db_path) as conn:
|
||||
cursor = conn.cursor()
|
||||
@@ -170,6 +183,7 @@ class Database:
|
||||
result = cursor.fetchall()
|
||||
self.close_connection(conn)
|
||||
return result
|
||||
|
||||
def checkUserExists(self, key, value) -> list[User] | bool:
|
||||
query = f"SELECT * FROM users WHERE {key} like '%{value}%'"
|
||||
conn = self.connect()
|
||||
@@ -181,7 +195,9 @@ class Database:
|
||||
|
||||
users = cursor.fetchall()
|
||||
for index, user in enumerate(users):
|
||||
users[index] = User(userid=user[1], username=user[2], email=user[3], id=user[0])
|
||||
users[index] = User(
|
||||
userid=user[1], username=user[2], email=user[3], id=user[0]
|
||||
)
|
||||
self.close_connection(conn)
|
||||
return users
|
||||
|
||||
@@ -209,7 +225,6 @@ class Database:
|
||||
return user
|
||||
|
||||
def getUser(self, user_id) -> User:
|
||||
|
||||
conn = self.connect()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(f"SELECT * FROM users")
|
||||
@@ -230,7 +245,7 @@ class Database:
|
||||
log.info(f"Returning User {user}")
|
||||
return user
|
||||
raise ValueError(f"User {user_id} not found")
|
||||
#return User(userid="gelöscht", username="gelöscht", email="gelöscht", id="gelöscht")
|
||||
# return User(userid="gelöscht", username="gelöscht", email="gelöscht", id="gelöscht")
|
||||
# user = User(userid=result[1], username=result[2], email=result[3],id = result[0])
|
||||
# return user
|
||||
|
||||
@@ -240,7 +255,7 @@ class Database:
|
||||
cursor.execute(f"SELECT * FROM users WHERE username = '{username}'")
|
||||
result = cursor.fetchone()
|
||||
self.close_connection(conn)
|
||||
user = User(userid=result[1], username=result[2], email=result[3],id = result[0])
|
||||
user = User(userid=result[1], username=result[2], email=result[3], id=result[0])
|
||||
log.info(f"Returning User {user}")
|
||||
return user
|
||||
|
||||
@@ -254,7 +269,7 @@ class Database:
|
||||
conn.commit()
|
||||
self.close_connection(conn)
|
||||
|
||||
def setUserActiveDate(self, userid,date):
|
||||
def setUserActiveDate(self, userid, date):
|
||||
query = f"UPDATE users SET lastActive = '{date}' WHERE user_id = '{userid}'"
|
||||
conn = self.connect()
|
||||
cursor = conn.cursor()
|
||||
@@ -263,7 +278,11 @@ class Database:
|
||||
log.debug(f"Setting User {userid} to active on {date}")
|
||||
|
||||
def renameInactiveUsers(self):
|
||||
lastYear = QtCore.QDate.currentDate().addDays(int(f"-{config.delete_inactive_user_duration}")).toString("yyyy-MM-dd")
|
||||
lastYear = (
|
||||
QtCore.QDate.currentDate()
|
||||
.addDays(int(f"-{config.delete_inactive_user_duration}"))
|
||||
.toString("yyyy-MM-dd")
|
||||
)
|
||||
query = f"SELECT id FROM users WHERE lastActive < '{lastYear}'"
|
||||
conn = self.connect()
|
||||
cursor = conn.cursor()
|
||||
@@ -276,7 +295,7 @@ class Database:
|
||||
if not hasLoans:
|
||||
self.deleteUser(user)
|
||||
|
||||
def hasLoans(self, userid)->bool:
|
||||
def hasLoans(self, userid) -> bool:
|
||||
query = f"SELECT * FROM loans WHERE user_id = '{userid}' AND returned = 0"
|
||||
conn = self.connect()
|
||||
cursor = conn.cursor()
|
||||
@@ -289,7 +308,9 @@ class Database:
|
||||
log.debug(f"Deleting User {userid}")
|
||||
conn = self.connect()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(f"UPDATE users SET username='gelöscht', usermail = 'gelöscht', user_id='gelöscht' WHERE id = '{userid}'")
|
||||
cursor.execute(
|
||||
f"UPDATE users SET username='gelöscht', usermail = 'gelöscht', user_id='gelöscht' WHERE id = '{userid}'"
|
||||
)
|
||||
conn.commit()
|
||||
self.close_connection(conn)
|
||||
|
||||
@@ -313,6 +334,7 @@ class Database:
|
||||
result = self.query(query)
|
||||
|
||||
return [res[0] for res in result]
|
||||
|
||||
def getAllLoans(self):
|
||||
loan_data = []
|
||||
query = "SELECT * FROM loans"
|
||||
@@ -334,6 +356,7 @@ class Database:
|
||||
)
|
||||
loan_data.append(l)
|
||||
return loan_data
|
||||
|
||||
def insertLoan(self, userid, mediaid, loandate, duedate):
|
||||
log.debug(f"Inserting Loan {userid}, {mediaid}, {loandate}, {duedate}")
|
||||
query = f"INSERT INTO loans (user_id, media_id, loan_date, return_date) Values ('{userid}', '{mediaid}', '{loandate}', '{duedate}')"
|
||||
@@ -359,6 +382,7 @@ class Database:
|
||||
def getLoansBy(self, field, value):
|
||||
# query all loans, sort by date descending and return
|
||||
pass
|
||||
|
||||
def getMediaSimilarSignatureByID(self, media_id) -> list[Book]:
|
||||
log.info(f"Getting Media Similar to {media_id}")
|
||||
query = f"SELECT * FROM media WHERE id = '{media_id}'"
|
||||
@@ -367,7 +391,7 @@ class Database:
|
||||
cursor.execute(query)
|
||||
result = cursor.fetchone()
|
||||
signature = result[1]
|
||||
#print(signature)
|
||||
# print(signature)
|
||||
query = f"SELECT * FROM media WHERE signature LIKE '%{signature}%'"
|
||||
cursor.execute(query)
|
||||
result = cursor.fetchall()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from PyQt6.QtCore import QThread, pyqtSignal
|
||||
from src.utils import launch_documentation
|
||||
|
||||
|
||||
class DocumentationThread(QThread):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import requests
|
||||
|
||||
URL = "https://sru.k10plus.de/opac-de-627!rec=1?version=1.1&operation=searchRetrieve&query="
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ username TEXT NOT NULL,
|
||||
usermail TEXT NOT NULL,
|
||||
lastActive TEXT);
|
||||
""" # id == matrikelnr,
|
||||
#matrikelnr TEXT NOT NULL,
|
||||
# matrikelnr TEXT NOT NULL,
|
||||
MEDIA = """CREATE TABLE IF NOT EXISTS media (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
signature TEXT NOT NULL,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass
|
||||
class User:
|
||||
username: str
|
||||
userid: Any
|
||||
email: str
|
||||
id : int = None
|
||||
id: int = None
|
||||
|
||||
def __repr__(self):
|
||||
return f"Name: {self.username}\nMatrikelnr.: {self.userid}\neMail: {self.email}"
|
||||
|
||||
@@ -5,6 +5,7 @@ from PyQt6.QtGui import QRegularExpressionValidator
|
||||
from src.logic import Database
|
||||
from src.utils import Icon
|
||||
|
||||
|
||||
class CreateUser(QtWidgets.QDialog, Ui_Dialog):
|
||||
def __init__(self, fieldname, data):
|
||||
super(CreateUser, self).__init__()
|
||||
@@ -40,6 +41,7 @@ class CreateUser(QtWidgets.QDialog, Ui_Dialog):
|
||||
lambda: self.validateInputUserno(self.userno.text(), "int")
|
||||
)
|
||||
log.info("User creation dialog opened")
|
||||
|
||||
def checkFields(self):
|
||||
if (
|
||||
self.username.hasAcceptableInput()
|
||||
|
||||
@@ -2,6 +2,7 @@ from .sources.Ui_dialog_extendLoanDuration import Ui_Dialog
|
||||
from PyQt6 import QtWidgets, QtCore
|
||||
from src.utils import Icon
|
||||
|
||||
|
||||
class ExtendLoan(QtWidgets.QDialog, Ui_Dialog):
|
||||
def __init__(self, user, media):
|
||||
super(ExtendLoan, self).__init__()
|
||||
@@ -17,9 +18,9 @@ class ExtendLoan(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.buttonBox.accepted.connect(self.extendLoan)
|
||||
|
||||
def extendLoan(self):
|
||||
#print("Extend Loan")
|
||||
# print("Extend Loan")
|
||||
selectedDate = self.extenduntil.selectedDate()
|
||||
#print(selectedDate)
|
||||
# print(selectedDate)
|
||||
self.extendDate = selectedDate
|
||||
self.close()
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ class LoanWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
def selfpass(self):
|
||||
pass
|
||||
|
||||
|
||||
def insertRow(self, data):
|
||||
log.debug(f"Inserting row: {data}")
|
||||
|
||||
|
||||
@@ -22,10 +22,12 @@ from .reportUi import ReportUi
|
||||
backup = Backup()
|
||||
cat = Catalogue()
|
||||
|
||||
|
||||
def getShortcut(shortcuts, name):
|
||||
shortcut = [cut for cut in shortcuts if cut["name"] == name][0]
|
||||
return shortcut["current"]
|
||||
|
||||
|
||||
class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
def __init__(self):
|
||||
super(MainUI, self).__init__()
|
||||
@@ -43,10 +45,12 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.actionBericht_erstellen.triggered.connect(self.generateReport)
|
||||
self.actionDokumentation_ffnen.triggered.connect(self.openDocumentation)
|
||||
self.actionBeenden.triggered.connect(self.shutdown)
|
||||
|
||||
def __mail():
|
||||
webbrowser.open(f"mailto:{__email__}")
|
||||
|
||||
self.actionProblem_melden.triggered.connect(__mail)
|
||||
#if close button is pressed call shutdown
|
||||
# if close button is pressed call shutdown
|
||||
self.closeEvent = self.shutdown
|
||||
# Buttons
|
||||
self.btn_show_lentmedia.clicked.connect(self.showUser)
|
||||
@@ -98,21 +102,24 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.show()
|
||||
|
||||
def shutdown(self, *args):
|
||||
#kill documentation thread
|
||||
# kill documentation thread
|
||||
log.info("Shutting down")
|
||||
if config.documentation:
|
||||
self.docu.terminate()
|
||||
sys.exit()
|
||||
|
||||
|
||||
def assignShortcuts(self):
|
||||
shortcuts = config.shortcuts
|
||||
shortcuts = OmegaConf.to_container(shortcuts)
|
||||
#convert to dictconfig
|
||||
# convert to dictconfig
|
||||
|
||||
self.actionDokumentation_ffnen.setShortcut(getShortcut(shortcuts, "Hilfe"))
|
||||
self.actionAusleihhistorie.setShortcut(getShortcut(shortcuts, "Ausleihhistorie"))
|
||||
self.actionBericht_erstellen.setShortcut(getShortcut(shortcuts, "Bericht_erstellen"))
|
||||
self.actionAusleihhistorie.setShortcut(
|
||||
getShortcut(shortcuts, "Ausleihhistorie")
|
||||
)
|
||||
self.actionBericht_erstellen.setShortcut(
|
||||
getShortcut(shortcuts, "Bericht_erstellen")
|
||||
)
|
||||
self.actionNutzer.setShortcut(getShortcut(shortcuts, "Nutzer"))
|
||||
self.actionRueckgabemodus.setShortcut(getShortcut(shortcuts, "Rueckgabemodus"))
|
||||
|
||||
@@ -138,20 +145,22 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
settings = Settings()
|
||||
settings.exec()
|
||||
result = settings.result()
|
||||
print(settings.settingschanged, settings.restart_required)
|
||||
if result == 1:
|
||||
#dialog to ask if program should be restarted
|
||||
# print(settings.settingschanged, settings.restart_required)
|
||||
if result == 1 and settings.restart_required:
|
||||
# dialog to ask if program should be restarted
|
||||
dialog = QtWidgets.QMessageBox()
|
||||
dialog.setWindowTitle("Einstellungen geändert")
|
||||
dialog.setIcon(QtWidgets.QMessageBox.Icon.Information)
|
||||
dialog.setWindowIcon(Icon("settings").icon)
|
||||
dialog.setText("Einstellungen wurden geändert\nProgramm neu starten?")
|
||||
dialog.setWindowIcon(Icon("restart").icon)
|
||||
dialog.setText(
|
||||
"Einstellungen wurden geändert\nDas Programm muss neu gestartet werden?"
|
||||
)
|
||||
dialog.setStandardButtons(
|
||||
QtWidgets.QMessageBox.StandardButton.Yes
|
||||
| QtWidgets.QMessageBox.StandardButton.No
|
||||
)
|
||||
dialog.setDefaultButton(QtWidgets.QMessageBox.StandardButton.No)
|
||||
#translate buttons
|
||||
# translate buttons
|
||||
yes = dialog.button(QtWidgets.QMessageBox.StandardButton.Yes)
|
||||
yes.setText("Ja")
|
||||
no = dialog.button(QtWidgets.QMessageBox.StandardButton.No)
|
||||
@@ -161,7 +170,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
if result == QtWidgets.QMessageBox.StandardButton.Yes:
|
||||
self.restart()
|
||||
# reload settings
|
||||
#print(config)
|
||||
# print(config)
|
||||
|
||||
def openDocumentation(self):
|
||||
log.info("Opening Documentation")
|
||||
@@ -175,19 +184,16 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
dialog.setText("Dokumentation nicht verfügbar")
|
||||
dialog.exec()
|
||||
|
||||
|
||||
|
||||
|
||||
def restart(self):
|
||||
#log restart
|
||||
# log restart
|
||||
log.info("Restarting Program")
|
||||
import os
|
||||
|
||||
python_executable = sys.executable
|
||||
args = sys.argv[:]
|
||||
args.insert(0, sys.executable)
|
||||
os.execvp(python_executable, args)
|
||||
|
||||
|
||||
def changeMode(self):
|
||||
log.info("Changing Mode, current mode is {}", self.activeState)
|
||||
self.input_username.clear()
|
||||
@@ -205,8 +211,8 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
if self.activeState == "Rückgabe":
|
||||
if stayReturn:
|
||||
self.activateReturnMode()
|
||||
else: self.activateLoanMode()
|
||||
|
||||
else:
|
||||
self.activateLoanMode()
|
||||
|
||||
else:
|
||||
self.activateReturnMode()
|
||||
@@ -225,7 +231,9 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.activeState = "Ausleihe"
|
||||
if self.input_userno.text() == "" or self.input_username.text() == "":
|
||||
self.input_file_ident.setEnabled(False)
|
||||
self.input_file_ident.setPlaceholderText("Bitte zuerst Nutzerdaten eingeben")
|
||||
self.input_file_ident.setPlaceholderText(
|
||||
"Bitte zuerst Nutzerdaten eingeben"
|
||||
)
|
||||
else:
|
||||
self.input_file_ident.setEnabled(True)
|
||||
|
||||
@@ -240,7 +248,9 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.mode.setText("Rückgabe")
|
||||
self.input_file_ident.setEnabled(True)
|
||||
self.input_file_ident.setPlaceholderText("Buchidentifikation eingeben")
|
||||
self.input_username.setPlaceholderText("Bitte erst in den Ausleihmodus wechseln")
|
||||
self.input_username.setPlaceholderText(
|
||||
"Bitte erst in den Ausleihmodus wechseln"
|
||||
)
|
||||
self.input_userno.setPlaceholderText("Bitte erst in den Ausleihmodus wechseln")
|
||||
|
||||
def showUser(self):
|
||||
@@ -256,9 +266,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
dialog.exec()
|
||||
return
|
||||
|
||||
self.user_ui = UserUI(
|
||||
self.activeUser
|
||||
)
|
||||
self.user_ui = UserUI(self.activeUser)
|
||||
# self.user_ui.setFields("John Doe", "123456789", "test@mail.com")
|
||||
self.user_ui.show()
|
||||
|
||||
@@ -291,7 +299,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
def checkUser(self, fieldname, data):
|
||||
log.info(f"Checking User {fieldname}, {data}")
|
||||
#print("Checking User", fieldname, data)
|
||||
# print("Checking User", fieldname, data)
|
||||
# set fieldname as key and data as variable
|
||||
user = self.db.checkUserExists(fieldname, data)
|
||||
if not user:
|
||||
@@ -311,16 +319,16 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
multi.exec()
|
||||
self.activeUser = multi.userdata
|
||||
else:
|
||||
#print("User found", user[0])
|
||||
# print("User found", user[0])
|
||||
self.activeUser = user[0]
|
||||
|
||||
if self.activeUser is not None:
|
||||
log.info(f"User found {self.activeUser}")
|
||||
#print("User found", self.activeUser)
|
||||
# print("User found", self.activeUser)
|
||||
self.setUserData()
|
||||
self.input_file_ident.setFocus()
|
||||
self.mode.setText("Ausleihe")
|
||||
#print(self.activeUser.__dict__)
|
||||
# print(self.activeUser.__dict__)
|
||||
loans = self.db.getActiveLoans(self.activeUser.id)
|
||||
log.debug("Active Loans", loans)
|
||||
self.btn_show_lentmedia.setText(loans)
|
||||
@@ -339,6 +347,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.input_file_ident.setEnabled(True)
|
||||
self.input_file_ident.setPlaceholderText("Buchidentifikation eingeben")
|
||||
self.input_file_ident.setFocus()
|
||||
|
||||
def moveToLine(self, line):
|
||||
log.debug("Moving to Line", line)
|
||||
line.setFocus()
|
||||
@@ -356,7 +365,9 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
dialog.setWindowTitle("Ungültige Eingabe")
|
||||
dialog.setIcon(QtWidgets.QMessageBox.Icon.Warning)
|
||||
dialog.setWindowIcon(Icon("warning").overwriteColor("#EA3323"))
|
||||
dialog.setText("Eingabe ist nicht in der Datenbank\nBitte prüfen und erneut eingeben")
|
||||
dialog.setText(
|
||||
"Eingabe ist nicht in der Datenbank\nBitte prüfen und erneut eingeben"
|
||||
)
|
||||
dialog.exec()
|
||||
self.input_file_ident.setFocus()
|
||||
self.input_file_ident.clear()
|
||||
@@ -376,6 +387,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
return
|
||||
self.mediaAdd(value)
|
||||
self.input_file_ident.setFocus()
|
||||
|
||||
def mediaAdd(self, identifier):
|
||||
log.info("Adding Media", identifier=identifier)
|
||||
self.input_file_ident.clear()
|
||||
@@ -404,7 +416,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
elif book_id:
|
||||
if isinstance(book_id, list) and len(book_id) > 1:
|
||||
#print("Multiple Books found")
|
||||
# print("Multiple Books found")
|
||||
# TODO: implement book selection dialog
|
||||
return
|
||||
else:
|
||||
@@ -413,7 +425,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
# check if book is already loaned
|
||||
loaned = self.db.checkLoanState(book_id[0])
|
||||
if loaned:
|
||||
#print("Book already loaned")
|
||||
# print("Book already loaned")
|
||||
self.setStatusTipMessage("Buch bereits entliehen")
|
||||
# dialog with yes no to create new entry
|
||||
dialog = QtWidgets.QMessageBox()
|
||||
@@ -434,9 +446,11 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
return
|
||||
newentry = NewEntry([book_id[0]])
|
||||
newentry.exec()
|
||||
if newentry.result() == 1: # only create dialog if new entry was created
|
||||
if (
|
||||
newentry.result() == 1
|
||||
): # only create dialog if new entry was created
|
||||
self.setStatusTipMessage("Neues Exemplar hinzugefügt")
|
||||
#print(created_ids)
|
||||
# print(created_ids)
|
||||
self.input_file_ident.setEnabled(True)
|
||||
newentries = newentry.newIds
|
||||
if newentries:
|
||||
@@ -446,7 +460,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
log.info("inserted duplicated book into database")
|
||||
return
|
||||
else:
|
||||
#print("Book not loaned, loaning now")
|
||||
# print("Book not loaned, loaning now")
|
||||
self.loanMedia(user_id, book_id)
|
||||
|
||||
def loanMedia(self, user_id, book_id):
|
||||
@@ -457,7 +471,7 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.duedate.date().toString("yyyy-MM-dd"),
|
||||
)
|
||||
media = self.db.getMedia(book_id[0])
|
||||
#print(media)
|
||||
# print(media)
|
||||
self.mediaOverview.insertRow(0)
|
||||
self.mediaOverview.setItem(0, 0, QtWidgets.QTableWidgetItem(media.signature))
|
||||
self.mediaOverview.setItem(0, 1, QtWidgets.QTableWidgetItem(media.title))
|
||||
@@ -473,19 +487,19 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.input_file_ident.setEnabled(True)
|
||||
|
||||
def returnMedia(self, identifier):
|
||||
#print("Returning Media", identifier)
|
||||
# print("Returning Media", identifier)
|
||||
# get book id from database
|
||||
# self.
|
||||
identifier = Book(
|
||||
isbn=identifier, title=identifier, signature=identifier, ppn=identifier
|
||||
)
|
||||
book_id = self.db.checkMediaExists(identifier)
|
||||
#print(book_id)
|
||||
# print(book_id)
|
||||
if book_id:
|
||||
# check if book is already loaned
|
||||
loaned = self.db.checkLoanState(book_id[0])
|
||||
if loaned:
|
||||
#print("Book already loaned, returning now")
|
||||
# print("Book already loaned, returning now")
|
||||
user = self.db.getUserByLoan(book_id[0])
|
||||
# set userdata in lineedits
|
||||
self.activeUser = user
|
||||
@@ -494,7 +508,9 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
book_id[0], self.currentDate.toString("yyyy-MM-dd")
|
||||
)
|
||||
self.mediaOverview.insertRow(0)
|
||||
self.mediaOverview.setItem(0, 0, QtWidgets.QTableWidgetItem(book.signature))
|
||||
self.mediaOverview.setItem(
|
||||
0, 0, QtWidgets.QTableWidgetItem(book.signature)
|
||||
)
|
||||
self.mediaOverview.setItem(0, 1, QtWidgets.QTableWidgetItem(book.title))
|
||||
self.mediaOverview.setItem(
|
||||
0, 2, QtWidgets.QTableWidgetItem("Zurückgegeben")
|
||||
@@ -504,15 +520,13 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.db.getActiveLoans(self.activeUser.id)
|
||||
)
|
||||
else:
|
||||
#print("Book not loaned")
|
||||
# print("Book not loaned")
|
||||
self.setStatusTipMessage("Buch nicht entliehen")
|
||||
self.input_file_ident.clear()
|
||||
else:
|
||||
log.error("Book not found, identifier", identifier)
|
||||
#print("Book not found")
|
||||
#self.input_file_ident.setPlaceholderText(f"Buch {identifier} nicht gefunden")
|
||||
|
||||
|
||||
# print("Book not found")
|
||||
# self.input_file_ident.setPlaceholderText(f"Buch {identifier} nicht gefunden")
|
||||
|
||||
def setStatusTipMessage(self, message):
|
||||
dialog = QtWidgets.QMessageBox()
|
||||
@@ -521,13 +535,15 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
dialog.setWindowIcon(Icon("error").overwriteColor("#EA3323"))
|
||||
dialog.setText(message)
|
||||
dialog.exec()
|
||||
|
||||
|
||||
def exit_handler():
|
||||
log.info(
|
||||
"Exiting, creating backup, renaming inactive users, creating report if day matches"
|
||||
)
|
||||
restore_config()
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
#print(backup.backup)
|
||||
# print(backup.backup)
|
||||
# generate report if monday
|
||||
if datetime.datetime.now().weekday() == config.report.report_day:
|
||||
log.info("Generating Report")
|
||||
@@ -561,6 +577,8 @@ def exit_handler():
|
||||
dialog.exec()
|
||||
log.info("Exiting")
|
||||
sys.exit()
|
||||
|
||||
|
||||
def launch(*argv):
|
||||
options = sys.argv
|
||||
if argv:
|
||||
@@ -588,18 +606,20 @@ def launch(*argv):
|
||||
atexit.register(exit_handler)
|
||||
sys.exit(app.exec())
|
||||
# sys.exit(app.exec())
|
||||
#print("Launching Main UI")
|
||||
#print(options)
|
||||
QtCore.QLocale().setDefault(QtCore.QLocale(QtCore.QLocale.Language.German, QtCore.QLocale.Country.Germany))
|
||||
# print("Launching Main UI")
|
||||
# print(options)
|
||||
QtCore.QLocale().setDefault(
|
||||
QtCore.QLocale(QtCore.QLocale.Language.German, QtCore.QLocale.Country.Germany)
|
||||
)
|
||||
SYSTEM_LANGUAGE = QtCore.QLocale().system().name()
|
||||
|
||||
# Load base QT translations from the normal place
|
||||
app = QtWidgets.QApplication([])
|
||||
main_ui = MainUI()
|
||||
#translate ui to system language
|
||||
# translate ui to system language
|
||||
if SYSTEM_LANGUAGE:
|
||||
translator = QtCore.QTranslator()
|
||||
#do not use ascii encoding
|
||||
# do not use ascii encoding
|
||||
translator.load(f"qt_{SYSTEM_LANGUAGE}", "translations")
|
||||
translator.load("app.qm", "translations")
|
||||
app.installTranslator(translator)
|
||||
|
||||
@@ -27,7 +27,7 @@ class MultiUserFound(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.tableWidget.cellClicked.connect(self.selectUser)
|
||||
|
||||
def selectUser(self, row, column):
|
||||
#print(row, column)
|
||||
# print(row, column)
|
||||
user = User(
|
||||
userid=self.tableWidget.item(row, 0).text(),
|
||||
username=self.tableWidget.item(row, 1).text(),
|
||||
|
||||
@@ -4,6 +4,7 @@ from src.logic import Database
|
||||
from src.schemas import Book
|
||||
from src.utils import Icon
|
||||
|
||||
|
||||
class NewEntry(QtWidgets.QDialog, Ui_Dialog):
|
||||
def __init__(self, title_id: list[int]):
|
||||
super(NewEntry, self).__init__()
|
||||
@@ -19,15 +20,15 @@ class NewEntry(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.populateTable()
|
||||
self.btn_addNewBook.clicked.connect(self.addEntry)
|
||||
self.buttonBox.accepted.connect(self.insertEntry)
|
||||
#disable buttonbox accepted
|
||||
self.buttonBox.button(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
).setEnabled(False)
|
||||
# disable buttonbox accepted
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setEnabled(
|
||||
False
|
||||
)
|
||||
|
||||
def addEntry(self):
|
||||
self.buttonBox.button(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
).setEnabled(True)
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setEnabled(
|
||||
True
|
||||
)
|
||||
# clone last row and its data
|
||||
row = self.tableWidget.rowCount()
|
||||
self.tableWidget.insertRow(row)
|
||||
@@ -45,9 +46,10 @@ class NewEntry(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.tableWidget.item(row, i).text().split("+")[0] + "+" + entry
|
||||
),
|
||||
)
|
||||
|
||||
def populateTable(self):
|
||||
for title in self.titles:
|
||||
#print(title)
|
||||
# print(title)
|
||||
entries = self.db.getMediaSimilarSignatureByID(title)
|
||||
# sort by signature
|
||||
entries.sort(key=lambda x: x.signature, reverse=True)
|
||||
@@ -73,7 +75,7 @@ class NewEntry(QtWidgets.QDialog, Ui_Dialog):
|
||||
signature=signature,
|
||||
ppn=eval(ppn),
|
||||
)
|
||||
#print(book)
|
||||
# print(book)
|
||||
if not self.db.checkMediaExists(book):
|
||||
newBookId = self.db.insertMedia(book)
|
||||
self.newIds.append(newBookId)
|
||||
|
||||
@@ -90,7 +90,7 @@ class ReportUi(QtWidgets.QDialog, Ui_Dialog):
|
||||
def report_generated(self):
|
||||
self.reportlink.setOpenExternalLinks(True)
|
||||
fileformat = self.rthread.format
|
||||
#print(fileformat)
|
||||
# print(fileformat)
|
||||
self.reportlink.setText(
|
||||
f'<a href="file:///{os.getcwd()}/report.{fileformat}">Report</a>'
|
||||
)
|
||||
|
||||
@@ -5,13 +5,14 @@ from src.utils import Icon
|
||||
from omegaconf import OmegaConf
|
||||
import os
|
||||
|
||||
|
||||
class Settings(QtWidgets.QDialog, Ui_Dialog):
|
||||
def __init__(self):
|
||||
super(Settings, self).__init__()
|
||||
self.setupUi(self)
|
||||
self.setWindowTitle("Einstellungen")
|
||||
self.setWindowIcon(Icon("settings").icon)
|
||||
#variables
|
||||
# variables
|
||||
self.originalSettings = config.to_Omegaconf()
|
||||
self.changedSettings = config.to_Omegaconf()
|
||||
self.shortcuts = config.shortcuts
|
||||
@@ -19,13 +20,11 @@ class Settings(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.settingschanged = False
|
||||
self.restart_required = False
|
||||
|
||||
|
||||
# buttonbox
|
||||
self.buttonBox.accepted.connect(self.saveSettings)
|
||||
self.buttonBox.rejected.connect(self.close)
|
||||
self.loadSettings()
|
||||
|
||||
|
||||
self.populateShortcuts()
|
||||
# buttons
|
||||
self.btn_select_database_backupLocation.clicked.connect(
|
||||
@@ -36,10 +35,12 @@ class Settings(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.btn_select_report_path.clicked.connect(self.selectReportPath)
|
||||
self.returnMode.clicked.connect(self.returnModeSetting)
|
||||
|
||||
# other
|
||||
# stretch columns
|
||||
self.shortcutchanger.horizontalHeader().setSectionResizeMode(
|
||||
0, QtWidgets.QHeaderView.ResizeMode.Stretch
|
||||
)
|
||||
|
||||
#other
|
||||
#stretch columns
|
||||
self.shortcutchanger.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeMode.Stretch)
|
||||
def returnModeSetting(self):
|
||||
currentstate = self.returnMode.isChecked()
|
||||
if self.originalSettings.advanced_refresh != currentstate:
|
||||
@@ -51,16 +52,17 @@ class Settings(QtWidgets.QDialog, Ui_Dialog):
|
||||
default = shortcut["default"]
|
||||
current = shortcut["current"]
|
||||
self.addShortcut(name, default, current)
|
||||
#assume the shortcuts will be changed
|
||||
# assume the shortcuts will be changed
|
||||
self.settingschanged = True
|
||||
|
||||
def addShortcut(self, name, default, current):
|
||||
#remove all pages from shortcutchanger
|
||||
#add new page with name, default and current
|
||||
# remove all pages from shortcutchanger
|
||||
# add new page with name, default and current
|
||||
|
||||
self.shortcutchanger.insertRow(0)
|
||||
self.shortcutchanger.setItem(0, 0, QtWidgets.QTableWidgetItem(name))
|
||||
self.shortcutchanger.setItem(0, 1, QtWidgets.QTableWidgetItem(default))
|
||||
#add keysequenceedit
|
||||
# add keysequenceedit
|
||||
keysequenceedit = QtWidgets.QKeySequenceEdit()
|
||||
keysequenceedit.setKeySequence(current)
|
||||
self.shortcutchanger.setCellWidget(0, 2, keysequenceedit)
|
||||
@@ -160,16 +162,13 @@ class Settings(QtWidgets.QDialog, Ui_Dialog):
|
||||
report_path = self.report_path.text()
|
||||
refresh_state = self.returnMode.isChecked()
|
||||
shortcuts = self.getShortcuts()
|
||||
#shortcuts to omegaconf.DictConfig
|
||||
# shortcuts to omegaconf.DictConfig
|
||||
shortcuts = OmegaConf.create(shortcuts)
|
||||
|
||||
|
||||
if database_path != self.originalSettings.database.path :
|
||||
if database_path != self.originalSettings.database.path:
|
||||
os.makedirs(database_path, exist_ok=True)
|
||||
self.restart_required = True
|
||||
|
||||
|
||||
|
||||
# create new Settings
|
||||
self.changedSettings.institution_name = institution_name
|
||||
self.changedSettings.loan_duration = default_loan_duration
|
||||
@@ -186,74 +185,66 @@ class Settings(QtWidgets.QDialog, Ui_Dialog):
|
||||
changed = self.changedSettings
|
||||
original = self.originalSettings
|
||||
|
||||
|
||||
|
||||
if changed == original:
|
||||
self.settingschanged = False
|
||||
self.restart_required = False
|
||||
log.info("Settings not changed")
|
||||
else:
|
||||
self.settingschanged = True
|
||||
#compare if database or shortcuts were changed
|
||||
# compare if database or shortcuts were changed
|
||||
database = original.database == changed.database
|
||||
shortcuts = self.shortcuts == self.sortShortcuts(changed.shortcuts)
|
||||
if not database or not shortcuts:
|
||||
self.restart_required = True
|
||||
log.info(
|
||||
f"Settings changed, restart required: {self.restart_required}",
|
||||
database=database,
|
||||
shortcuts=shortcuts,
|
||||
)
|
||||
|
||||
# save the new settings
|
||||
if self.settingschanged:
|
||||
# save the settings
|
||||
config.updateValue("institution_name", self.changedSettings.institution_name)
|
||||
config.updateValue("default_loan_duration", self.changedSettings.loan_duration)
|
||||
config.updateValue("database.backupLocation", self.changedSettings.database.backupLocation)
|
||||
config.updateValue(
|
||||
"institution_name", self.changedSettings.institution_name
|
||||
)
|
||||
config.updateValue(
|
||||
"default_loan_duration", self.changedSettings.loan_duration
|
||||
)
|
||||
config.updateValue(
|
||||
"database.backupLocation", self.changedSettings.database.backupLocation
|
||||
)
|
||||
config.updateValue("database.path", self.changedSettings.database.path)
|
||||
config.updateValue("database.name", self.changedSettings.database.name)
|
||||
config.updateValue("inactive_user_deletion", self.changedSettings.inactive_user_deletion)
|
||||
config.updateValue("report.report_day", self.changedSettings.report.report_day)
|
||||
config.updateValue("report.generate_report", self.changedSettings.report.generate_report)
|
||||
config.updateValue(
|
||||
"inactive_user_deletion", self.changedSettings.inactive_user_deletion
|
||||
)
|
||||
config.updateValue(
|
||||
"report.report_day", self.changedSettings.report.report_day
|
||||
)
|
||||
config.updateValue(
|
||||
"report.generate_report", self.changedSettings.report.generate_report
|
||||
)
|
||||
config.updateValue("report.path", self.changedSettings.report.path)
|
||||
config.updateValue("advanced_refresh", self.changedSettings.advanced_refresh)
|
||||
config.updateValue(
|
||||
"advanced_refresh", self.changedSettings.advanced_refresh
|
||||
)
|
||||
config.updateValue("shortcuts", self.changedSettings.shortcuts)
|
||||
self.originalSettings = self.changedSettings
|
||||
config.save()
|
||||
|
||||
if self.restart_required:
|
||||
self.restart()
|
||||
self.close()
|
||||
|
||||
def restart(self):
|
||||
dialog = QtWidgets.QMessageBox()
|
||||
dialog.setIcon(QtWidgets.QMessageBox.Icon.Information)
|
||||
dialog.setText("Neustart erforderlich")
|
||||
dialog.setInformativeText(
|
||||
"Das Programm muss neu gestartet werden, um die Änderungen zu übernehmen."
|
||||
)
|
||||
dialog.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
||||
dialog.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
|
||||
dialog.setWindowTitle("Neustart erforderlich")
|
||||
dialog.setWindowIcon(Icon("restart").icon)
|
||||
dialog.exec()
|
||||
|
||||
def DiscardSettings(self):
|
||||
self.loadSettings()
|
||||
self.restart_required = False
|
||||
self.settingschanged = False
|
||||
|
||||
def loadSettings(self):
|
||||
self.institution_name.setText(config.institution_name)
|
||||
self.default_loan_duration.setValue(
|
||||
int(config.loan_duration)
|
||||
)
|
||||
self.default_loan_duration.setValue(int(config.loan_duration))
|
||||
self.delete_inactive_user_duration.setValue(
|
||||
int(config.delete_inactive_user_duration)
|
||||
)
|
||||
self.database_backupLocation.setText(
|
||||
config.database.backupLocation
|
||||
)
|
||||
self.database_backupLocation.setText(config.database.backupLocation)
|
||||
self.database_path.setText(config.database.path)
|
||||
self.database_name.setText(config.database.name)
|
||||
self.report_day.setCurrentIndex(config.report.report_day)
|
||||
|
||||
@@ -17,7 +17,12 @@ class Ui_Dialog(object):
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout.addItem(spacerItem)
|
||||
self.btn_addNewBook = QtWidgets.QToolButton(parent=Dialog)
|
||||
self.btn_addNewBook.setObjectName("btn_addNewBook")
|
||||
@@ -38,7 +43,10 @@ class Ui_Dialog(object):
|
||||
self.verticalLayout.addWidget(self.tableWidget)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
||||
| QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.verticalLayout.addWidget(self.buttonBox)
|
||||
|
||||
|
||||
@@ -37,10 +37,18 @@ class Ui_Dialog(object):
|
||||
self.gridLayout.addWidget(self.username, 0, 1, 1, 1)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Save)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
||||
| QtWidgets.QDialogButtonBox.StandardButton.Save
|
||||
)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.gridLayout.addWidget(self.buttonBox, 4, 1, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
spacerItem = QtWidgets.QSpacerItem(
|
||||
20,
|
||||
40,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
)
|
||||
self.gridLayout.addItem(spacerItem, 3, 0, 1, 1)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
|
||||
@@ -21,7 +21,10 @@ class Ui_Dialog(object):
|
||||
self.gridLayout.addWidget(self.extenduntil, 1, 2, 1, 1)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
||||
| QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.gridLayout.addWidget(self.buttonBox, 2, 2, 1, 1)
|
||||
self.label = QtWidgets.QLabel(parent=Dialog)
|
||||
@@ -40,4 +43,6 @@ class Ui_Dialog(object):
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
|
||||
self.label.setText(_translate("Dialog", "Bitte das Verlängerungsdatum auswählen"))
|
||||
self.label.setText(
|
||||
_translate("Dialog", "Bitte das Verlängerungsdatum auswählen")
|
||||
)
|
||||
|
||||
@@ -37,7 +37,9 @@ class Ui_Dialog(object):
|
||||
self.horizontalLayout.addWidget(self.radio_year)
|
||||
self.gridLayout.addLayout(self.horizontalLayout, 1, 1, 1, 1)
|
||||
self.dayValue = QtWidgets.QLineEdit(parent=Dialog)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed)
|
||||
sizePolicy = QtWidgets.QSizePolicy(
|
||||
QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed
|
||||
)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.dayValue.sizePolicy().hasHeightForWidth())
|
||||
@@ -107,7 +109,9 @@ class Ui_Dialog(object):
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
|
||||
self.label.setText(_translate("Dialog", "Wieviele Tage sollen im Bericht erfasst werden?"))
|
||||
self.label.setText(
|
||||
_translate("Dialog", "Wieviele Tage sollen im Bericht erfasst werden?")
|
||||
)
|
||||
self.label_2.setText(_translate("Dialog", "Tage"))
|
||||
self.radio_week.setText(_translate("Dialog", "Woche"))
|
||||
self.radio_month.setText(_translate("Dialog", "Monat"))
|
||||
|
||||
@@ -20,7 +20,10 @@ class Ui_Dialog(object):
|
||||
self.horizontalLayout.addWidget(self.textEdit)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Vertical)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
||||
| QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.horizontalLayout.addWidget(self.buttonBox)
|
||||
|
||||
|
||||
@@ -19,8 +19,12 @@ class Ui_Dialog(object):
|
||||
self.label.setObjectName("label")
|
||||
self.verticalLayout.addWidget(self.label)
|
||||
self.tableWidget = QtWidgets.QTableWidget(parent=Dialog)
|
||||
self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
self.tableWidget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
self.tableWidget.setEditTriggers(
|
||||
QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers
|
||||
)
|
||||
self.tableWidget.setSelectionBehavior(
|
||||
QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows
|
||||
)
|
||||
self.tableWidget.setObjectName("tableWidget")
|
||||
self.tableWidget.setColumnCount(3)
|
||||
self.tableWidget.setRowCount(0)
|
||||
@@ -33,7 +37,10 @@ class Ui_Dialog(object):
|
||||
self.verticalLayout.addWidget(self.tableWidget)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
||||
| QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.verticalLayout.addWidget(self.buttonBox)
|
||||
|
||||
@@ -45,7 +52,12 @@ class Ui_Dialog(object):
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
|
||||
self.label.setText(_translate("Dialog", "Es wurden mehrere passende Personen gefunden. Bitte die richtige Person auswählen."))
|
||||
self.label.setText(
|
||||
_translate(
|
||||
"Dialog",
|
||||
"Es wurden mehrere passende Personen gefunden. Bitte die richtige Person auswählen.",
|
||||
)
|
||||
)
|
||||
item = self.tableWidget.horizontalHeaderItem(0)
|
||||
item.setText(_translate("Dialog", "Matrikelnr."))
|
||||
item = self.tableWidget.horizontalHeaderItem(1)
|
||||
|
||||
@@ -17,13 +17,19 @@ class Ui_Dialog(object):
|
||||
self.formLayout.setObjectName("formLayout")
|
||||
self.label = QtWidgets.QLabel(parent=Dialog)
|
||||
self.label.setObjectName("label")
|
||||
self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label)
|
||||
self.formLayout.setWidget(
|
||||
0, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label
|
||||
)
|
||||
self.institution_name = QtWidgets.QLineEdit(parent=Dialog)
|
||||
self.institution_name.setObjectName("institution_name")
|
||||
self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.FieldRole, self.institution_name)
|
||||
self.formLayout.setWidget(
|
||||
0, QtWidgets.QFormLayout.ItemRole.FieldRole, self.institution_name
|
||||
)
|
||||
self.label_2 = QtWidgets.QLabel(parent=Dialog)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_2)
|
||||
self.formLayout.setWidget(
|
||||
1, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_2
|
||||
)
|
||||
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
|
||||
self.default_loan_duration = QtWidgets.QSpinBox(parent=Dialog)
|
||||
@@ -34,29 +40,41 @@ class Ui_Dialog(object):
|
||||
self.label_13.setMaximumSize(QtCore.QSize(43, 16777215))
|
||||
self.label_13.setObjectName("label_13")
|
||||
self.horizontalLayout_2.addWidget(self.label_13)
|
||||
self.formLayout.setLayout(1, QtWidgets.QFormLayout.ItemRole.FieldRole, self.horizontalLayout_2)
|
||||
self.formLayout.setLayout(
|
||||
1, QtWidgets.QFormLayout.ItemRole.FieldRole, self.horizontalLayout_2
|
||||
)
|
||||
self.label_7 = QtWidgets.QLabel(parent=Dialog)
|
||||
self.label_7.setObjectName("label_7")
|
||||
self.formLayout.setWidget(3, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_7)
|
||||
self.formLayout.setWidget(
|
||||
3, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_7
|
||||
)
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.delete_inactive_user_duration = QtWidgets.QSpinBox(parent=Dialog)
|
||||
self.delete_inactive_user_duration.setMaximum(9999)
|
||||
self.delete_inactive_user_duration.setProperty("value", 365)
|
||||
self.delete_inactive_user_duration.setObjectName("delete_inactive_user_duration")
|
||||
self.delete_inactive_user_duration.setObjectName(
|
||||
"delete_inactive_user_duration"
|
||||
)
|
||||
self.horizontalLayout.addWidget(self.delete_inactive_user_duration)
|
||||
self.label_12 = QtWidgets.QLabel(parent=Dialog)
|
||||
self.label_12.setMaximumSize(QtCore.QSize(43, 16777215))
|
||||
self.label_12.setObjectName("label_12")
|
||||
self.horizontalLayout.addWidget(self.label_12)
|
||||
self.formLayout.setLayout(3, QtWidgets.QFormLayout.ItemRole.FieldRole, self.horizontalLayout)
|
||||
self.formLayout.setLayout(
|
||||
3, QtWidgets.QFormLayout.ItemRole.FieldRole, self.horizontalLayout
|
||||
)
|
||||
self.returnMode = QtWidgets.QCheckBox(parent=Dialog)
|
||||
self.returnMode.setTristate(False)
|
||||
self.returnMode.setObjectName("returnMode")
|
||||
self.formLayout.setWidget(4, QtWidgets.QFormLayout.ItemRole.FieldRole, self.returnMode)
|
||||
self.formLayout.setWidget(
|
||||
4, QtWidgets.QFormLayout.ItemRole.FieldRole, self.returnMode
|
||||
)
|
||||
self.label_3 = QtWidgets.QLabel(parent=Dialog)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.formLayout.setWidget(5, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_3)
|
||||
self.formLayout.setWidget(
|
||||
5, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_3
|
||||
)
|
||||
self.databasesettings = QtWidgets.QGridLayout()
|
||||
self.databasesettings.setObjectName("databasesettings")
|
||||
self.database_name = QtWidgets.QLineEdit(parent=Dialog)
|
||||
@@ -84,12 +102,20 @@ class Ui_Dialog(object):
|
||||
self.btn_select_database_name.setObjectName("btn_select_database_name")
|
||||
self.databasesettings.addWidget(self.btn_select_database_name, 1, 2, 1, 1)
|
||||
self.btn_select_database_backupLocation = QtWidgets.QToolButton(parent=Dialog)
|
||||
self.btn_select_database_backupLocation.setObjectName("btn_select_database_backupLocation")
|
||||
self.databasesettings.addWidget(self.btn_select_database_backupLocation, 2, 2, 1, 1)
|
||||
self.formLayout.setLayout(5, QtWidgets.QFormLayout.ItemRole.FieldRole, self.databasesettings)
|
||||
self.btn_select_database_backupLocation.setObjectName(
|
||||
"btn_select_database_backupLocation"
|
||||
)
|
||||
self.databasesettings.addWidget(
|
||||
self.btn_select_database_backupLocation, 2, 2, 1, 1
|
||||
)
|
||||
self.formLayout.setLayout(
|
||||
5, QtWidgets.QFormLayout.ItemRole.FieldRole, self.databasesettings
|
||||
)
|
||||
self.label_9 = QtWidgets.QLabel(parent=Dialog)
|
||||
self.label_9.setObjectName("label_9")
|
||||
self.formLayout.setWidget(6, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_9)
|
||||
self.formLayout.setWidget(
|
||||
6, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_9
|
||||
)
|
||||
self.gridLayout = QtWidgets.QGridLayout()
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.btn_select_report_path = QtWidgets.QToolButton(parent=Dialog)
|
||||
@@ -119,12 +145,20 @@ class Ui_Dialog(object):
|
||||
self.report_day.addItem("")
|
||||
self.report_day.addItem("")
|
||||
self.gridLayout.addWidget(self.report_day, 0, 1, 1, 1)
|
||||
self.formLayout.setLayout(6, QtWidgets.QFormLayout.ItemRole.FieldRole, self.gridLayout)
|
||||
self.formLayout.setLayout(
|
||||
6, QtWidgets.QFormLayout.ItemRole.FieldRole, self.gridLayout
|
||||
)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Discard|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
||||
| QtWidgets.QDialogButtonBox.StandardButton.Discard
|
||||
| QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.formLayout.setWidget(9, QtWidgets.QFormLayout.ItemRole.FieldRole, self.buttonBox)
|
||||
self.formLayout.setWidget(
|
||||
9, QtWidgets.QFormLayout.ItemRole.FieldRole, self.buttonBox
|
||||
)
|
||||
self.shortcutchanger = QtWidgets.QTableWidget(parent=Dialog)
|
||||
self.shortcutchanger.setObjectName("shortcutchanger")
|
||||
self.shortcutchanger.setColumnCount(3)
|
||||
@@ -135,7 +169,9 @@ class Ui_Dialog(object):
|
||||
self.shortcutchanger.setHorizontalHeaderItem(1, item)
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.shortcutchanger.setHorizontalHeaderItem(2, item)
|
||||
self.formLayout.setWidget(8, QtWidgets.QFormLayout.ItemRole.FieldRole, self.shortcutchanger)
|
||||
self.formLayout.setWidget(
|
||||
8, QtWidgets.QFormLayout.ItemRole.FieldRole, self.shortcutchanger
|
||||
)
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.label_14 = QtWidgets.QLabel(parent=Dialog)
|
||||
@@ -144,7 +180,9 @@ class Ui_Dialog(object):
|
||||
self.label_15 = QtWidgets.QLabel(parent=Dialog)
|
||||
self.label_15.setObjectName("label_15")
|
||||
self.verticalLayout.addWidget(self.label_15)
|
||||
self.formLayout.setLayout(8, QtWidgets.QFormLayout.ItemRole.LabelRole, self.verticalLayout)
|
||||
self.formLayout.setLayout(
|
||||
8, QtWidgets.QFormLayout.ItemRole.LabelRole, self.verticalLayout
|
||||
)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
|
||||
@@ -155,7 +193,9 @@ class Ui_Dialog(object):
|
||||
Dialog.setTabOrder(self.database_name, self.database_backupLocation)
|
||||
Dialog.setTabOrder(self.database_backupLocation, self.btn_select_database_path)
|
||||
Dialog.setTabOrder(self.btn_select_database_path, self.btn_select_database_name)
|
||||
Dialog.setTabOrder(self.btn_select_database_name, self.btn_select_database_backupLocation)
|
||||
Dialog.setTabOrder(
|
||||
self.btn_select_database_name, self.btn_select_database_backupLocation
|
||||
)
|
||||
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
@@ -163,10 +203,14 @@ class Ui_Dialog(object):
|
||||
self.label.setText(_translate("Dialog", "Name der Einrichtung"))
|
||||
self.label_2.setText(_translate("Dialog", "Leihdauer"))
|
||||
self.label_13.setText(_translate("Dialog", "Tage(n)"))
|
||||
self.label_7.setText(_translate("Dialog", "Inaktive Nutzer\n"
|
||||
"Löschen nach"))
|
||||
self.label_7.setText(_translate("Dialog", "Inaktive Nutzer\nLöschen nach"))
|
||||
self.label_12.setText(_translate("Dialog", "Tage(n)"))
|
||||
self.returnMode.setToolTip(_translate("Dialog", "Wenn aktiv: Wenn ein Medium zurückgegeben wird, wird die nächste Aktion des Moduswechsels zum normalen Rückgabemodus führen"))
|
||||
self.returnMode.setToolTip(
|
||||
_translate(
|
||||
"Dialog",
|
||||
"Wenn aktiv: Wenn ein Medium zurückgegeben wird, wird die nächste Aktion des Moduswechsels zum normalen Rückgabemodus führen",
|
||||
)
|
||||
)
|
||||
self.returnMode.setText(_translate("Dialog", "Erweiterter Rückgabemodus"))
|
||||
self.label_3.setText(_translate("Dialog", "Datenbank"))
|
||||
self.label_4.setText(_translate("Dialog", "Speicherort"))
|
||||
@@ -192,5 +236,4 @@ class Ui_Dialog(object):
|
||||
item = self.shortcutchanger.horizontalHeaderItem(2)
|
||||
item.setText(_translate("Dialog", "Aktuell"))
|
||||
self.label_14.setText(_translate("Dialog", "Shortcuts"))
|
||||
self.label_15.setText(_translate("Dialog", "(Erst nach Neustart\n"
|
||||
"wirksam)"))
|
||||
self.label_15.setText(_translate("Dialog", "(Erst nach Neustart\nwirksam)"))
|
||||
|
||||
@@ -29,7 +29,12 @@ class Ui_MainWindow(object):
|
||||
self.radio_overdue = QtWidgets.QRadioButton(parent=self.centralwidget)
|
||||
self.radio_overdue.setObjectName("radio_overdue")
|
||||
self.horizontalLayout.addWidget(self.radio_overdue)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout.addItem(spacerItem)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
|
||||
@@ -45,9 +50,15 @@ class Ui_MainWindow(object):
|
||||
self.horizontalLayout_2.addWidget(self.searchFields)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_2)
|
||||
self.loanTable = QtWidgets.QTableWidget(parent=self.centralwidget)
|
||||
self.loanTable.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
self.loanTable.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.SingleSelection)
|
||||
self.loanTable.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
self.loanTable.setEditTriggers(
|
||||
QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers
|
||||
)
|
||||
self.loanTable.setSelectionMode(
|
||||
QtWidgets.QAbstractItemView.SelectionMode.SingleSelection
|
||||
)
|
||||
self.loanTable.setSelectionBehavior(
|
||||
QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows
|
||||
)
|
||||
self.loanTable.setObjectName("loanTable")
|
||||
self.loanTable.setColumnCount(7)
|
||||
self.loanTable.setRowCount(0)
|
||||
@@ -86,7 +97,9 @@ class Ui_MainWindow(object):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
|
||||
self.radio_all.setText(_translate("MainWindow", "Alle Ausleihen"))
|
||||
self.radio_current.setText(_translate("MainWindow", "Aktuell Entliehene Medien"))
|
||||
self.radio_current.setText(
|
||||
_translate("MainWindow", "Aktuell Entliehene Medien")
|
||||
)
|
||||
self.radio_overdue.setText(_translate("MainWindow", "Überzogene Medien"))
|
||||
self.searchFields.setItemText(0, _translate("MainWindow", "Titel"))
|
||||
self.searchFields.setItemText(1, _translate("MainWindow", "Signatur"))
|
||||
|
||||
@@ -22,7 +22,9 @@ class Ui_MainWindow(object):
|
||||
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
|
||||
self.duedate = QtWidgets.QDateEdit(parent=self.centralwidget)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed)
|
||||
sizePolicy = QtWidgets.QSizePolicy(
|
||||
QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed
|
||||
)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.duedate.sizePolicy().hasHeightForWidth())
|
||||
@@ -32,14 +34,23 @@ class Ui_MainWindow(object):
|
||||
self.duedate.setBaseSize(QtCore.QSize(70, 0))
|
||||
self.duedate.setObjectName("duedate")
|
||||
self.horizontalLayout_4.addWidget(self.duedate)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout_4.addItem(spacerItem)
|
||||
self.gridLayout.addLayout(self.horizontalLayout_4, 5, 1, 1, 1)
|
||||
self.label_3 = QtWidgets.QLabel(parent=self.centralwidget)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.gridLayout.addWidget(self.label_3, 3, 0, 1, 1)
|
||||
self.label_6 = QtWidgets.QLabel(parent=self.centralwidget)
|
||||
self.label_6.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignVCenter)
|
||||
self.label_6.setAlignment(
|
||||
QtCore.Qt.AlignmentFlag.AlignLeading
|
||||
| QtCore.Qt.AlignmentFlag.AlignLeft
|
||||
| QtCore.Qt.AlignmentFlag.AlignVCenter
|
||||
)
|
||||
self.label_6.setObjectName("label_6")
|
||||
self.gridLayout.addWidget(self.label_6, 5, 0, 1, 1)
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout()
|
||||
@@ -66,7 +77,12 @@ class Ui_MainWindow(object):
|
||||
self.gridLayout.addWidget(self.input_file_ident, 3, 1, 1, 1)
|
||||
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout_3.addItem(spacerItem1)
|
||||
self.btn_createNewUser = QtWidgets.QPushButton(parent=self.centralwidget)
|
||||
self.btn_createNewUser.setObjectName("btn_createNewUser")
|
||||
@@ -104,7 +120,11 @@ class Ui_MainWindow(object):
|
||||
self.btn_show_lentmedia.setObjectName("btn_show_lentmedia")
|
||||
self.gridLayout_2.addWidget(self.btn_show_lentmedia, 0, 1, 1, 1)
|
||||
self.label_4 = QtWidgets.QLabel(parent=self.groupBox_2)
|
||||
self.label_4.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
|
||||
self.label_4.setAlignment(
|
||||
QtCore.Qt.AlignmentFlag.AlignRight
|
||||
| QtCore.Qt.AlignmentFlag.AlignTrailing
|
||||
| QtCore.Qt.AlignmentFlag.AlignVCenter
|
||||
)
|
||||
self.label_4.setObjectName("label_4")
|
||||
self.gridLayout_2.addWidget(self.label_4, 0, 0, 1, 1)
|
||||
self.label_7 = QtWidgets.QLabel(parent=self.groupBox_2)
|
||||
@@ -217,8 +237,12 @@ class Ui_MainWindow(object):
|
||||
self.actionNutzer.setShortcut(_translate("MainWindow", "F6"))
|
||||
self.actionAusleihhistorie.setText(_translate("MainWindow", "Ausleihhistorie"))
|
||||
self.actionAusleihhistorie.setShortcut(_translate("MainWindow", "F8"))
|
||||
self.actionBericht_erstellen.setText(_translate("MainWindow", "Bericht erstellen"))
|
||||
self.actionBericht_erstellen.setText(
|
||||
_translate("MainWindow", "Bericht erstellen")
|
||||
)
|
||||
self.actionBericht_erstellen.setShortcut(_translate("MainWindow", "F7"))
|
||||
self.actionDokumentation_ffnen.setText(_translate("MainWindow", "Dokumentation öffnen"))
|
||||
self.actionDokumentation_ffnen.setText(
|
||||
_translate("MainWindow", "Dokumentation öffnen")
|
||||
)
|
||||
self.actionDokumentation_ffnen.setShortcut(_translate("MainWindow", "F1"))
|
||||
self.actionProblem_melden.setText(_translate("MainWindow", "Problem melden"))
|
||||
|
||||
@@ -26,7 +26,12 @@ class Ui_MainWindow(object):
|
||||
self.frame.setObjectName("frame")
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout(self.frame)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout.addItem(spacerItem)
|
||||
self.btn_userChange_save = QtWidgets.QPushButton(parent=self.frame)
|
||||
self.btn_userChange_save.setStatusTip("")
|
||||
@@ -35,7 +40,12 @@ class Ui_MainWindow(object):
|
||||
self.btn_userchange_cancel = QtWidgets.QPushButton(parent=self.frame)
|
||||
self.btn_userchange_cancel.setObjectName("btn_userchange_cancel")
|
||||
self.horizontalLayout.addWidget(self.btn_userchange_cancel)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout.addItem(spacerItem1)
|
||||
self.gridLayout.addWidget(self.frame, 3, 1, 1, 1)
|
||||
self.label = QtWidgets.QLabel(parent=self.centralwidget)
|
||||
@@ -94,7 +104,12 @@ class Ui_MainWindow(object):
|
||||
self.radio_overdueLoans = QtWidgets.QRadioButton(parent=self.centralwidget)
|
||||
self.radio_overdueLoans.setObjectName("radio_overdueLoans")
|
||||
self.horizontalLayout_2.addWidget(self.radio_overdueLoans)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout_2.addItem(spacerItem2)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_2)
|
||||
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
|
||||
@@ -107,7 +122,12 @@ class Ui_MainWindow(object):
|
||||
self.searchfilter.addItem("")
|
||||
self.searchfilter.addItem("")
|
||||
self.horizontalLayout_3.addWidget(self.searchfilter)
|
||||
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem3 = QtWidgets.QSpacerItem(
|
||||
40,
|
||||
20,
|
||||
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||
)
|
||||
self.horizontalLayout_3.addItem(spacerItem3)
|
||||
self.btn_extendSelectedMedia = QtWidgets.QPushButton(parent=self.centralwidget)
|
||||
self.btn_extendSelectedMedia.setEnabled(False)
|
||||
@@ -117,10 +137,16 @@ class Ui_MainWindow(object):
|
||||
self.UserMediaTable = QtWidgets.QTableWidget(parent=self.centralwidget)
|
||||
self.UserMediaTable.setMouseTracking(True)
|
||||
self.UserMediaTable.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
|
||||
self.UserMediaTable.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
self.UserMediaTable.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
self.UserMediaTable.setHorizontalScrollBarPolicy(
|
||||
QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff
|
||||
)
|
||||
self.UserMediaTable.setEditTriggers(
|
||||
QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers
|
||||
)
|
||||
self.UserMediaTable.setAlternatingRowColors(True)
|
||||
self.UserMediaTable.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
self.UserMediaTable.setSelectionBehavior(
|
||||
QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows
|
||||
)
|
||||
self.UserMediaTable.setObjectName("UserMediaTable")
|
||||
self.UserMediaTable.setColumnCount(6)
|
||||
self.UserMediaTable.setRowCount(0)
|
||||
@@ -177,11 +203,15 @@ class Ui_MainWindow(object):
|
||||
self.label_5.setText(_translate("MainWindow", "Nutzer Löschen"))
|
||||
self.label_4.setText(_translate("MainWindow", "Medien"))
|
||||
self.radio_allLoanedMedia.setText(_translate("MainWindow", "Alle Ausleihen"))
|
||||
self.radio_currentlyLoaned.setText(_translate("MainWindow", "Aktuell entliehen"))
|
||||
self.radio_currentlyLoaned.setText(
|
||||
_translate("MainWindow", "Aktuell entliehen")
|
||||
)
|
||||
self.radio_overdueLoans.setText(_translate("MainWindow", "Überzogen"))
|
||||
self.searchfilter.setItemText(0, _translate("MainWindow", "Titel"))
|
||||
self.searchfilter.setItemText(1, _translate("MainWindow", "Signatur"))
|
||||
self.btn_extendSelectedMedia.setText(_translate("MainWindow", "Ausgewählte Verlängern"))
|
||||
self.btn_extendSelectedMedia.setText(
|
||||
_translate("MainWindow", "Ausgewählte Verlängern")
|
||||
)
|
||||
self.UserMediaTable.setSortingEnabled(True)
|
||||
item = self.UserMediaTable.horizontalHeaderItem(0)
|
||||
item.setText(_translate("MainWindow", "ISBN"))
|
||||
|
||||
@@ -34,7 +34,9 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.deleteUser.clicked.connect(self.userDelete)
|
||||
self.deleteUser.setIcon(Icon("delete").overwriteColor("red"))
|
||||
self.deleteUser.setEnabled(False)
|
||||
self.deleteUser.setToolTip("Nutzer löschen nicht möglich, solange Medien ausgeliehen sind")
|
||||
self.deleteUser.setToolTip(
|
||||
"Nutzer löschen nicht möglich, solange Medien ausgeliehen sind"
|
||||
)
|
||||
self.btn_extendSelectedMedia.setEnabled(False)
|
||||
|
||||
# radioButtons
|
||||
@@ -46,8 +48,9 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.frame.hide()
|
||||
if self.UserMediaTable.rowCount() == 0:
|
||||
self.btn_extendSelectedMedia.setEnabled(False)
|
||||
self.deleteUser.setEnabled( True)
|
||||
else: self.btn_extendSelectedMedia.setEnabled(True)
|
||||
self.deleteUser.setEnabled(True)
|
||||
else:
|
||||
self.btn_extendSelectedMedia.setEnabled(True)
|
||||
|
||||
# table
|
||||
self.UserMediaTable.horizontalHeader().setSectionResizeMode(
|
||||
@@ -63,7 +66,6 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.user_no.textChanged.connect(self.showFrame)
|
||||
self.mail.textChanged.connect(self.showFrame)
|
||||
|
||||
|
||||
self.show()
|
||||
|
||||
def check_book(self, book: Book):
|
||||
@@ -97,7 +99,7 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
for item in self.UserMediaTable.selectedItems():
|
||||
if item.column() == 1:
|
||||
signature = item.text()
|
||||
#print(signature)
|
||||
# print(signature)
|
||||
self.db.extendLoanDuration(signature, extendDate)
|
||||
self.userMedia = []
|
||||
self.UserMediaTable.setRowCount(0)
|
||||
@@ -111,7 +113,7 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
self.UserMediaTable.setRowCount(0)
|
||||
for loan in self.userMedia:
|
||||
#print("looping loans")
|
||||
# print("looping loans")
|
||||
fielddata = eval(f"loan.{searchfield}")
|
||||
if isinstance(fielddata, str):
|
||||
fielddata = fielddata.lower()
|
||||
@@ -161,12 +163,12 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
if self.radio_currentlyLoaned.isChecked()
|
||||
else "overdue"
|
||||
)
|
||||
#print(mode)
|
||||
# print(mode)
|
||||
if self.userMedia == []:
|
||||
books = self.db.getAllMedia(self.user_id)
|
||||
for book in books:
|
||||
self.userMedia.append(book)
|
||||
#print(self.userMedia)
|
||||
# print(self.userMedia)
|
||||
self.UserMediaTable.setRowCount(0)
|
||||
|
||||
for book in self.userMedia:
|
||||
@@ -186,7 +188,8 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
continue
|
||||
|
||||
self.addBookToTable(book)
|
||||
#print(book.title)
|
||||
# print(book.title)
|
||||
|
||||
def addBookToTable(self, book):
|
||||
self.UserMediaTable.insertRow(0)
|
||||
# item0 = isbn
|
||||
|
||||
@@ -7,13 +7,14 @@ from PyQt6.QtCore import QDate
|
||||
from src import config
|
||||
import datetime
|
||||
|
||||
|
||||
# query all loans that happened in the last 7 days
|
||||
def generate_report():
|
||||
'''Generate an excel report for all actions that happened in the last seven days
|
||||
"""Generate an excel report for all actions that happened in the last seven days
|
||||
|
||||
Returns:
|
||||
str: a string represeting the generated table
|
||||
'''
|
||||
"""
|
||||
db = Database()
|
||||
path = db.db_path
|
||||
year = datetime.datetime.now().year
|
||||
@@ -23,7 +24,7 @@ def generate_report():
|
||||
report_path = os.path.join(config.report.path, f"report_{year}_{week}.tsv")
|
||||
day = QDate.currentDate().addDays(-7).toString("yyyy-MM-dd")
|
||||
query = f"""SELECT * FROM loans WHERE loan_date >= '{day}';"""
|
||||
#print(query)
|
||||
# print(query)
|
||||
|
||||
colnames = ["UserId", "Title", "Action", "Datum"]
|
||||
table = PrettyTable(colnames)
|
||||
|
||||
@@ -3,18 +3,23 @@ from wsgiref.simple_server import make_server
|
||||
from src import docport, log
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def website():
|
||||
config = Configurator()
|
||||
|
||||
# Set up static file serving from the 'site/' directory
|
||||
config.add_static_view(name='/', path=os.path.join(os.getcwd(), 'site'), cache_max_age=3600)
|
||||
config.add_static_view(
|
||||
name="/", path=os.path.join(os.getcwd(), "site"), cache_max_age=3600
|
||||
)
|
||||
|
||||
app = config.make_wsgi_app()
|
||||
return app
|
||||
|
||||
|
||||
def launch_documentation():
|
||||
app = website()
|
||||
server = make_server('localhost', 6543, app)
|
||||
server = make_server("localhost", 6543, app)
|
||||
log.info("Serving MkDocs documentation on http://0.0.0.0:{}".format(docport))
|
||||
with open(os.devnull, "w") as devnull:
|
||||
old_stdout = sys.stdout
|
||||
@@ -27,6 +32,6 @@ def launch_documentation():
|
||||
sys.stdout = old_stdout
|
||||
sys.stderr = old_stderr
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
0
src/utils/filepicker.py
Normal file
0
src/utils/filepicker.py
Normal file
@@ -58,7 +58,7 @@ class ReportThread(QThread):
|
||||
# # wruitng the table to a file
|
||||
if self.format == "tsv":
|
||||
table = table.get_csv_string()
|
||||
tsv_table = table.replace(",", "\t")#.replace("Rückgabe", "Rückgabe")
|
||||
tsv_table = table.replace(",", "\t") # .replace("Rückgabe", "Rückgabe")
|
||||
# write the file
|
||||
with open("report.tsv", "w") as f:
|
||||
f.write(tsv_table)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# import qdate
|
||||
from PyQt6 import QtCore
|
||||
from src import log
|
||||
|
||||
|
||||
def stringToDate(date: str) -> QtCore.QDate:
|
||||
"""Takes an input string and returns a QDate object.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user