DmitrMakeev
commited on
Commit
•
08404c2
1
Parent(s):
3797008
Update app.py
Browse files
app.py
CHANGED
@@ -1680,6 +1680,20 @@ def add_data_ver_cur():
|
|
1680 |
|
1681 |
DATABASE2 = 'data_gc.db'
|
1682 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1683 |
def parse_csv_data(data):
|
1684 |
parsed_data = []
|
1685 |
for item in data:
|
@@ -1690,6 +1704,7 @@ def parse_csv_data(data):
|
|
1690 |
return parsed_data
|
1691 |
|
1692 |
def insert_data(data, db_name):
|
|
|
1693 |
conn = sqlite3.connect(db_name)
|
1694 |
cursor = conn.cursor()
|
1695 |
|
@@ -1746,6 +1761,15 @@ def insert_data(data, db_name):
|
|
1746 |
print(f"User with email {email} or phone {phone} already exists. Skipping insert.")
|
1747 |
continue
|
1748 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1749 |
# Создание динамического SQL-запроса для вставки данных
|
1750 |
columns = ['name', 'phone', 'email', 'vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'ad_url', 'key_pr', 'n_con', 'canal', 'data_t', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content']
|
1751 |
values = [name, phone, email, vk_id, chat_id, ws_st, ws_stop, web_st, fin_prog, b_city, b_fin, b_ban, b_ign, b_baners, b_butt, b_mess, shop_st, curator, pr1, pr2, pr3, pr4, pr5, ad_url, key_pr, n_con, canal, data_t, utm_source, utm_medium, utm_campaign, utm_term, utm_content]
|
|
|
1680 |
|
1681 |
DATABASE2 = 'data_gc.db'
|
1682 |
|
1683 |
+
def verify_phone_number(phone_number):
|
1684 |
+
if verifikation_start == "1":
|
1685 |
+
full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
|
1686 |
+
payload = {"phoneNumber": phone_number}
|
1687 |
+
headers = {'Content-Type': 'application/json'}
|
1688 |
+
response = requests.post(full_url_ver, headers=headers, json=payload)
|
1689 |
+
if response.status_code == 200:
|
1690 |
+
response_body = response.json()
|
1691 |
+
return response_body.get('existsWhatsapp', 'false')
|
1692 |
+
else:
|
1693 |
+
return "Error"
|
1694 |
+
else:
|
1695 |
+
return "false"
|
1696 |
+
|
1697 |
def parse_csv_data(data):
|
1698 |
parsed_data = []
|
1699 |
for item in data:
|
|
|
1704 |
return parsed_data
|
1705 |
|
1706 |
def insert_data(data, db_name):
|
1707 |
+
global current_curator_index
|
1708 |
conn = sqlite3.connect(db_name)
|
1709 |
cursor = conn.cursor()
|
1710 |
|
|
|
1761 |
print(f"User with email {email} or phone {phone} already exists. Skipping insert.")
|
1762 |
continue
|
1763 |
|
1764 |
+
# Добавление куратора, если curator_on_off == "1"
|
1765 |
+
if curator_on_off == "1":
|
1766 |
+
curator = curators[current_curator_index]
|
1767 |
+
current_curator_index = (current_curator_index + 1) % len(curators)
|
1768 |
+
|
1769 |
+
# Верификация номера телефона, если verifikation_start == "1"
|
1770 |
+
if verifikation_start == "1":
|
1771 |
+
ws_st = verify_phone_number(phone)
|
1772 |
+
|
1773 |
# Создание динамического SQL-запроса для вставки данных
|
1774 |
columns = ['name', 'phone', 'email', 'vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'ad_url', 'key_pr', 'n_con', 'canal', 'data_t', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content']
|
1775 |
values = [name, phone, email, vk_id, chat_id, ws_st, ws_stop, web_st, fin_prog, b_city, b_fin, b_ban, b_ign, b_baners, b_butt, b_mess, shop_st, curator, pr1, pr2, pr3, pr4, pr5, ad_url, key_pr, n_con, canal, data_t, utm_source, utm_medium, utm_campaign, utm_term, utm_content]
|