change to the buchungs system
This commit is contained in:
+37
-29
@@ -3714,38 +3714,46 @@ def run_tenant_provisioning_async(app, user_id, tenant_slug, school_name, user_e
|
||||
@app.route('/booking_payment_async', methods=['POST'])
|
||||
@login_required
|
||||
def booking_payment_async():
|
||||
user_id = session.get("user_id")
|
||||
user_email = session.get("email")
|
||||
tenant_slug = _slugify_subdomain(request.form.get('tenant_slug'))
|
||||
school_name = request.form.get('school_name', tenant_slug)
|
||||
|
||||
# Insert request record into instance_requests
|
||||
req_client, req_col = _get_collection("instance_requests")
|
||||
try:
|
||||
prov_doc = {
|
||||
"user_id": user_id,
|
||||
"tenant_slug": tenant_slug,
|
||||
"school_name": school_name,
|
||||
"provision_status": "pending",
|
||||
"created_at": _utc_now_iso(),
|
||||
"updated_at": _utc_now_iso()
|
||||
}
|
||||
prov_id = str(req_col.insert_one(prov_doc).inserted_id)
|
||||
finally:
|
||||
req_client.close()
|
||||
user_id = session.get("user_id")
|
||||
user_email = session.get("email")
|
||||
tenant_slug = _slugify_subdomain(request.form.get('tenant_slug'))
|
||||
school_name = request.form.get('school_name', tenant_slug)
|
||||
|
||||
# Start async worker passing prov_id
|
||||
thread = threading.Thread(
|
||||
target=run_tenant_provisioning_async,
|
||||
args=(app._get_current_object(), user_id, tenant_slug, school_name, user_email, prov_id)
|
||||
)
|
||||
thread.start()
|
||||
if not tenant_slug:
|
||||
return jsonify({"success": False, "error": "Ungültige Subdomain angegeben."}), 400
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"tenant_slug": tenant_slug,
|
||||
"request_id": prov_id
|
||||
}), 200
|
||||
# Datenbank-Eintrag erstellen...
|
||||
req_client, req_col = _get_collection("instance_requests")
|
||||
try:
|
||||
prov_doc = {
|
||||
"user_id": user_id,
|
||||
"tenant_slug": tenant_slug,
|
||||
"school_name": school_name,
|
||||
"provision_status": "pending",
|
||||
"created_at": _utc_now_iso(),
|
||||
"updated_at": _utc_now_iso()
|
||||
}
|
||||
prov_id = str(req_col.insert_one(prov_doc).inserted_id)
|
||||
finally:
|
||||
req_client.close()
|
||||
|
||||
# Asynchronen Thread starten...
|
||||
thread = threading.Thread(
|
||||
target=run_tenant_provisioning_async,
|
||||
args=(app._get_current_object(), user_id, tenant_slug, school_name, user_email, prov_id)
|
||||
)
|
||||
thread.start()
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"tenant_slug": tenant_slug,
|
||||
"request_id": prov_id
|
||||
}), 200
|
||||
|
||||
except Exception as e:
|
||||
# WICHTIG: Fängt jegliche Python-Fehler ab und sendet sauberes JSON statt HTML-Crash
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@app.route('/instance_request/status')
|
||||
def tenant_status():
|
||||
|
||||
Reference in New Issue
Block a user