changes to the provisioning process
This commit is contained in:
+9
-5
@@ -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)
|
||||||
|
try:
|
||||||
send_accreditation_email(
|
send_accreditation_email(
|
||||||
recipient=user_email,
|
recipient=user_email,
|
||||||
domain=domain,
|
domain=domain,
|
||||||
username="admin",
|
username="admin",
|
||||||
password=admin_password,
|
password=admin_password,
|
||||||
invoice_pdf_path=f"/var/invoices/{tenant_slug}_invoice.pdf",
|
# invoice_pdf_path=f"/var/invoices/{tenant_slug}_invoice.pdf", # Testweise auskommentieren
|
||||||
contract_pdf_path=f"/var/contracts/{tenant_slug}_contract.pdf"
|
# 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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user