change to the buchungs system
This commit is contained in:
+10
-2
@@ -3714,12 +3714,16 @@ def run_tenant_provisioning_async(app, user_id, tenant_slug, school_name, user_e
|
|||||||
@app.route('/booking_payment_async', methods=['POST'])
|
@app.route('/booking_payment_async', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def booking_payment_async():
|
def booking_payment_async():
|
||||||
|
try:
|
||||||
user_id = session.get("user_id")
|
user_id = session.get("user_id")
|
||||||
user_email = session.get("email")
|
user_email = session.get("email")
|
||||||
tenant_slug = _slugify_subdomain(request.form.get('tenant_slug'))
|
tenant_slug = _slugify_subdomain(request.form.get('tenant_slug'))
|
||||||
school_name = request.form.get('school_name', tenant_slug)
|
school_name = request.form.get('school_name', tenant_slug)
|
||||||
|
|
||||||
# Insert request record into instance_requests
|
if not tenant_slug:
|
||||||
|
return jsonify({"success": False, "error": "Ungültige Subdomain angegeben."}), 400
|
||||||
|
|
||||||
|
# Datenbank-Eintrag erstellen...
|
||||||
req_client, req_col = _get_collection("instance_requests")
|
req_client, req_col = _get_collection("instance_requests")
|
||||||
try:
|
try:
|
||||||
prov_doc = {
|
prov_doc = {
|
||||||
@@ -3734,7 +3738,7 @@ def booking_payment_async():
|
|||||||
finally:
|
finally:
|
||||||
req_client.close()
|
req_client.close()
|
||||||
|
|
||||||
# Start async worker passing prov_id
|
# Asynchronen Thread starten...
|
||||||
thread = threading.Thread(
|
thread = threading.Thread(
|
||||||
target=run_tenant_provisioning_async,
|
target=run_tenant_provisioning_async,
|
||||||
args=(app._get_current_object(), user_id, tenant_slug, school_name, user_email, prov_id)
|
args=(app._get_current_object(), user_id, tenant_slug, school_name, user_email, prov_id)
|
||||||
@@ -3747,6 +3751,10 @@ def booking_payment_async():
|
|||||||
"request_id": prov_id
|
"request_id": prov_id
|
||||||
}), 200
|
}), 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')
|
@app.route('/instance_request/status')
|
||||||
def tenant_status():
|
def tenant_status():
|
||||||
slug = request.args.get('slug')
|
slug = request.args.get('slug')
|
||||||
|
|||||||
@@ -482,18 +482,21 @@
|
|||||||
headers: { 'Accept': 'application/json' }
|
headers: { 'Accept': 'application/json' }
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await response.json();
|
// Prüfen, ob der Server echtes JSON zurückgibt
|
||||||
|
const contentType = response.headers.get("content-type");
|
||||||
if (!response.ok) {
|
let result;
|
||||||
throw new Error(result.error || 'Es gab ein Problem bei der Buchung.');
|
if (contentType && contentType.includes("application/json")) {
|
||||||
|
result = await response.json();
|
||||||
|
} else {
|
||||||
|
// Wenn der Server HTML schickt (z.B. Flask Debugger Error Page)
|
||||||
|
const rawText = await response.text();
|
||||||
|
console.error("Server hat kein JSON gesendet:", rawText);
|
||||||
|
throw new Error("Ein Serverfehler ist aufgetreten. Bitte prüfen Sie die Konsolenausgabe.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erfolg: Formular verstecken, Ladebildschirm zeigen
|
if (!response.ok || !result.success) {
|
||||||
formState.style.display = 'none';
|
throw new Error(result.error || 'Es gab ein Problem bei der Buchung.');
|
||||||
loadingState.style.display = 'block';
|
}
|
||||||
|
|
||||||
// Starte Polling
|
|
||||||
startPolling(tenantSlug);
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorAlert.textContent = error.message;
|
errorAlert.textContent = error.message;
|
||||||
|
|||||||
Reference in New Issue
Block a user