UI: refactor mail template dialog for plaintext handling, improve logging, and update UI elements
This commit is contained in:
@@ -3,6 +3,8 @@ from typing import List
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from src import Icon
|
||||
from src.backend.catalogue import Catalogue
|
||||
from src.logic import BookData
|
||||
|
||||
from .widget_sources.new_edition_check_book_ui import (
|
||||
@@ -11,14 +13,20 @@ from .widget_sources.new_edition_check_book_ui import (
|
||||
from .widget_sources.new_edition_check_found_result_ui import (
|
||||
Ui_Dialog as Ui_NewEditionCheckFoundResult,
|
||||
)
|
||||
from .widget_sources.new_edition_check_selector_ui import (
|
||||
Ui_Dialog as Ui_NewEditionCheckSelector,
|
||||
)
|
||||
from .widget_sources.new_edition_check_ui import Ui_Dialog as Ui_NewEditionCheck
|
||||
from .widget_sources.new_edition_check_selector_ui import Ui_Dialog as Ui_NewEditionCheckSelector
|
||||
|
||||
cat = Catalogue()
|
||||
|
||||
|
||||
class NewEditionCheckSelector(QtWidgets.QDialog, Ui_NewEditionCheckSelector):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
self.setWindowTitle("Neuauflagen prüfen")
|
||||
self.setWindowIcon(Icon("confirm_type").icon)
|
||||
self.btn_apparat.clicked.connect(self.select_apparat)
|
||||
self.btn_prof.clicked.connect(self.select_professor)
|
||||
self.selection = None
|
||||
@@ -31,6 +39,7 @@ class NewEditionCheckSelector(QtWidgets.QDialog, Ui_NewEditionCheckSelector):
|
||||
self.selection = "professor"
|
||||
self.accept()
|
||||
|
||||
|
||||
class NewEditionCheckFoundResult(QtWidgets.QDialog, Ui_NewEditionCheckFoundResult):
|
||||
def __init__(self, book: BookData, parent=None):
|
||||
assert isinstance(book, BookData)
|
||||
@@ -44,6 +53,7 @@ class NewEditionCheckFoundResult(QtWidgets.QDialog, Ui_NewEditionCheckFoundResul
|
||||
self.line_publisher.setText(self.book.publisher if self.book.publisher else "")
|
||||
self.line_year.setText(self.book.year if self.book.year else "")
|
||||
self.line_pages.setText(self.book.pages if self.book.pages else "")
|
||||
self.line_author.setText(self.book.author if self.book.author else "")
|
||||
link = self.book.link if self.book.link else ""
|
||||
if self.book.link != "SWB":
|
||||
link = f"<a href='{link}'>Lehmanns</a>"
|
||||
@@ -66,7 +76,17 @@ class NewEditionCheckFoundResult(QtWidgets.QDialog, Ui_NewEditionCheckFoundResul
|
||||
self.in_library.setText(
|
||||
"Diese Neuauflage ist bereits in der Bibliothek vorhanden."
|
||||
)
|
||||
self.book.library_location = 1
|
||||
self.book.link == f"https://www.lehmanns.de/search/quick?mediatype_id=&q={self.book.isbn[0]}"
|
||||
if (
|
||||
self.book.link == "SWB"
|
||||
and self.book.signature is not None
|
||||
and self.book.signature != ""
|
||||
and self.book.library_location not in (0, "0", None)
|
||||
):
|
||||
self.in_library.setText(
|
||||
f"Diese Neuauflage ist bereits in der Bibliothek vorhanden, und an diesem Standort: {self.book.library_location}."
|
||||
)
|
||||
f"https://www.lehmanns.de/search/quick?mediatype_id=&q={self.book.isbn[0]}"
|
||||
|
||||
pass
|
||||
|
||||
@@ -78,7 +98,10 @@ class NewEditionCheckBook(QtWidgets.QDialog, Ui_NewEditionCheckBook):
|
||||
self.book = book
|
||||
self.accepted_books = []
|
||||
self.responses = responses
|
||||
self.line_author.setText(self.book.author)
|
||||
author = self.book.author if self.book.author else cat.get_author(self.book.ppn)
|
||||
if self.book.author is None and author is not None:
|
||||
self.book.author = author
|
||||
self.line_author.setText(author if author else "")
|
||||
self.line_title.setText(self.book.title)
|
||||
self.line_ppn.setText(self.book.ppn if self.book.ppn else "")
|
||||
self.line_signature.setText(self.book.signature if self.book.signature else "")
|
||||
@@ -103,6 +126,9 @@ class NewEditionCheckBook(QtWidgets.QDialog, Ui_NewEditionCheckBook):
|
||||
self.label_book_index.setText(f"1 / {self.stackedWidget.count()}")
|
||||
self.btn_next.clicked.connect(self.next)
|
||||
self.btn_prev.clicked.connect(self.previous)
|
||||
if self.stackedWidget.count() <= 1:
|
||||
self.btn_next.hide()
|
||||
self.btn_prev.hide()
|
||||
|
||||
def next(self):
|
||||
index = self.stackedWidget.currentIndex()
|
||||
@@ -110,6 +136,7 @@ class NewEditionCheckBook(QtWidgets.QDialog, Ui_NewEditionCheckBook):
|
||||
index += 1
|
||||
self.stackedWidget.setCurrentIndex(index)
|
||||
self.label_book_index.setText(f"{index + 1} / {self.stackedWidget.count()}")
|
||||
self.btn_prev.show()
|
||||
if index == self.stackedWidget.count() - 1:
|
||||
self.btn_next.hide()
|
||||
|
||||
@@ -119,6 +146,9 @@ class NewEditionCheckBook(QtWidgets.QDialog, Ui_NewEditionCheckBook):
|
||||
index -= 1
|
||||
self.stackedWidget.setCurrentIndex(index)
|
||||
self.label_book_index.setText(f"{index + 1} / {self.stackedWidget.count()}")
|
||||
self.btn_next.show()
|
||||
if index == 0:
|
||||
self.btn_prev.hide()
|
||||
if index < self.stackedWidget.count() - 1:
|
||||
self.btn_next.show()
|
||||
|
||||
@@ -130,7 +160,8 @@ class NewEditionChecker(QtWidgets.QDialog, Ui_NewEditionCheck):
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
self.results = results
|
||||
self.setWindowTitle("Prüfung auf Neuauflagen")
|
||||
self.setWindowIcon(Icon("results").icon)
|
||||
self.setWindowTitle(f"Neuauflagen prüfen ({len(self.results)})")
|
||||
# remove pages from stacked widget
|
||||
for _ in range(self.stackedWidget.count()):
|
||||
widget = self.stackedWidget.widget(0)
|
||||
@@ -138,6 +169,7 @@ class NewEditionChecker(QtWidgets.QDialog, Ui_NewEditionCheck):
|
||||
widget.deleteLater()
|
||||
for resultset in self.results:
|
||||
book, responses = resultset
|
||||
# print(book, responses)
|
||||
self.stackedWidget.addWidget(
|
||||
NewEditionCheckBook(parent=self, book=book, responses=responses)
|
||||
)
|
||||
@@ -170,7 +202,7 @@ class NewEditionChecker(QtWidgets.QDialog, Ui_NewEditionCheck):
|
||||
self.progressBar.setValue(index + 1)
|
||||
|
||||
def accept(self) -> None:
|
||||
print("finished checking for new editions")
|
||||
# print("finished checking for new editions")
|
||||
accepted_books = []
|
||||
for i in range(self.stackedWidget.count()):
|
||||
book_widget = self.stackedWidget.widget(i)
|
||||
@@ -179,7 +211,8 @@ class NewEditionChecker(QtWidgets.QDialog, Ui_NewEditionCheck):
|
||||
found_widget = book_widget.stackedWidget.widget(j)
|
||||
if isinstance(found_widget, NewEditionCheckFoundResult):
|
||||
if found_widget.checkBox.isChecked():
|
||||
found_widget.book.old_book = book_widget.book
|
||||
accepted_books.append(found_widget.book)
|
||||
super().accept()
|
||||
print("accepted", len(accepted_books), "new editions")
|
||||
# print("accepted", len(accepted_books), "new editions")
|
||||
self.accepted_books = accepted_books
|
||||
|
||||
Reference in New Issue
Block a user