DmitrMakeev
commited on
Commit
•
6d6d24d
1
Parent(s):
38af07d
Update app.py
Browse files
app.py
CHANGED
@@ -1674,7 +1674,7 @@ def verify_phone_number(phone_number):
|
|
1674 |
else:
|
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,16 +1689,16 @@ def add_or_update_contact(contact_data):
|
|
1689 |
contact = cursor.fetchone()
|
1690 |
|
1691 |
# List all fields for updating or inserting
|
1692 |
-
fields =
|
1693 |
|
1694 |
placeholders = ", ".join([f"{field} = ?" for field in fields])
|
1695 |
|
1696 |
if contact:
|
1697 |
update_query = f"UPDATE contacts SET {placeholders} WHERE id = ?"
|
1698 |
-
cursor.execute(update_query, (*[contact_data
|
1699 |
else:
|
1700 |
insert_query = f"INSERT INTO contacts ({', '.join(fields)}) VALUES ({', '.join(['?' for _ in fields])})"
|
1701 |
-
cursor.execute(insert_query, tuple(contact_data
|
1702 |
|
1703 |
conn.commit()
|
1704 |
conn.close()
|
@@ -1709,14 +1709,13 @@ def add_data_ver():
|
|
1709 |
contact_data = {
|
1710 |
'name': request.args.get('name', ''),
|
1711 |
'phone': request.args.get('phone', ''),
|
1712 |
-
'email': request.args.get('email', '')
|
1713 |
-
'ws_st': request.args.get('ws_st', '')
|
1714 |
}
|
1715 |
|
1716 |
# Получение значения проверки номера телефона
|
1717 |
phone_verification_response = verify_phone_number(contact_data['phone'])
|
1718 |
if phone_verification_response is not None:
|
1719 |
-
contact_data['
|
1720 |
|
1721 |
try:
|
1722 |
add_or_update_contact(contact_data)
|
@@ -1727,16 +1726,6 @@ def add_data_ver():
|
|
1727 |
|
1728 |
|
1729 |
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
initialize_requests()
|
1741 |
|
1742 |
|
|
|
1674 |
else:
|
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 = list(contact_data.keys())
|
1693 |
|
1694 |
placeholders = ", ".join([f"{field} = ?" for field in fields])
|
1695 |
|
1696 |
if contact:
|
1697 |
update_query = f"UPDATE contacts SET {placeholders} WHERE id = ?"
|
1698 |
+
cursor.execute(update_query, (*[contact_data[field] for field in fields], contact[0]))
|
1699 |
else:
|
1700 |
insert_query = f"INSERT INTO contacts ({', '.join(fields)}) VALUES ({', '.join(['?' for _ in fields])})"
|
1701 |
+
cursor.execute(insert_query, tuple(contact_data[field] for field in fields))
|
1702 |
|
1703 |
conn.commit()
|
1704 |
conn.close()
|
|
|
1709 |
contact_data = {
|
1710 |
'name': request.args.get('name', ''),
|
1711 |
'phone': request.args.get('phone', ''),
|
1712 |
+
'email': request.args.get('email', '')
|
|
|
1713 |
}
|
1714 |
|
1715 |
# Получение значения проверки номера телефона
|
1716 |
phone_verification_response = verify_phone_number(contact_data['phone'])
|
1717 |
if phone_verification_response is not None:
|
1718 |
+
contact_data['ws_st'] = phone_verification_response # Сохраняем значение в поле ws_st
|
1719 |
|
1720 |
try:
|
1721 |
add_or_update_contact(contact_data)
|
|
|
1726 |
|
1727 |
|
1728 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1729 |
initialize_requests()
|
1730 |
|
1731 |
|