update deps, change config to restore changes, color overdue red in main, in loan color based on state
This commit is contained in:
@@ -2,8 +2,10 @@ import sys
|
||||
import atexit
|
||||
import datetime
|
||||
import webbrowser
|
||||
from src import config, __email__, docport, log
|
||||
from src.logic import Database, Catalogue, Backup
|
||||
from PyQt6 import QtCore, QtWidgets
|
||||
from omegaconf import OmegaConf
|
||||
from src import config, __email__, docport, log, restore_config
|
||||
from src.logic import Database, Catalogue, Backup, DocumentationThread
|
||||
from src.utils import stringToDate, Icon
|
||||
from src.utils.createReport import generate_report
|
||||
from src.schemas import Book
|
||||
@@ -16,9 +18,7 @@ from .settings import Settings
|
||||
from .newBook import NewBook
|
||||
from .loans import LoanWindow
|
||||
from .reportUi import ReportUi
|
||||
from PyQt6 import QtCore, QtWidgets
|
||||
from omegaconf import OmegaConf
|
||||
from src.logic.documentation_thread import DocumentationThread
|
||||
|
||||
backup = Backup()
|
||||
cat = Catalogue()
|
||||
|
||||
@@ -327,6 +327,12 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
retdate = self.db.selectClosestReturnDate(self.activeUser.id)
|
||||
if retdate:
|
||||
date = stringToDate(retdate).toString("dd.MM.yyyy")
|
||||
today = QtCore.QDate.currentDate().toString("yyyy-MM-dd")
|
||||
# if retdate is in past, set nextReturnDate color to red
|
||||
if retdate < today:
|
||||
self.nextReturnDate.setStyleSheet("color: red")
|
||||
else:
|
||||
self.nextReturnDate.setStyleSheet("color: black")
|
||||
self.nextReturnDate.setText(date)
|
||||
self.nextReturnDate.show()
|
||||
self.label_7.show()
|
||||
@@ -516,13 +522,16 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
dialog.setText(message)
|
||||
dialog.exec()
|
||||
def exit_handler():
|
||||
log.info("Exiting, creating backup")
|
||||
log.info(
|
||||
"Exiting, creating backup, renaming inactive users, creating report if day matches"
|
||||
)
|
||||
restore_config()
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
#print(backup.backup)
|
||||
# generate report if monday
|
||||
if datetime.datetime.now().weekday() == config.report.report_day:
|
||||
log.info("Generating Report")
|
||||
generate_report()
|
||||
log.info("Generated Report")
|
||||
Database().renameInactiveUsers()
|
||||
if config.database.do_backup:
|
||||
state = backup.createBackup()
|
||||
@@ -550,11 +559,35 @@ def exit_handler():
|
||||
dialog.setWindowTitle("Backup nicht möglich")
|
||||
dialog.setText("Backup konnte nicht erstellt werden\nGrund: {}".format(reason))
|
||||
dialog.exec()
|
||||
log.info("Exiting")
|
||||
sys.exit()
|
||||
def launch(*argv):
|
||||
options = sys.argv
|
||||
if argv:
|
||||
options += [arg for arg in argv]
|
||||
options = [arg for arg in options if arg.startswith("--")]
|
||||
options += [arg for arg in options if arg.startswith("--")]
|
||||
# add options to sys.argv
|
||||
# print(options)
|
||||
# print("Launching Main UI")
|
||||
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
|
||||
if SYSTEM_LANGUAGE:
|
||||
translator = QtCore.QTranslator()
|
||||
# do not use ascii encoding
|
||||
translator.load(f"qt_{SYSTEM_LANGUAGE}", "translations")
|
||||
translator.load("app.qm", "translations")
|
||||
app.installTranslator(translator)
|
||||
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user