changes to the email sending
This commit is contained in:
@@ -330,7 +330,7 @@ def generate_main_contract_pdf(
|
|||||||
|
|
||||||
pdf.set_x(start_x)
|
pdf.set_x(start_x)
|
||||||
pdf.cell(col_width, 5, f"{datetime.today().strftime('%d.%m.%Y')} ________________________", align="C", ln=False)
|
pdf.cell(col_width, 5, f"{datetime.today().strftime('%d.%m.%Y')} ________________________", align="C", ln=False)
|
||||||
pdf.cell(col_width, 5, f"{datetime.today().strftime('%d.%m.%Y')} ________________________", align="C", ln=True)
|
pdf.cell(col_width, 5, f"{datetime.today().strftime('%d.%m.%Y')} ___________ _____________", align="C", ln=True)
|
||||||
|
|
||||||
pdf.set_x(start_x)
|
pdf.set_x(start_x)
|
||||||
pdf.cell(col_width, 5, "(Verantwortlicher)", align="C", ln=False)
|
pdf.cell(col_width, 5, "(Verantwortlicher)", align="C", ln=False)
|
||||||
@@ -345,36 +345,35 @@ def send_accreditation_email(
|
|||||||
domain: str,
|
domain: str,
|
||||||
username: str,
|
username: str,
|
||||||
password: str,
|
password: str,
|
||||||
school_name: str,
|
invoice_pdf_path: str,
|
||||||
address: str,
|
contract_pdf_path: str,
|
||||||
price: str,
|
school_name: str = "[Name der Schule / des Auftraggebers]",
|
||||||
date: str,
|
address: str = "[Straße, Hausnummer] [PLZ, Ort]",
|
||||||
software_name: str,
|
price: str = "250,00",
|
||||||
invoice_pdf_path: str = None
|
date: str = "[Ort, Datum]"
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Sends an accreditation email with login credentials and generated contract PDF."""
|
"""Generiert den Hauptvertrag und sendet diesen zusammen mit Rechnung, AGB und AVV per E-Mail."""
|
||||||
|
|
||||||
# 1. Temporären Pfad für das generierte PDF festlegen
|
# 1. Hauptvertrag generieren
|
||||||
contract_filename = f"Vertrag_{school_name.replace(' ', '_')}.pdf"
|
|
||||||
contract_pdf_path = os.path.join(tempfile.gettempdir(), contract_filename)
|
|
||||||
|
|
||||||
# 2. Hauptvertrag als PDF generieren
|
|
||||||
generate_main_contract_pdf(
|
generate_main_contract_pdf(
|
||||||
school_name=school_name,
|
school_name=school_name,
|
||||||
address=address,
|
address=address,
|
||||||
price=price,
|
price=price,
|
||||||
date=date,
|
date=date,
|
||||||
software_name=software_name,
|
|
||||||
output_path=contract_pdf_path
|
output_path=contract_pdf_path
|
||||||
)
|
)
|
||||||
|
|
||||||
# 3. E-Mail Inhalt vorbereiten
|
# 2. Pfade zu den statischen Dokumenten
|
||||||
|
agb_pdf_path = os.path.join("static", "download", "AGB Invario.pdf")
|
||||||
|
avv_pdf_path = os.path.join("static", "download", "AVV Invario.pdf")
|
||||||
|
|
||||||
|
# 3. E-Mail Texte
|
||||||
subject = "Ihre Zugangsdaten und Unterlagen für Invario"
|
subject = "Ihre Zugangsdaten und Unterlagen für Invario"
|
||||||
|
|
||||||
text_note = (
|
text_note = (
|
||||||
f"Sehr geehrte/r {username},\n\n"
|
f"Sehr geehrte/r {username},\n\n"
|
||||||
"Vielen Dank für Ihre Akkreditierung bei Invario. "
|
"Vielen Dank für Ihre Akkreditierung bei Invario. "
|
||||||
"Im Anhang finden Sie Ihre Rechnung und den Vertrag.\n\n"
|
"Im Anhang finden Sie Ihre Rechnung, den Hauptvertrag sowie die AGB und den AVV.\n\n"
|
||||||
f"Ihre Zugangsdaten:\n"
|
f"Ihre Zugangsdaten:\n"
|
||||||
f"Domain: https://{domain}\n"
|
f"Domain: https://{domain}\n"
|
||||||
f"Benutzername: {username}\n"
|
f"Benutzername: {username}\n"
|
||||||
@@ -386,7 +385,7 @@ def send_accreditation_email(
|
|||||||
<div style="font-family: Arial, Helvetica, sans-serif; color: #333333;">
|
<div style="font-family: Arial, Helvetica, sans-serif; color: #333333;">
|
||||||
<h2 style="color: #2c3e50; margin-top: 0;">Willkommen bei Invario!</h2>
|
<h2 style="color: #2c3e50; margin-top: 0;">Willkommen bei Invario!</h2>
|
||||||
<p style="font-size: 15px; line-height: 1.6;">
|
<p style="font-size: 15px; line-height: 1.6;">
|
||||||
Vielen Dank für Ihre Akkreditierung. Im Anhang finden Sie Ihre Rechnung und den Vertrag.
|
Vielen Dank für Ihre Akkreditierung. Im Anhang finden Sie Ihre Rechnung, den Hauptvertrag sowie die AGB und den AVV.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 style="color: #2c3e50;">Ihre Zugangsdaten:</h3>
|
<h3 style="color: #2c3e50;">Ihre Zugangsdaten:</h3>
|
||||||
@@ -402,18 +401,25 @@ def send_accreditation_email(
|
|||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# 4. Anhänge zusammenstellen
|
# 4. Alle existierenden Anhänge sammeln
|
||||||
attachments = [contract_pdf_path]
|
attachments = []
|
||||||
|
|
||||||
|
# Generierter Hauptvertrag & Rechnung
|
||||||
|
if contract_pdf_path and os.path.exists(contract_pdf_path):
|
||||||
|
attachments.append(contract_pdf_path)
|
||||||
if invoice_pdf_path and os.path.exists(invoice_pdf_path):
|
if invoice_pdf_path and os.path.exists(invoice_pdf_path):
|
||||||
attachments.append(invoice_pdf_path)
|
attachments.append(invoice_pdf_path)
|
||||||
|
|
||||||
# 5. E-Mail versenden
|
|
||||||
result = send(recipient, subject, text_body=text_note, html_body=html_note, attachments=attachments)
|
|
||||||
|
|
||||||
# 6. Temporäre PDF-Datei nach dem Versand wieder löschen
|
|
||||||
try:
|
|
||||||
os.remove(contract_pdf_path)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return result
|
# Statische Dokumente aus static/download/
|
||||||
|
if os.path.exists(agb_pdf_path):
|
||||||
|
attachments.append(agb_pdf_path)
|
||||||
|
else:
|
||||||
|
print(f"Warnung: AGB unter {agb_pdf_path} nicht gefunden.")
|
||||||
|
|
||||||
|
if os.path.exists(avv_pdf_path):
|
||||||
|
attachments.append(avv_pdf_path)
|
||||||
|
else:
|
||||||
|
print(f"Warnung: AVV unter {avv_pdf_path} nicht gefunden.")
|
||||||
|
|
||||||
|
# 5. E-Mail mit allen 4 Anhängen versenden
|
||||||
|
return send(recipient, subject, text_body=text_note, html_body=html_note, attachments=attachments)
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user