Update app.py
Browse files
app.py
CHANGED
@@ -625,7 +625,16 @@ def shop_order_new():
|
|
625 |
|
626 |
|
627 |
# Работа из VK_ID Запись ордер с полными данными
|
628 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
def write_order_vk_full():
|
630 |
try:
|
631 |
logging.debug("Starting shop_order_new")
|
@@ -634,17 +643,40 @@ def write_order_vk_full():
|
|
634 |
if api_sys_control != api_key_sys:
|
635 |
logging.warning("Unauthorized access attempt")
|
636 |
return json.dumps({"error": "Unauthorized access"}), 403
|
637 |
-
|
638 |
|
|
|
639 |
name = request.args.get('name', '')
|
640 |
email = request.args.get('email', '')
|
641 |
-
vkid = request.args.get('vk_id', '')
|
642 |
phone = request.args.get('phone', '').lstrip('+')
|
643 |
order = request.args.get('order', '')
|
644 |
status = request.args.get('status', '')
|
645 |
del_flag = request.args.get('del', '')
|
646 |
n_con_flag = request.args.get('n_con', '')
|
647 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
648 |
if not email or not phone:
|
649 |
logging.error("Email and phone are required")
|
650 |
return json.dumps({"error": "Email and phone are required"}), 400
|
|
|
625 |
|
626 |
|
627 |
# Работа из VK_ID Запись ордер с полными данными
|
628 |
+
# Функция для замены NULL на пустую строку в базе данных
|
629 |
+
def replace_null_with_empty_string(conn):
|
630 |
+
cursor = conn.cursor()
|
631 |
+
cursor.execute("PRAGMA table_info(contacts)")
|
632 |
+
columns = [column[1] for column in cursor.fetchall()]
|
633 |
+
for column in columns:
|
634 |
+
cursor.execute(f"UPDATE contacts SET {column} = '' WHERE {column} IS NULL")
|
635 |
+
conn.commit()
|
636 |
+
|
637 |
+
@app.route('/wr_order_vk_full', methods=['GET', 'POST'])
|
638 |
def write_order_vk_full():
|
639 |
try:
|
640 |
logging.debug("Starting shop_order_new")
|
|
|
643 |
if api_sys_control != api_key_sys:
|
644 |
logging.warning("Unauthorized access attempt")
|
645 |
return json.dumps({"error": "Unauthorized access"}), 403
|
|
|
646 |
|
647 |
+
# Читаем параметры из GET-запроса
|
648 |
name = request.args.get('name', '')
|
649 |
email = request.args.get('email', '')
|
650 |
+
vkid = request.args.get('vk_id', '')
|
651 |
phone = request.args.get('phone', '').lstrip('+')
|
652 |
order = request.args.get('order', '')
|
653 |
status = request.args.get('status', '')
|
654 |
del_flag = request.args.get('del', '')
|
655 |
n_con_flag = request.args.get('n_con', '')
|
656 |
|
657 |
+
# Читаем параметры из POST-запроса (формы)
|
658 |
+
if request.method == 'POST':
|
659 |
+
name = request.form.get('name', name)
|
660 |
+
email = request.form.get('email', email)
|
661 |
+
vkid = request.form.get('vk_id', vkid)
|
662 |
+
phone = request.form.get('phone', phone).lstrip('+')
|
663 |
+
order = request.form.get('order', order)
|
664 |
+
status = request.form.get('status', status)
|
665 |
+
del_flag = request.form.get('del', del_flag)
|
666 |
+
n_con_flag = request.form.get('n_con', n_con_flag)
|
667 |
+
|
668 |
+
# Читаем параметры из POST-запроса (JSON)
|
669 |
+
if request.is_json:
|
670 |
+
json_data = request.get_json()
|
671 |
+
name = json_data.get('name', name)
|
672 |
+
email = json_data.get('email', email)
|
673 |
+
vkid = json_data.get('vk_id', vkid)
|
674 |
+
phone = json_data.get('phone', phone).lstrip('+')
|
675 |
+
order = json_data.get('order', order)
|
676 |
+
status = json_data.get('status', status)
|
677 |
+
del_flag = json_data.get('del', del_flag)
|
678 |
+
n_con_flag = json_data.get('n_con', n_con_flag)
|
679 |
+
|
680 |
if not email or not phone:
|
681 |
logging.error("Email and phone are required")
|
682 |
return json.dumps({"error": "Email and phone are required"}), 400
|