fix: лого SVG, убран Добавить (onchange), create_contract возвращает id, JS без лишнего GET

This commit is contained in:
2026-06-15 06:52:54 +04:00
parent 4b68ad70c5
commit 46b6bee913
3 changed files with 24 additions and 14 deletions
+17 -6
View File
@@ -36,14 +36,25 @@ def create_contract():
if not number: if not number:
return jsonify({"error": "number is required"}), 400 return jsonify({"error": "number is required"}), 400
rowcount, err = db.execute( # INSERT с RETURNING id
"INSERT INTO contracts (number, client, date_signed) VALUES (%s, %s, %s)", conn, err = db.connect()
(number, client, date_signed),
)
if err: if err:
return jsonify({"error": err}), 500 return jsonify({"error": err}), 500
try:
return jsonify({"status": "created", "rowcount": rowcount}), 201 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"]) @api_bp.route("/api/contracts", methods=["GET"])
+3 -2
View File
@@ -1,2 +1,3 @@
Forbidden <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 32" width="120" height="32">
Transaction ID: bdd7fbca-219a-4dbf-95ca-a27cc8bdecd9 <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

+4 -6
View File
@@ -107,10 +107,7 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="form-row"> <div class="form-row">
<input type="file" id="fileInput" accept=".docx,.doc,.pdf,.zip" multiple style="height:36px;"> <input type="file" id="fileInput" accept=".docx,.doc,.pdf,.zip" multiple style="height:36px;" onchange="addFiles()">
<button class="btn btn-primary" onclick="addFiles()">
<i data-lucide="plus" style="width:16px;height:16px;"></i> Добавить
</button>
</div> </div>
<div class="queue" id="queue"></div> <div class="queue" id="queue"></div>
<div class="queue-empty" id="queueEmpty">Нет добавленных файлов</div> <div class="queue-empty" id="queueEmpty">Нет добавленных файлов</div>
@@ -197,8 +194,9 @@
method: 'POST', headers: {'Content-Type': 'application/json'}, method: 'POST', headers: {'Content-Type': 'application/json'},
body: JSON.stringify({number: 'б/н ' + new Date().toISOString().slice(0,10)}), body: JSON.stringify({number: 'б/н ' + new Date().toISOString().slice(0,10)}),
}); });
const listResp = await fetch('/api/contracts'); const data = await resp.json();
contractId = (await listResp.json()).contracts[0].id; if (!resp.ok || !data.id) throw new Error(data.error || 'no id');
contractId = data.id;
} catch (e) { } catch (e) {
resultsBody.innerHTML = '<div class="error-box">❌ ' + e.message + '</div>'; resultsBody.innerHTML = '<div class="error-box">❌ ' + e.message + '</div>';
resetBtn(); return; resetBtn(); return;