DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1595,7 +1595,7 @@ def add_or_update_contact(contact_data):
|
|
1595 |
conn.commit()
|
1596 |
replace_null_with_empty_string(conn)
|
1597 |
conn.close()
|
1598 |
-
@app.route('/
|
1599 |
def add_data_ver_cur():
|
1600 |
global current_curator_index
|
1601 |
|
@@ -1635,7 +1635,58 @@ def add_data_ver_cur():
|
|
1635 |
return jsonify({'status': 'error', 'message': str(e)}), 500
|
1636 |
|
1637 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1638 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1639 |
|
1640 |
|
1641 |
|
|
|
1595 |
conn.commit()
|
1596 |
replace_null_with_empty_string(conn)
|
1597 |
conn.close()
|
1598 |
+
@app.route('/ver_cur', methods=['GET'])
|
1599 |
def add_data_ver_cur():
|
1600 |
global current_curator_index
|
1601 |
|
|
|
1635 |
return jsonify({'status': 'error', 'message': str(e)}), 500
|
1636 |
|
1637 |
|
1638 |
+
@app.route('/ver_bonus', methods=['GET'])
|
1639 |
+
def add_data_ver_cur():
|
1640 |
+
global current_curator_index
|
1641 |
+
|
1642 |
+
veref_on_off = request.args.get('ver', '0') # Включает "1" и выключает "0" верификацию номера вместо verifikation_start
|
1643 |
+
curator_on_off = request.args.get('cur', '0') # Включает "1" и выключает "0" назначение куратора
|
1644 |
+
|
1645 |
+
template_key = request.args.get('template_key', 'avp')
|
1646 |
+
mapping_template_cur = mapp_templates.get(template_key, mt_avp)
|
1647 |
+
|
1648 |
+
user_data = {mapping_template_cur[key]: request.args.get(key, "") for key in mapping_template_cur}
|
1649 |
+
|
1650 |
+
logging.debug(f"Received data: {user_data}")
|
1651 |
+
|
1652 |
+
if curator_on_off == "1":
|
1653 |
+
user_data['curator'] = curators[current_curator_index]
|
1654 |
+
current_curator_index = (current_curator_index + 1) % len(curators)
|
1655 |
+
else:
|
1656 |
+
user_data['curator'] = user_data.get('curator', '')
|
1657 |
+
|
1658 |
+
if veref_on_off == "1":
|
1659 |
+
phone_number = user_data.get('phone', '')
|
1660 |
+
if not phone_number:
|
1661 |
+
logging.error("Phone number is empty")
|
1662 |
+
return jsonify({'status': 'error', 'message': 'Phone number is empty'}), 400
|
1663 |
+
|
1664 |
+
phone_verification_response = verify_phone_number(phone_number)
|
1665 |
+
if phone_verification_response is not None:
|
1666 |
+
user_data['ws_st'] = '1' if phone_verification_response else '0'
|
1667 |
+
else:
|
1668 |
+
user_data['ws_st'] = user_data.get('ws_st', '')
|
1669 |
|
1670 |
+
# Обработка pr1
|
1671 |
+
email = user_data.get('email')
|
1672 |
+
new_pr1 = user_data.get('pr1')
|
1673 |
+
if email and new_pr1:
|
1674 |
+
conn = sqlite3.connect(DATABASE_NAME3)
|
1675 |
+
cursor = conn.cursor()
|
1676 |
+
cursor.execute("SELECT pr1 FROM contacts WHERE email = ?", (email,))
|
1677 |
+
result = cursor.fetchone()
|
1678 |
+
if result and result[0]:
|
1679 |
+
user_data['pr1'] = str(int(result[0]) + int(new_pr1))
|
1680 |
+
else:
|
1681 |
+
user_data['pr1'] = new_pr1
|
1682 |
+
conn.close()
|
1683 |
+
|
1684 |
+
try:
|
1685 |
+
add_or_update_contact(user_data)
|
1686 |
+
return jsonify({'status': 'success', 'message': f'User added with curator {user_data.get("curator", "not assigned")}'})
|
1687 |
+
except Exception as e:
|
1688 |
+
logging.error(f"Error adding user: {e}")
|
1689 |
+
return jsonify({'status': 'error', 'message': str(e)}), 500
|
1690 |
|
1691 |
|
1692 |
|