refactor: reorganize imports and enhance Mail_Dialog to handle accepted_books
This commit is contained in:
@@ -1,23 +1,21 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import loguru
|
||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
|
|
||||||
from src import Icon, settings as config
|
from src import LOG_DIR, Icon
|
||||||
|
from src import settings as config
|
||||||
|
|
||||||
from .dialog_sources.Ui_mail_preview import Ui_eMailPreview as MailPreviewDialog
|
from .dialog_sources.Ui_mail_preview import Ui_eMailPreview as MailPreviewDialog
|
||||||
from .mailTemplate import MailTemplateDialog
|
from .mailTemplate import MailTemplateDialog
|
||||||
import loguru
|
|
||||||
import sys
|
|
||||||
from src import LOG_DIR
|
|
||||||
log = loguru.logger
|
log = loguru.logger
|
||||||
log.remove()
|
log.remove()
|
||||||
log.add(sys.stdout, level="INFO")
|
log.add(sys.stdout, level="INFO")
|
||||||
log.add(f"{LOG_DIR}/application.log", rotation="1 MB", retention="10 days")
|
log.add(f"{LOG_DIR}/application.log", rotation="1 MB", retention="10 days")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
empty_signature = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
empty_signature = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
|
|
||||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style
|
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style
|
||||||
@@ -47,6 +45,7 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
|||||||
app_subject,
|
app_subject,
|
||||||
prof_name,
|
prof_name,
|
||||||
prof_mail,
|
prof_mail,
|
||||||
|
accepted_books=None,
|
||||||
parent=None,
|
parent=None,
|
||||||
default_mail="Information zum Semesterapparat",
|
default_mail="Information zum Semesterapparat",
|
||||||
):
|
):
|
||||||
@@ -58,6 +57,7 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
|||||||
self.appname = app_name
|
self.appname = app_name
|
||||||
self.subject = app_subject
|
self.subject = app_subject
|
||||||
self.profname = prof_name
|
self.profname = prof_name
|
||||||
|
self.books = accepted_books if accepted_books is not None else []
|
||||||
self.mail_data = ""
|
self.mail_data = ""
|
||||||
self.signature = self.determine_signature()
|
self.signature = self.determine_signature()
|
||||||
self.prof_mail = prof_mail
|
self.prof_mail = prof_mail
|
||||||
@@ -148,6 +148,14 @@ Tel.: 0761/682-778 | 07617682-545"""
|
|||||||
AppSubject=self.subject,
|
AppSubject=self.subject,
|
||||||
greeting=self.get_greeting(),
|
greeting=self.get_greeting(),
|
||||||
signature=self.signature,
|
signature=self.signature,
|
||||||
|
newEditions="<br>".join(
|
||||||
|
[
|
||||||
|
f"{book.title} von {book.author} (ISBN: {book.isbn}, Auflage: {book.edition}, In Bibliothek: {'ja' if getattr(book, 'library_location', 1) == 1 else 'nein'})"
|
||||||
|
for book in self.books
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if self.books
|
||||||
|
else "keine neuen Auflagen gefunden",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.mail_body.setHtml(mail_html)
|
self.mail_body.setHtml(mail_html)
|
||||||
|
|||||||
Reference in New Issue
Block a user