Update app.py
Browse files
app.py
CHANGED
|
@@ -1824,9 +1824,22 @@ curators = ["Anna", "Ekaterina", "Ivan"]
|
|
| 1824 |
# Переменная для отслеживания текущего куратора
|
| 1825 |
current_curator_index = 0
|
| 1826 |
|
| 1827 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1828 |
global current_curator_index
|
| 1829 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1830 |
if curator_name is None:
|
| 1831 |
curator_name = curators[current_curator_index]
|
| 1832 |
elif curator_name not in curators:
|
|
@@ -1839,12 +1852,12 @@ def add_user_cur(curator_name):
|
|
| 1839 |
|
| 1840 |
@app.route('/add_user_cur', methods=['GET'])
|
| 1841 |
def add_user_cur_route():
|
| 1842 |
-
|
| 1843 |
|
| 1844 |
-
if add_user_cur(
|
| 1845 |
-
return jsonify({'status': 'success', 'message': f'Current curator set to {
|
| 1846 |
else:
|
| 1847 |
-
return jsonify({'status': 'error', 'message': f'Curator {
|
| 1848 |
|
| 1849 |
|
| 1850 |
|
|
|
|
| 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 is None:
|
| 1844 |
curator_name = curators[current_curator_index]
|
| 1845 |
elif curator_name not in curators:
|
|
|
|
| 1852 |
|
| 1853 |
@app.route('/add_user_cur', methods=['GET'])
|
| 1854 |
def add_user_cur_route():
|
| 1855 |
+
user_data = {key: request.args.get(key, "") for key in mapping_template_cur.keys()}
|
| 1856 |
|
| 1857 |
+
if add_user_cur(user_data, mapping_template_cur):
|
| 1858 |
+
return jsonify({'status': 'success', 'message': f'Current curator set to {curators[current_curator_index]}'})
|
| 1859 |
else:
|
| 1860 |
+
return jsonify({'status': 'error', 'message': f'Curator {user_data.get("curator")} not found in the list of curators'}), 400
|
| 1861 |
|
| 1862 |
|
| 1863 |
|