changes to the provisioning process
This commit is contained in:
+15
-11
@@ -3753,23 +3753,24 @@ def run_tenant_provisioning_async(app, user_id, tenant_slug, school_name, user_e
|
||||
finally:
|
||||
inst_client.close()
|
||||
|
||||
# 5. E-Mail versenden (wird vor dem Status-Update gemacht, damit bei Crash 'failed' ausgelöst wird)
|
||||
send_accreditation_email(
|
||||
recipient=user_email,
|
||||
domain=domain,
|
||||
username="admin",
|
||||
password=admin_password,
|
||||
invoice_pdf_path=f"/var/invoices/{tenant_slug}_invoice.pdf",
|
||||
contract_pdf_path=f"/var/contracts/{tenant_slug}_contract.pdf"
|
||||
)
|
||||
# 5. E-Mail versenden (isoliert, damit ein Mail-Fehler nicht die Instanz killt)
|
||||
try:
|
||||
send_accreditation_email(
|
||||
recipient=user_email,
|
||||
domain=domain,
|
||||
username="admin",
|
||||
password=admin_password,
|
||||
# invoice_pdf_path=f"/var/invoices/{tenant_slug}_invoice.pdf", # Testweise auskommentieren
|
||||
# contract_pdf_path=f"/var/contracts/{tenant_slug}_contract.pdf" # Testweise auskommentieren
|
||||
)
|
||||
except Exception as mail_error:
|
||||
print(f"[WARNUNG] Mail konnte nicht gesendet werden: {mail_error}")
|
||||
|
||||
# 6. Request als erfolgreich markieren (WICHTIG: Status "ready" und exakte Felder für Frontend)
|
||||
_update_prov_status("ready", {
|
||||
"instance_id": created_inst_id,
|
||||
"url": f"https://{domain}",
|
||||
"username": "admin",
|
||||
"password": admin_password
|
||||
# Optional: "invoice_url": f"/download/invoice/{tenant_slug}" falls du den PDF-Download im Frontend anbietest
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
@@ -3843,6 +3844,9 @@ def tenant_status():
|
||||
|
||||
current_status = prov_req.get("provision_status") if prov_req else None
|
||||
|
||||
if current_status == "failed":
|
||||
return jsonify({"status": "failed", "error": prov_req.get("last_error", "Unbekannter Fehler")}), 200
|
||||
|
||||
if not prov_req or current_status not in ["ready", "completed"]:
|
||||
return jsonify({"status": "pending"}), 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user