DmitrMakeev commited on
Commit
9154d57
·
verified ·
1 Parent(s): 5fc7c41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -20
app.py CHANGED
@@ -1824,22 +1824,9 @@ curators = ["Anna", "Ekaterina", "Ivan"]
1824
  # Переменная для отслеживания текущего куратора
1825
  current_curator_index = 0
1826
 
1827
- # Шаблон сопоставления для кураторов
1828
- mapping_template_cur = {
1829
- 'name': 'name',
1830
- 'phone': 'phone',
1831
- 'email': 'email',
1832
- 'curator': 'curator'
1833
- }
1834
-
1835
- def add_user_cur(user_data, mapping_template_cur):
1836
  global current_curator_index
1837
 
1838
- # Преобразование данных пользователя на основе шаблона сопоставления
1839
- transformed_data = {db_column: user_data.get(json_key, "") for json_key, db_column in mapping_template_cur.items()}
1840
-
1841
- # Назначение куратора
1842
- curator_name = transformed_data.get('curator')
1843
  if curator_name not in curators:
1844
  logging.error(f"Curator {curator_name} not found in the list of curators")
1845
  return False
@@ -1848,15 +1835,14 @@ def add_user_cur(user_data, mapping_template_cur):
1848
  logging.info(f"Current curator set to {curator_name}")
1849
  return True
1850
 
1851
- @app.route('/add_user_cur', methods=['POST'])
1852
  def add_user_cur_route():
1853
- user_data = request.json
1854
 
1855
- if add_user_cur(user_data, mapping_template_cur):
1856
- return jsonify({'status': 'success', 'message': f'Current curator set to {user_data.get("curator")}'})
1857
  else:
1858
- return jsonify({'status': 'error', 'message': f'Curator {user_data.get("curator")} not found in the list of curators'}), 400
1859
-
1860
 
1861
 
1862
 
 
1824
  # Переменная для отслеживания текущего куратора
1825
  current_curator_index = 0
1826
 
1827
+ def add_user_cur(curator_name):
 
 
 
 
 
 
 
 
1828
  global current_curator_index
1829
 
 
 
 
 
 
1830
  if curator_name not in curators:
1831
  logging.error(f"Curator {curator_name} not found in the list of curators")
1832
  return False
 
1835
  logging.info(f"Current curator set to {curator_name}")
1836
  return True
1837
 
1838
+ @app.route('/add_user_cur', methods=['GET'])
1839
  def add_user_cur_route():
1840
+ curator_name = request.args.get('curator_name')
1841
 
1842
+ if add_user_cur(curator_name):
1843
+ return jsonify({'status': 'success', 'message': f'Current curator set to {curator_name}'})
1844
  else:
1845
+ return jsonify({'status': 'error', 'message': f'Curator {curator_name} not found in the list of curators'}), 400
 
1846
 
1847
 
1848