checkpoint prior to class
This commit is contained in:
@@ -8,8 +8,10 @@ from email.message import EmailMessage
|
||||
from html.parser import HTMLParser
|
||||
from io import StringIO
|
||||
|
||||
from PyQt6.QtCore import QResource, QSize, Qt, pyqtSlot
|
||||
import css_inline
|
||||
from PyQt6.QtCore import QResource, QSize, Qt, QUrl, pyqtSlot
|
||||
from PyQt6.QtGui import QStandardItem, QStandardItemModel
|
||||
from PyQt6.QtMultimedia import QMediaDevices, QSoundEffect
|
||||
from PyQt6.QtSql import QSqlQuery, QSqlQueryModel
|
||||
from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QStyledItemDelegate
|
||||
|
||||
@@ -106,6 +108,7 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
SectionSequenceRole = Qt.ItemDataRole.UserRole + 1
|
||||
BookIdRole = Qt.ItemDataRole.UserRole + 2
|
||||
person_id = 0
|
||||
inliner = css_inline.CSSInliner(keep_style_tags=True, keep_link_tags=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.person_id = kwargs.pop("person_id", 0)
|
||||
@@ -202,27 +205,41 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
|
||||
@pyqtSlot()
|
||||
def senditAction(self) -> None:
|
||||
html = "<!DOCTYPE html>\n<html><head><title>Hello</title>\n"
|
||||
title = self.sessionCombo.currentText()
|
||||
html = f"<!DOCTYPE html>\n<html><head><title>{title}</title>\n"
|
||||
html += (
|
||||
'<style type="text/css">\n'
|
||||
+ QResource(":email.css").data().decode("utf-8")
|
||||
+ "</style>\n"
|
||||
)
|
||||
html += "</head><body>\n"
|
||||
html += f"<h1>{title}</h1>\n"
|
||||
html += self.makeDefinitions()
|
||||
html += self.makeText()
|
||||
html += "</body>\n</html>\n"
|
||||
|
||||
if self.sender() == self.printBtn:
|
||||
dev = None
|
||||
for output in QMediaDevices.audioOutputs():
|
||||
if output.id().data().decode("UTF-8") == "virt-input":
|
||||
dev = output
|
||||
break
|
||||
self.alert = QSoundEffect()
|
||||
if dev:
|
||||
self.alert.setAudioDevice(dev)
|
||||
self.alert.setSource(QUrl.fromLocalFile("ui/beep.wav"))
|
||||
self.alert.setLoopCount(1)
|
||||
self.alert.play()
|
||||
print(html)
|
||||
return
|
||||
msg = EmailMessage(policy=policy.default)
|
||||
start = datetime.fromisoformat(self.sessionCombo.currentText())
|
||||
msg["Subject"] = f"TT English, Session: {start.date().isoformat()}"
|
||||
msg["From"] = "Christopher T. Johnson <cjohnson@troglodite.com>"
|
||||
msg["To"] = self.emailEdit.text().strip()
|
||||
# msg["To"] = self.emailEdit.text().strip()
|
||||
msg["To"] = "cjohnson@troglodite.com"
|
||||
msg.set_content("There is a html message you should read")
|
||||
msg.add_alternative(html, subtype="html")
|
||||
msg.add_alternative(self.inliner.inline(html), subtype="html")
|
||||
server = smtplib.SMTP(secrets.SMTP_HOST, secrets.SMTP_PORT)
|
||||
server.set_debuglevel(1)
|
||||
if secrets.SMTP_STARTTLS:
|
||||
|
||||
Reference in New Issue
Block a user