UI: changes to new edition UIs
This commit is contained in:
@@ -4,9 +4,8 @@ import loguru
|
|||||||
from PySide6 import QtCore, QtWidgets
|
from PySide6 import QtCore, QtWidgets
|
||||||
|
|
||||||
from src import LOG_DIR
|
from src import LOG_DIR
|
||||||
from src.backend.database import Database
|
|
||||||
from src.backend.catalogue import Catalogue
|
from src.backend.catalogue import Catalogue
|
||||||
|
from src.backend.database import Database
|
||||||
from src.ui.dialogs.mail import Mail_Dialog
|
from src.ui.dialogs.mail import Mail_Dialog
|
||||||
|
|
||||||
from .dialog_sources.order_neweditions_ui import Ui_Dialog
|
from .dialog_sources.order_neweditions_ui import Ui_Dialog
|
||||||
@@ -33,8 +32,9 @@ class NewEditionDialog(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
def populateTable(self):
|
def populateTable(self):
|
||||||
for book in self.books:
|
for book in self.books:
|
||||||
signature = book.signature
|
signature = book.signature
|
||||||
if signature is None or signature == "None":
|
# if signature is None or signature == "None" and book.ppn is not None:
|
||||||
signature = self.catalogue.get_signature(book.ppn)
|
# signature = self.catalogue.get_signature(f"kid:{book.ppn}")
|
||||||
|
# book.signature = signature
|
||||||
link_label = QtWidgets.QLabel()
|
link_label = QtWidgets.QLabel()
|
||||||
link = (
|
link = (
|
||||||
book.link
|
book.link
|
||||||
@@ -52,8 +52,10 @@ class NewEditionDialog(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self.tableWidget.insertRow(0)
|
self.tableWidget.insertRow(0)
|
||||||
# first column is checkbox for ordering
|
# first column is checkbox for ordering
|
||||||
checkbox = QtWidgets.QCheckBox()
|
checkbox = QtWidgets.QCheckBox()
|
||||||
|
checked = True if not book.signature else False
|
||||||
checkbox.setChecked(False)
|
if book.library_location is not None:
|
||||||
|
checked = True if "hb" in book.library_location else checked
|
||||||
|
checkbox.setChecked(checked)
|
||||||
self.tableWidget.setCellWidget(0, 0, checkbox)
|
self.tableWidget.setCellWidget(0, 0, checkbox)
|
||||||
self.tableWidget.setItem(
|
self.tableWidget.setItem(
|
||||||
0,
|
0,
|
||||||
@@ -63,12 +65,17 @@ class NewEditionDialog(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.tableWidget.setItem(0, 2, QtWidgets.QTableWidgetItem(book.title))
|
self.tableWidget.setItem(0, 2, QtWidgets.QTableWidgetItem(book.title))
|
||||||
self.tableWidget.setItem(
|
isbn = (
|
||||||
0, 3, QtWidgets.QTableWidgetItem(",".join(book.isbn))
|
book.isbn[0]
|
||||||
|
if isinstance(book.isbn, list) and len(book.isbn) > 0
|
||||||
|
else book.isbn
|
||||||
)
|
)
|
||||||
|
self.tableWidget.setItem(0, 3, QtWidgets.QTableWidgetItem(isbn))
|
||||||
self.tableWidget.setItem(0, 4, QtWidgets.QTableWidgetItem(book.author))
|
self.tableWidget.setItem(0, 4, QtWidgets.QTableWidgetItem(book.author))
|
||||||
self.tableWidget.setItem(0, 5, QtWidgets.QTableWidgetItem(book.edition))
|
self.tableWidget.setItem(0, 5, QtWidgets.QTableWidgetItem(book.edition))
|
||||||
self.tableWidget.setItem(0, 6, QtWidgets.QTableWidgetItem(book.library_location))
|
self.tableWidget.setItem(
|
||||||
|
0, 6, QtWidgets.QTableWidgetItem(book.library_location)
|
||||||
|
)
|
||||||
self.tableWidget.setCellWidget(0, 7, link_label)
|
self.tableWidget.setCellWidget(0, 7, link_label)
|
||||||
|
|
||||||
def orderBooks(self):
|
def orderBooks(self):
|
||||||
@@ -82,11 +89,12 @@ class NewEditionDialog(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
if book.link != "SWB"
|
if book.link != "SWB"
|
||||||
else f"https://www.lehmanns.de/search/quick?mediatype_id=&q={book.isbn[0]}"
|
else f"https://www.lehmanns.de/search/quick?mediatype_id=&q={book.isbn[0]}"
|
||||||
)
|
)
|
||||||
print(f"Bestelle Neuauflage für {book.title} ({book.edition})")
|
# print(f"Bestelle Neuauflage für {book.title} ({book.edition})")
|
||||||
|
book.isbn = [book.isbn] if isinstance(book.isbn, str) else book.isbn
|
||||||
ordered_books.append(book)
|
ordered_books.append(book)
|
||||||
# Process ordered_books as needed
|
# Process ordered_books as needed
|
||||||
# editionId = self.db.getNewEditionId(book)
|
editionId = self.db.getNewEditionId(book)
|
||||||
# self.db.setOrdered(editionId)
|
self.db.setOrdered(editionId)
|
||||||
|
|
||||||
self.mail = Mail_Dialog(
|
self.mail = Mail_Dialog(
|
||||||
app_id=self.mail_data.get("app_nr"),
|
app_id=self.mail_data.get("app_nr"),
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ from .widget_sources.new_edition_check_ui import Ui_Dialog as Ui_NewEditionCheck
|
|||||||
|
|
||||||
cat = Catalogue()
|
cat = Catalogue()
|
||||||
|
|
||||||
|
LEHMANNS_LINK = "https://www.lehmanns.de/search/quick?mediatype_id=&q={}"
|
||||||
|
|
||||||
|
|
||||||
class NewEditionCheckSelector(QtWidgets.QDialog, Ui_NewEditionCheckSelector):
|
class NewEditionCheckSelector(QtWidgets.QDialog, Ui_NewEditionCheckSelector):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
@@ -55,41 +57,82 @@ class NewEditionCheckFoundResult(QtWidgets.QDialog, Ui_NewEditionCheckFoundResul
|
|||||||
self.line_pages.setText(self.book.pages if self.book.pages 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 "")
|
self.line_author.setText(self.book.author if self.book.author else "")
|
||||||
link = self.book.link if self.book.link else ""
|
link = self.book.link if self.book.link else ""
|
||||||
|
text = "Lehmanns" if self.book.link else "Kein Link gefunden"
|
||||||
if self.book.link != "SWB":
|
if self.book.link != "SWB":
|
||||||
link = f"<a href='{link}'>Lehmanns</a>"
|
link = f"<a href='{link}'>{text}</a>"
|
||||||
self.line_source.setText(link)
|
self.line_source.setText(link)
|
||||||
self.line_source.setOpenExternalLinks(True)
|
self.line_source.setOpenExternalLinks(True)
|
||||||
self.line_source.setTextFormat(Qt.TextFormat.RichText)
|
self.line_source.setTextFormat(Qt.TextFormat.RichText)
|
||||||
self.line_source.setTextInteractionFlags(
|
self.line_source.setTextInteractionFlags(
|
||||||
Qt.TextInteractionFlag.TextBrowserInteraction
|
Qt.TextInteractionFlag.TextBrowserInteraction
|
||||||
)
|
)
|
||||||
|
self.line_isbn.textChanged.connect(self.update_book)
|
||||||
|
self.line_author.textChanged.connect(self.update_book)
|
||||||
|
self.line_title.textChanged.connect(self.update_book)
|
||||||
|
self.line_ppn.textChanged.connect(self.update_book)
|
||||||
|
self.line_signature.textChanged.connect(self.update_book)
|
||||||
|
self.line_edition.textChanged.connect(self.update_book)
|
||||||
|
self.line_publisher.textChanged.connect(self.update_book)
|
||||||
|
self.line_year.textChanged.connect(self.update_book)
|
||||||
|
self.line_pages.textChanged.connect(self.update_book)
|
||||||
|
|
||||||
self.line_isbn.setText(
|
self.line_isbn.setText(
|
||||||
", ".join(self.book.isbn)
|
", ".join(self.book.isbn)
|
||||||
if isinstance(self.book.isbn, list)
|
if isinstance(self.book.isbn, list)
|
||||||
else self.book.isbn
|
else self.book.isbn
|
||||||
)
|
)
|
||||||
if (
|
if self.book.signature is not None and self.book.signature != "":
|
||||||
self.book.link == "SWB"
|
|
||||||
and self.book.signature is not None
|
|
||||||
and self.book.signature != ""
|
|
||||||
):
|
|
||||||
self.in_library.setText(
|
self.in_library.setText(
|
||||||
"Diese Neuauflage ist bereits in der Bibliothek vorhanden."
|
f"Diese Neuauflage ist bereits in der Bibliothek vorhanden.\nStandort: {self.book.library_location}"
|
||||||
)
|
)
|
||||||
self.book.link == f"https://www.lehmanns.de/search/quick?mediatype_id=&q={self.book.isbn[0]}"
|
isbn = (
|
||||||
|
self.book.isbn[0]
|
||||||
|
if isinstance(self.book.isbn, list) and len(self.book.isbn) > 0
|
||||||
|
else self.book.title
|
||||||
|
)
|
||||||
|
self.book.link = LEHMANNS_LINK.format(self.line_isbn.text())
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.book.link == "SWB"
|
self.book.signature is not None
|
||||||
and self.book.signature is not None
|
|
||||||
and self.book.signature != ""
|
and self.book.signature != ""
|
||||||
and self.book.library_location not in (0, "0", None)
|
and self.book.library_location not in (0, "0", None)
|
||||||
):
|
):
|
||||||
self.in_library.setText(
|
self.in_library.setText(
|
||||||
f"Diese Neuauflage ist bereits in der Bibliothek vorhanden, und an diesem Standort: {self.book.library_location}."
|
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]}"
|
isbn = (
|
||||||
|
str(self.book.isbn[0])
|
||||||
|
if isinstance(self.book.isbn, list)
|
||||||
|
else str(self.book.isbn)
|
||||||
|
)
|
||||||
|
self.book.link = LEHMANNS_LINK.format(isbn)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def update_book(self):
|
||||||
|
print("update book")
|
||||||
|
# for each line edit, get the value and assign it to the book on the corresponding attribute
|
||||||
|
for line_edit, attr in [
|
||||||
|
(self.line_ppn, "ppn"),
|
||||||
|
(self.line_title, "title"),
|
||||||
|
(self.line_signature, "signature"),
|
||||||
|
(self.line_edition, "edition"),
|
||||||
|
(self.line_publisher, "publisher"),
|
||||||
|
(self.line_year, "year"),
|
||||||
|
(self.line_pages, "pages"),
|
||||||
|
(self.line_author, "author"),
|
||||||
|
(self.line_isbn, "isbn"),
|
||||||
|
]:
|
||||||
|
value = line_edit.text()
|
||||||
|
if value == "":
|
||||||
|
value = None
|
||||||
|
setattr(self.book, attr, value)
|
||||||
|
print("set", attr, "to", value)
|
||||||
|
if attr == "isbn" and value is not None:
|
||||||
|
self.line_source.setText(
|
||||||
|
f"<a href='{LEHMANNS_LINK.format(self.line_isbn.text())}'>Lehmanns</a>"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NewEditionCheckBook(QtWidgets.QDialog, Ui_NewEditionCheckBook):
|
class NewEditionCheckBook(QtWidgets.QDialog, Ui_NewEditionCheckBook):
|
||||||
def __init__(self, book: BookData, responses: List[BookData], parent=None):
|
def __init__(self, book: BookData, responses: List[BookData], parent=None):
|
||||||
@@ -124,6 +167,27 @@ class NewEditionCheckBook(QtWidgets.QDialog, Ui_NewEditionCheckBook):
|
|||||||
NewEditionCheckFoundResult(parent=self, book=response)
|
NewEditionCheckFoundResult(parent=self, book=response)
|
||||||
)
|
)
|
||||||
self.label_book_index.setText(f"1 / {self.stackedWidget.count()}")
|
self.label_book_index.setText(f"1 / {self.stackedWidget.count()}")
|
||||||
|
link = f"<a href='{self.book.link}'>Katalog</a>"
|
||||||
|
self.label_source_local.setText(link)
|
||||||
|
self.label_source_local.setOpenExternalLinks(True)
|
||||||
|
self.label_source_local.setTextFormat(Qt.TextFormat.RichText)
|
||||||
|
self.label_source_local.setTextInteractionFlags(
|
||||||
|
Qt.TextInteractionFlag.TextBrowserInteraction
|
||||||
|
)
|
||||||
|
|
||||||
|
isbn = (
|
||||||
|
str(self.book.isbn[0])
|
||||||
|
if isinstance(self.book.isbn, list) and len(self.book.isbn) > 0
|
||||||
|
else f"{self.book.title}+{self.book.author}"
|
||||||
|
)
|
||||||
|
self.label_source_external.setText(
|
||||||
|
f"<a href='{LEHMANNS_LINK.format(isbn)}'>Lehmanns</a>"
|
||||||
|
)
|
||||||
|
self.label_source_external.setOpenExternalLinks(True)
|
||||||
|
self.label_source_external.setTextFormat(Qt.TextFormat.RichText)
|
||||||
|
self.label_source_external.setTextInteractionFlags(
|
||||||
|
Qt.TextInteractionFlag.TextBrowserInteraction
|
||||||
|
)
|
||||||
self.btn_next.clicked.connect(self.next)
|
self.btn_next.clicked.connect(self.next)
|
||||||
self.btn_prev.clicked.connect(self.previous)
|
self.btn_prev.clicked.connect(self.previous)
|
||||||
if self.stackedWidget.count() <= 1:
|
if self.stackedWidget.count() <= 1:
|
||||||
@@ -216,3 +280,10 @@ class NewEditionChecker(QtWidgets.QDialog, Ui_NewEditionCheck):
|
|||||||
super().accept()
|
super().accept()
|
||||||
# print("accepted", len(accepted_books), "new editions")
|
# print("accepted", len(accepted_books), "new editions")
|
||||||
self.accepted_books = accepted_books
|
self.accepted_books = accepted_books
|
||||||
|
|
||||||
|
|
||||||
|
def launch(results: List[tuple[BookData, List[BookData]]]):
|
||||||
|
app = QtWidgets.QApplication([])
|
||||||
|
widget = NewEditionChecker(results)
|
||||||
|
widget.show()
|
||||||
|
app.exec()
|
||||||
|
|||||||
@@ -149,6 +149,37 @@
|
|||||||
<item row="8" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="QLineEdit" name="line_isbn"/>
|
<widget class="QLineEdit" name="line_isbn"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_source_local">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_source_external">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QLabel" name="label_12">
|
||||||
|
<property name="text">
|
||||||
|
<string>Quelle</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
|
|||||||
@@ -147,6 +147,28 @@ class Ui_Dialog(object):
|
|||||||
|
|
||||||
self.formLayout_2.setWidget(8, QFormLayout.ItemRole.FieldRole, self.line_isbn)
|
self.formLayout_2.setWidget(8, QFormLayout.ItemRole.FieldRole, self.line_isbn)
|
||||||
|
|
||||||
|
self.horizontalLayout_3 = QHBoxLayout()
|
||||||
|
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
|
||||||
|
self.label_source_local = QLabel(Dialog)
|
||||||
|
self.label_source_local.setObjectName(u"label_source_local")
|
||||||
|
self.label_source_local.setOpenExternalLinks(True)
|
||||||
|
|
||||||
|
self.horizontalLayout_3.addWidget(self.label_source_local)
|
||||||
|
|
||||||
|
self.label_source_external = QLabel(Dialog)
|
||||||
|
self.label_source_external.setObjectName(u"label_source_external")
|
||||||
|
self.label_source_external.setOpenExternalLinks(True)
|
||||||
|
|
||||||
|
self.horizontalLayout_3.addWidget(self.label_source_external)
|
||||||
|
|
||||||
|
|
||||||
|
self.formLayout_2.setLayout(9, QFormLayout.ItemRole.FieldRole, self.horizontalLayout_3)
|
||||||
|
|
||||||
|
self.label_12 = QLabel(Dialog)
|
||||||
|
self.label_12.setObjectName(u"label_12")
|
||||||
|
|
||||||
|
self.formLayout_2.setWidget(9, QFormLayout.ItemRole.LabelRole, self.label_12)
|
||||||
|
|
||||||
|
|
||||||
self.gridLayout.addLayout(self.formLayout_2, 1, 0, 1, 1)
|
self.gridLayout.addLayout(self.formLayout_2, 1, 0, 1, 1)
|
||||||
|
|
||||||
@@ -196,6 +218,9 @@ class Ui_Dialog(object):
|
|||||||
self.label_7.setText(QCoreApplication.translate("Dialog", u"Seiten", None))
|
self.label_7.setText(QCoreApplication.translate("Dialog", u"Seiten", None))
|
||||||
self.label_8.setText(QCoreApplication.translate("Dialog", u"Autor", None))
|
self.label_8.setText(QCoreApplication.translate("Dialog", u"Autor", None))
|
||||||
self.label_11.setText(QCoreApplication.translate("Dialog", u"ISBN", None))
|
self.label_11.setText(QCoreApplication.translate("Dialog", u"ISBN", None))
|
||||||
|
self.label_source_local.setText("")
|
||||||
|
self.label_source_external.setText("")
|
||||||
|
self.label_12.setText(QCoreApplication.translate("Dialog", u"Quelle", None))
|
||||||
self.btn_prev.setText(QCoreApplication.translate("Dialog", u"Previous", None))
|
self.btn_prev.setText(QCoreApplication.translate("Dialog", u"Previous", None))
|
||||||
self.btn_next.setText(QCoreApplication.translate("Dialog", u"Next", None))
|
self.btn_next.setText(QCoreApplication.translate("Dialog", u"Next", None))
|
||||||
# retranslateUi
|
# retranslateUi
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>312</height>
|
<height>346</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -113,12 +113,21 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="QLabel" name="line_source">
|
<widget class="QLabel" name="line_source">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::PlainText</enum>
|
<enum>Qt::PlainText</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::LinksAccessibleByMouse</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="8" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Ui_Dialog(object):
|
|||||||
def setupUi(self, Dialog):
|
def setupUi(self, Dialog):
|
||||||
if not Dialog.objectName():
|
if not Dialog.objectName():
|
||||||
Dialog.setObjectName(u"Dialog")
|
Dialog.setObjectName(u"Dialog")
|
||||||
Dialog.resize(400, 312)
|
Dialog.resize(400, 346)
|
||||||
self.formLayout = QFormLayout(Dialog)
|
self.formLayout = QFormLayout(Dialog)
|
||||||
self.formLayout.setObjectName(u"formLayout")
|
self.formLayout.setObjectName(u"formLayout")
|
||||||
self.label = QLabel(Dialog)
|
self.label = QLabel(Dialog)
|
||||||
@@ -112,7 +112,10 @@ class Ui_Dialog(object):
|
|||||||
|
|
||||||
self.line_source = QLabel(Dialog)
|
self.line_source = QLabel(Dialog)
|
||||||
self.line_source.setObjectName(u"line_source")
|
self.line_source.setObjectName(u"line_source")
|
||||||
|
self.line_source.setFocusPolicy(Qt.NoFocus)
|
||||||
self.line_source.setTextFormat(Qt.PlainText)
|
self.line_source.setTextFormat(Qt.PlainText)
|
||||||
|
self.line_source.setOpenExternalLinks(True)
|
||||||
|
self.line_source.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
|
||||||
|
|
||||||
self.formLayout.setWidget(10, QFormLayout.ItemRole.FieldRole, self.line_source)
|
self.formLayout.setWidget(10, QFormLayout.ItemRole.FieldRole, self.line_source)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user