DmitrMakeev commited on
Commit
5b3744e
1 Parent(s): d61e90d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -1550,6 +1550,45 @@ def add_data_ver_cur():
1550
 
1551
 
1552
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1553
 
1554
 
1555
 
 
1550
 
1551
 
1552
 
1553
+ @app.route('/add_data_ver_cur2', methods=['GET'])
1554
+ def add_data_ver_cur():
1555
+ global current_curator_index
1556
+
1557
+ veref_on_off = request.args.get('ver', '0') # Включает "1" и выключает "0" верификацию номера вместо verifikation_start
1558
+ curator_on_off = request.args.get('cur', '0') # Включает "1" и выключает "0" назначение куратора
1559
+
1560
+ template_key = request.args.get('template_key', 'avp')
1561
+ mapping_template_cur = mapp_templates.get(template_key, mt_avp)
1562
+
1563
+ user_data = {mapping_template_cur[key]: request.args.get(key, "") for key in mapping_template_cur}
1564
+
1565
+ logging.debug(f"Received data: {user_data}")
1566
+
1567
+ if curator_on_off == "1":
1568
+ user_data['curator'] = curators[current_curator_index]
1569
+
1570
+ if veref_on_off == "true":
1571
+ phone_number = user_data.get('phone', '')
1572
+ if not phone_number:
1573
+ logging.error("Phone number is empty")
1574
+ return jsonify({'status': 'error', 'message': 'Phone number is empty'}), 400
1575
+
1576
+ phone_verification_response = verify_phone_number(phone_number)
1577
+ if phone_verification_response is not None:
1578
+ user_data['ws_st'] = phone_verification_response
1579
+
1580
+ try:
1581
+ add_or_update_contact(user_data)
1582
+ if curator_on_off == "1":
1583
+ current_curator_index = (current_curator_index + 1) % len(curators)
1584
+
1585
+
1586
+
1587
+ return jsonify({'status': 'success', 'message': f'User added with curator {user_data.get("curator", "not assigned")}'})
1588
+ except Exception as e:
1589
+ logging.error(f"Error adding user: {e}")
1590
+ return jsonify({'status': 'error', 'message': str(e)}), 500
1591
+
1592
 
1593
 
1594