Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -634,31 +634,27 @@ def write_order_vk_full():
|
|
634 |
@app.route('/wr_order_vk', methods=['GET'])
|
635 |
def wr_order_vk():
|
636 |
try:
|
637 |
-
logging.debug("Starting
|
638 |
api_sys_control = request.args.get('api_sys')
|
639 |
|
640 |
if api_sys_control != api_key_sys:
|
641 |
logging.warning("Unauthorized access attempt")
|
642 |
return json.dumps({"error": "Unauthorized access"}), 403
|
643 |
|
644 |
-
|
645 |
vkid = request.args.get('vk_id', '')
|
646 |
-
|
647 |
order = request.args.get('order', '')
|
648 |
status = request.args.get('status', '')
|
649 |
del_flag = request.args.get('del', '')
|
650 |
n_con_flag = request.args.get('n_con', '')
|
651 |
|
652 |
-
if not
|
653 |
-
logging.error("
|
654 |
-
return json.dumps({"error": "
|
655 |
-
|
656 |
-
phone = clean_phone_number_ss(phone)
|
657 |
|
658 |
conn = sqlite3.connect(DATABASE_NEW)
|
659 |
cursor = conn.cursor()
|
660 |
|
661 |
-
cursor.execute("SELECT * FROM contacts WHERE
|
662 |
result = cursor.fetchone()
|
663 |
|
664 |
if result:
|
@@ -686,8 +682,8 @@ def wr_order_vk():
|
|
686 |
|
687 |
if result:
|
688 |
set_clause = ', '.join([f"{col} = ?" for col in columns_to_update])
|
689 |
-
query = f"UPDATE contacts SET {set_clause} WHERE
|
690 |
-
cursor.execute(query, values_to_update + [
|
691 |
else:
|
692 |
query = f"INSERT INTO contacts ({', '.join(columns_to_update)}) VALUES ({', '.join(['?' for _ in columns_to_update])})"
|
693 |
cursor.execute(query, values_to_update)
|
|
|
634 |
@app.route('/wr_order_vk', methods=['GET'])
|
635 |
def wr_order_vk():
|
636 |
try:
|
637 |
+
logging.debug("Starting wr_order_vk")
|
638 |
api_sys_control = request.args.get('api_sys')
|
639 |
|
640 |
if api_sys_control != api_key_sys:
|
641 |
logging.warning("Unauthorized access attempt")
|
642 |
return json.dumps({"error": "Unauthorized access"}), 403
|
643 |
|
|
|
644 |
vkid = request.args.get('vk_id', '')
|
|
|
645 |
order = request.args.get('order', '')
|
646 |
status = request.args.get('status', '')
|
647 |
del_flag = request.args.get('del', '')
|
648 |
n_con_flag = request.args.get('n_con', '')
|
649 |
|
650 |
+
if not vkid:
|
651 |
+
logging.error("VK ID is required")
|
652 |
+
return json.dumps({"error": "VK ID is required"}), 400
|
|
|
|
|
653 |
|
654 |
conn = sqlite3.connect(DATABASE_NEW)
|
655 |
cursor = conn.cursor()
|
656 |
|
657 |
+
cursor.execute("SELECT * FROM contacts WHERE vk_id = ?", (vkid,))
|
658 |
result = cursor.fetchone()
|
659 |
|
660 |
if result:
|
|
|
682 |
|
683 |
if result:
|
684 |
set_clause = ', '.join([f"{col} = ?" for col in columns_to_update])
|
685 |
+
query = f"UPDATE contacts SET {set_clause} WHERE vk_id = ?"
|
686 |
+
cursor.execute(query, values_to_update + [vkid])
|
687 |
else:
|
688 |
query = f"INSERT INTO contacts ({', '.join(columns_to_update)}) VALUES ({', '.join(['?' for _ in columns_to_update])})"
|
689 |
cursor.execute(query, values_to_update)
|