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.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.cell(col_width, 5, "(Verantwortlicher)", align="C", ln=False)
|
||||
@@ -345,36 +345,35 @@ def send_accreditation_email(
|
||||
domain: str,
|
||||
username: str,
|
||||
password: str,
|
||||
school_name: str,
|
||||
address: str,
|
||||
price: str,
|
||||
date: str,
|
||||
software_name: str,
|
||||
invoice_pdf_path: str = None
|
||||
invoice_pdf_path: str,
|
||||
contract_pdf_path: str,
|
||||
school_name: str = "[Name der Schule / des Auftraggebers]",
|
||||
address: str = "[Straße, Hausnummer] [PLZ, Ort]",
|
||||
price: str = "250,00",
|
||||
date: str = "[Ort, Datum]"
|
||||
) -> 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
|
||||
contract_filename = f"Vertrag_{school_name.replace(' ', '_')}.pdf"
|
||||
contract_pdf_path = os.path.join(tempfile.gettempdir(), contract_filename)
|
||||
|
||||
# 2. Hauptvertrag als PDF generieren
|
||||
# 1. Hauptvertrag generieren
|
||||
generate_main_contract_pdf(
|
||||
school_name=school_name,
|
||||
address=address,
|
||||
price=price,
|
||||
date=date,
|
||||
software_name=software_name,
|
||||
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"
|
||||
|
||||
text_note = (
|
||||
f"Sehr geehrte/r {username},\n\n"
|
||||
"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"Domain: https://{domain}\n"
|
||||
f"Benutzername: {username}\n"
|
||||
@@ -386,7 +385,7 @@ def send_accreditation_email(
|
||||
<div style="font-family: Arial, Helvetica, sans-serif; color: #333333;">
|
||||
<h2 style="color: #2c3e50; margin-top: 0;">Willkommen bei Invario!</h2>
|
||||
<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>
|
||||
|
||||
<h3 style="color: #2c3e50;">Ihre Zugangsdaten:</h3>
|
||||
@@ -402,18 +401,25 @@ def send_accreditation_email(
|
||||
</div>
|
||||
"""
|
||||
|
||||
# 4. Anhänge zusammenstellen
|
||||
attachments = [contract_pdf_path]
|
||||
# 4. Alle existierenden Anhänge sammeln
|
||||
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):
|
||||
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