Update app.py
Browse files
app.py
CHANGED
|
@@ -1834,16 +1834,7 @@ def download_csv():
|
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
-
|
| 1838 |
-
|
| 1839 |
-
|
| 1840 |
-
|
| 1841 |
-
|
| 1842 |
-
|
| 1843 |
-
|
| 1844 |
-
|
| 1845 |
-
|
| 1846 |
-
DATABASES4 = ['data_gc.db']
|
| 1847 |
curators = ["Anna", "Ekaterina", "Ivan", "Maria", "Sergey", "Olga", "Alex", "Natalia", "Dmitry", "Elena"]
|
| 1848 |
current_curator_index = 0
|
| 1849 |
|
|
@@ -1866,7 +1857,7 @@ def j_clean_phone_number(phone_number):
|
|
| 1866 |
|
| 1867 |
def j_insert_data(data, verify_phone, add_curator):
|
| 1868 |
global current_curator_index
|
| 1869 |
-
for db_name in
|
| 1870 |
conn = sqlite3.connect(db_name)
|
| 1871 |
cursor = conn.cursor()
|
| 1872 |
|
|
@@ -1882,7 +1873,7 @@ def j_insert_data(data, verify_phone, add_curator):
|
|
| 1882 |
user_exists = cursor.fetchone()
|
| 1883 |
|
| 1884 |
if user_exists:
|
| 1885 |
-
|
| 1886 |
continue
|
| 1887 |
|
| 1888 |
if add_curator == "1":
|
|
@@ -1912,8 +1903,8 @@ def j_insert_data(data, verify_phone, add_curator):
|
|
| 1912 |
user_data = dict(zip(columns, values))
|
| 1913 |
send_to_google_forms(user_data, gog_url)
|
| 1914 |
except Exception as e:
|
| 1915 |
-
|
| 1916 |
-
|
| 1917 |
conn.rollback()
|
| 1918 |
raise
|
| 1919 |
|
|
@@ -1933,8 +1924,8 @@ def j_upload_json():
|
|
| 1933 |
parsed_data = j_parse_json_data(data)
|
| 1934 |
verify_phone = request.form.get('verify_phone', '0')
|
| 1935 |
add_curator = request.form.get('add_curator', '0')
|
| 1936 |
-
|
| 1937 |
-
|
| 1938 |
j_insert_data(parsed_data, verify_phone, add_curator)
|
| 1939 |
return jsonify({"message": "Data uploaded and inserted successfully"})
|
| 1940 |
return jsonify({"error": "Invalid file format"}), 400
|
|
@@ -1970,7 +1961,6 @@ def j_se_upl_json():
|
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
-
|
| 1974 |
|
| 1975 |
|
| 1976 |
@app.route('/gc_in', methods=['GET'])
|
|
|
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
+
DATABASES5 = ['data_gc.db']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1838 |
curators = ["Anna", "Ekaterina", "Ivan", "Maria", "Sergey", "Olga", "Alex", "Natalia", "Dmitry", "Elena"]
|
| 1839 |
current_curator_index = 0
|
| 1840 |
|
|
|
|
| 1857 |
|
| 1858 |
def j_insert_data(data, verify_phone, add_curator):
|
| 1859 |
global current_curator_index
|
| 1860 |
+
for db_name in DATABASES5:
|
| 1861 |
conn = sqlite3.connect(db_name)
|
| 1862 |
cursor = conn.cursor()
|
| 1863 |
|
|
|
|
| 1873 |
user_exists = cursor.fetchone()
|
| 1874 |
|
| 1875 |
if user_exists:
|
| 1876 |
+
logging.warning(f"User with email {email} or phone {phone} already exists. Skipping insert.")
|
| 1877 |
continue
|
| 1878 |
|
| 1879 |
if add_curator == "1":
|
|
|
|
| 1903 |
user_data = dict(zip(columns, values))
|
| 1904 |
send_to_google_forms(user_data, gog_url)
|
| 1905 |
except Exception as e:
|
| 1906 |
+
logging.error(f"Error inserting row: {row}")
|
| 1907 |
+
logging.error(f"Error message: {str(e)}")
|
| 1908 |
conn.rollback()
|
| 1909 |
raise
|
| 1910 |
|
|
|
|
| 1924 |
parsed_data = j_parse_json_data(data)
|
| 1925 |
verify_phone = request.form.get('verify_phone', '0')
|
| 1926 |
add_curator = request.form.get('add_curator', '0')
|
| 1927 |
+
logging.debug(f"Verify Phone: {verify_phone}")
|
| 1928 |
+
logging.debug(f"Add Curator: {add_curator}")
|
| 1929 |
j_insert_data(parsed_data, verify_phone, add_curator)
|
| 1930 |
return jsonify({"message": "Data uploaded and inserted successfully"})
|
| 1931 |
return jsonify({"error": "Invalid file format"}), 400
|
|
|
|
| 1961 |
|
| 1962 |
|
| 1963 |
|
|
|
|
| 1964 |
|
| 1965 |
|
| 1966 |
@app.route('/gc_in', methods=['GET'])
|