changes to the provisioning process

This commit is contained in:
2026-08-25 22:24:36 +02:00
parent a9f89fc704
commit fa434f1048
+15 -11
View File
@@ -3753,23 +3753,24 @@ def run_tenant_provisioning_async(app, user_id, tenant_slug, school_name, user_e
finally: finally:
inst_client.close() inst_client.close()
# 5. E-Mail versenden (wird vor dem Status-Update gemacht, damit bei Crash 'failed' ausgelöst wird) # 5. E-Mail versenden (isoliert, damit ein Mail-Fehler nicht die Instanz killt)
send_accreditation_email( try:
recipient=user_email, send_accreditation_email(
domain=domain, recipient=user_email,
username="admin", domain=domain,
password=admin_password, username="admin",
invoice_pdf_path=f"/var/invoices/{tenant_slug}_invoice.pdf", password=admin_password,
contract_pdf_path=f"/var/contracts/{tenant_slug}_contract.pdf" # 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", { _update_prov_status("ready", {
"instance_id": created_inst_id, "instance_id": created_inst_id,
"url": f"https://{domain}", "url": f"https://{domain}",
"username": "admin", "username": "admin",
"password": admin_password "password": admin_password
# Optional: "invoice_url": f"/download/invoice/{tenant_slug}" falls du den PDF-Download im Frontend anbietest
}) })
except Exception as e: except Exception as e:
@@ -3843,6 +3844,9 @@ def tenant_status():
current_status = prov_req.get("provision_status") if prov_req else None 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"]: if not prov_req or current_status not in ["ready", "completed"]:
return jsonify({"status": "pending"}), 200 return jsonify({"status": "pending"}), 200