fix: лого SVG, убран Добавить (onchange), create_contract возвращает id, JS без лишнего GET
This commit is contained in:
+17
-6
@@ -36,14 +36,25 @@ def create_contract():
|
||||
if not number:
|
||||
return jsonify({"error": "number is required"}), 400
|
||||
|
||||
rowcount, err = db.execute(
|
||||
"INSERT INTO contracts (number, client, date_signed) VALUES (%s, %s, %s)",
|
||||
(number, client, date_signed),
|
||||
)
|
||||
# INSERT с RETURNING id
|
||||
conn, err = db.connect()
|
||||
if err:
|
||||
return jsonify({"error": err}), 500
|
||||
|
||||
return jsonify({"status": "created", "rowcount": rowcount}), 201
|
||||
try:
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"INSERT INTO contracts (number, client, date_signed) VALUES (%s, %s, %s) RETURNING id",
|
||||
(number, client, date_signed),
|
||||
)
|
||||
contract_id = cur.fetchone()[0]
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
return jsonify({"status": "created", "id": str(contract_id)}), 201
|
||||
except Exception as e:
|
||||
conn.rollback()
|
||||
conn.close()
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@api_bp.route("/api/contracts", methods=["GET"])
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
Forbidden
|
||||
Transaction ID: bdd7fbca-219a-4dbf-95ca-a27cc8bdecd9
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 32" width="120" height="32">
|
||||
<text x="0" y="24" font-family="system-ui,sans-serif" font-weight="700" font-size="24" fill="#2563eb">nubes</text>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 63 B After Width: | Height: | Size: 210 B |
@@ -107,10 +107,7 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<input type="file" id="fileInput" accept=".docx,.doc,.pdf,.zip" multiple style="height:36px;">
|
||||
<button class="btn btn-primary" onclick="addFiles()">
|
||||
<i data-lucide="plus" style="width:16px;height:16px;"></i> Добавить
|
||||
</button>
|
||||
<input type="file" id="fileInput" accept=".docx,.doc,.pdf,.zip" multiple style="height:36px;" onchange="addFiles()">
|
||||
</div>
|
||||
<div class="queue" id="queue"></div>
|
||||
<div class="queue-empty" id="queueEmpty">Нет добавленных файлов</div>
|
||||
@@ -197,8 +194,9 @@
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({number: 'б/н ' + new Date().toISOString().slice(0,10)}),
|
||||
});
|
||||
const listResp = await fetch('/api/contracts');
|
||||
contractId = (await listResp.json()).contracts[0].id;
|
||||
const data = await resp.json();
|
||||
if (!resp.ok || !data.id) throw new Error(data.error || 'no id');
|
||||
contractId = data.id;
|
||||
} catch (e) {
|
||||
resultsBody.innerHTML = '<div class="error-box">❌ ' + e.message + '</div>';
|
||||
resetBtn(); return;
|
||||
|
||||
Reference in New Issue
Block a user