DmitrMakeev
commited on
Commit
•
d3fb63f
1
Parent(s):
3fc8645
Update app.py
Browse files
app.py
CHANGED
@@ -1628,15 +1628,6 @@ def gc_forms():
|
|
1628 |
|
1629 |
DATABASE_NAME3 = 'data_gc.db'
|
1630 |
|
1631 |
-
import sqlite3
|
1632 |
-
import json
|
1633 |
-
import requests
|
1634 |
-
from flask import Flask, request, jsonify
|
1635 |
-
import logging
|
1636 |
-
|
1637 |
-
DATABASE_NAME3 = 'data_gc.db'
|
1638 |
-
|
1639 |
-
|
1640 |
def verify_phone_number(phone_number):
|
1641 |
verifikation_start = "1"
|
1642 |
print(f"verifikation_start: {verifikation_start}")
|
@@ -1684,8 +1675,6 @@ def verify_phone_number(phone_number):
|
|
1684 |
print("Verification not started")
|
1685 |
return "Verification not started"
|
1686 |
|
1687 |
-
REQUIRED_FIELDS = ["name", "phone", "email", "ws_st"]
|
1688 |
-
|
1689 |
# Функция для добавления или обновления контакта в базе данных
|
1690 |
def add_or_update_contact(contact_data):
|
1691 |
conn = sqlite3.connect(DATABASE_NAME3)
|
@@ -1700,28 +1689,56 @@ def add_or_update_contact(contact_data):
|
|
1700 |
contact = cursor.fetchone()
|
1701 |
|
1702 |
# List all fields for updating or inserting
|
1703 |
-
fields = [
|
|
|
|
|
|
|
|
|
1704 |
|
1705 |
placeholders = ", ".join([f"{field} = ?" for field in fields])
|
1706 |
|
1707 |
if contact:
|
1708 |
update_query = f"UPDATE contacts SET {placeholders} WHERE id = ?"
|
1709 |
-
cursor.execute(update_query, (*[contact_data
|
1710 |
else:
|
1711 |
insert_query = f"INSERT INTO contacts ({', '.join(fields)}) VALUES ({', '.join(['?' for _ in fields])})"
|
1712 |
-
cursor.execute(insert_query, tuple(contact_data
|
1713 |
|
1714 |
conn.commit()
|
1715 |
conn.close()
|
1716 |
|
1717 |
@app.route('/add_data_ver', methods=['GET'])
|
1718 |
def add_data_ver():
|
1719 |
-
# Извлечение параметров запроса с дефолтными значениями
|
1720 |
contact_data = {
|
1721 |
-
'name': request.args.get('name', ''),
|
1722 |
-
'phone': request.args.get('phone', ''),
|
1723 |
-
'email': request.args.get('email', ''),
|
1724 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1725 |
}
|
1726 |
|
1727 |
# Получение значения проверки номера телефона
|
@@ -1740,6 +1757,18 @@ def add_data_ver():
|
|
1740 |
|
1741 |
|
1742 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1743 |
initialize_requests()
|
1744 |
|
1745 |
|
|
|
1628 |
|
1629 |
DATABASE_NAME3 = 'data_gc.db'
|
1630 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1631 |
def verify_phone_number(phone_number):
|
1632 |
verifikation_start = "1"
|
1633 |
print(f"verifikation_start: {verifikation_start}")
|
|
|
1675 |
print("Verification not started")
|
1676 |
return "Verification not started"
|
1677 |
|
|
|
|
|
1678 |
# Функция для добавления или обновления контакта в базе данных
|
1679 |
def add_or_update_contact(contact_data):
|
1680 |
conn = sqlite3.connect(DATABASE_NAME3)
|
|
|
1689 |
contact = cursor.fetchone()
|
1690 |
|
1691 |
# List all fields for updating or inserting
|
1692 |
+
fields = [
|
1693 |
+
'name', 'phone', 'email', 'vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog',
|
1694 |
+
'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator',
|
1695 |
+
'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'ad_url', 'key_pr', 'n_con', 'canal', 'data_t'
|
1696 |
+
]
|
1697 |
|
1698 |
placeholders = ", ".join([f"{field} = ?" for field in fields])
|
1699 |
|
1700 |
if contact:
|
1701 |
update_query = f"UPDATE contacts SET {placeholders} WHERE id = ?"
|
1702 |
+
cursor.execute(update_query, (*[contact_data.get(field, '_') for field in fields], contact[0]))
|
1703 |
else:
|
1704 |
insert_query = f"INSERT INTO contacts ({', '.join(fields)}) VALUES ({', '.join(['?' for _ in fields])})"
|
1705 |
+
cursor.execute(insert_query, tuple(contact_data.get(field, '_') for field in fields))
|
1706 |
|
1707 |
conn.commit()
|
1708 |
conn.close()
|
1709 |
|
1710 |
@app.route('/add_data_ver', methods=['GET'])
|
1711 |
def add_data_ver():
|
1712 |
+
# Извлечение параметров запроса с дефолтными значениями нижнего подчеркивания
|
1713 |
contact_data = {
|
1714 |
+
'name': request.args.get('name', '_'),
|
1715 |
+
'phone': request.args.get('phone', '_'),
|
1716 |
+
'email': request.args.get('email', '_'),
|
1717 |
+
'vk_id': request.args.get('vk_id', '_'),
|
1718 |
+
'chat_id': request.args.get('chat_id', '_'),
|
1719 |
+
'ws_st': request.args.get('ws_st', '_'),
|
1720 |
+
'ws_stop': request.args.get('ws_stop', '_'),
|
1721 |
+
'web_st': request.args.get('web_st', '_'),
|
1722 |
+
'fin_prog': request.args.get('fin_prog', '_'),
|
1723 |
+
'b_city': request.args.get('b_city', '_'),
|
1724 |
+
'b_fin': request.args.get('b_fin', '_'),
|
1725 |
+
'b_ban': request.args.get('b_ban', '_'),
|
1726 |
+
'b_ign': request.args.get('b_ign', '_'),
|
1727 |
+
'b_baners': request.args.get('b_baners', '_'),
|
1728 |
+
'b_butt': request.args.get('b_butt', '_'),
|
1729 |
+
'b_mess': request.args.get('b_mess', '_'),
|
1730 |
+
'shop_st': request.args.get('shop_st', '_'),
|
1731 |
+
'curator': request.args.get('curator', '_'),
|
1732 |
+
'pr1': request.args.get('pr1', '_'),
|
1733 |
+
'pr2': request.args.get('pr2', '_'),
|
1734 |
+
'pr3': request.args.get('pr3', '_'),
|
1735 |
+
'pr4': request.args.get('pr4', '_'),
|
1736 |
+
'pr5': request.args.get('pr5', '_'),
|
1737 |
+
'ad_url': request.args.get('ad_url', '_'),
|
1738 |
+
'key_pr': request.args.get('key_pr', '_'),
|
1739 |
+
'n_con': request.args.get('n_con', '_'),
|
1740 |
+
'canal': request.args.get('canal', '_'),
|
1741 |
+
'data_t': request.args.get('data_t', '_')
|
1742 |
}
|
1743 |
|
1744 |
# Получение значения проверки номера телефона
|
|
|
1757 |
|
1758 |
|
1759 |
|
1760 |
+
|
1761 |
+
|
1762 |
+
|
1763 |
+
|
1764 |
+
|
1765 |
+
|
1766 |
+
|
1767 |
+
|
1768 |
+
|
1769 |
+
|
1770 |
+
|
1771 |
+
|
1772 |
initialize_requests()
|
1773 |
|
1774 |
|