fix some bugs, add mail template emit signal to update list
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from PyQt6 import QtWidgets
|
||||
|
||||
from src import Icon, settings as config
|
||||
from src import Icon, settings as config, logger
|
||||
|
||||
|
||||
from .dialog_sources.Ui_mail_preview import Ui_eMailPreview as MailPreviewDialog
|
||||
@@ -43,13 +43,7 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
||||
default_mail="Information zum Semesterapparat",
|
||||
):
|
||||
super().__init__(parent)
|
||||
self.setupUi(
|
||||
self,
|
||||
# app_id,
|
||||
# app_name,
|
||||
# app_subject,
|
||||
# prof_name,
|
||||
)
|
||||
self.setupUi(self)
|
||||
|
||||
logger.info("Setting up mail dialog")
|
||||
self.appid = app_id
|
||||
@@ -86,7 +80,9 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
||||
logger.info("Opening new template dialog")
|
||||
# TODO: implement new mail template dialog
|
||||
dialog = MailTemplateDialog()
|
||||
dialog.updateSignal.connect(self.load_mail_templates)
|
||||
dialog.exec()
|
||||
|
||||
pass
|
||||
|
||||
def determine_signature(self):
|
||||
@@ -103,6 +99,7 @@ Tel.: 0761/682-778 | 07617682-545"""
|
||||
logger.info("Loading mail templates")
|
||||
mail_templates = os.listdir("mail_vorlagen")
|
||||
logger.info(f"Mail templates: {mail_templates}")
|
||||
self.comboBox.clear()
|
||||
for template in mail_templates:
|
||||
self.comboBox.addItem(template)
|
||||
|
||||
@@ -146,12 +143,10 @@ Tel.: 0761/682-778 | 07617682-545"""
|
||||
)
|
||||
|
||||
self.mail_body.setHtml(mail_html)
|
||||
logger.info(f"Mail template set to {email_template}")
|
||||
|
||||
def createAndSendMail(self):
|
||||
logger.info("Sending mail")
|
||||
import smtplib
|
||||
import ssl
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
@@ -193,7 +188,13 @@ Tel.: 0761/682-778 | 07617682-545"""
|
||||
self.accept()
|
||||
|
||||
|
||||
def launch_gui(app_id="", app_name="", app_subject="", prof_name="", prof_mail=""):
|
||||
def launch_gui(
|
||||
app_id="1",
|
||||
app_name="Test",
|
||||
app_subject="Test",
|
||||
prof_name="Tester, 001",
|
||||
prof_mail="alexander.kirchner@ph-freiburg.de",
|
||||
):
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
dialog = Mail_Dialog(
|
||||
app_id=app_id,
|
||||
|
||||
Reference in New Issue
Block a user