Update app.py
Browse files
app.py
CHANGED
@@ -2057,7 +2057,6 @@ def from_allow():
|
|
2057 |
else:
|
2058 |
pr5_data = {}
|
2059 |
|
2060 |
-
# Логика обработки pr5_data
|
2061 |
if del_flag == '1':
|
2062 |
if module in pr5_data:
|
2063 |
del pr5_data[module]
|
@@ -2066,19 +2065,19 @@ def from_allow():
|
|
2066 |
|
2067 |
pr5_json = json.dumps(pr5_data)
|
2068 |
|
2069 |
-
# Получение текущей даты и времени в Московском часовом поясе
|
2070 |
utc_now = datetime.utcnow()
|
2071 |
msk_tz = pytz.timezone('Europe/Moscow')
|
2072 |
msk_now = utc_now.replace(tzinfo=pytz.utc).astimezone(msk_tz)
|
2073 |
data_on = msk_now.strftime('%Y-%m-%d %H:%M:%S')
|
2074 |
|
|
|
|
|
|
|
2075 |
if result:
|
2076 |
-
# Обновляем только те поля, которые переданы в запросе
|
2077 |
set_clause = ', '.join([f"{col} = ?" for col in columns_to_update])
|
2078 |
query = f"UPDATE contacts SET {set_clause} WHERE email = ? OR phone = ?"
|
2079 |
cursor.execute(query, values_to_update + [email, phone])
|
2080 |
else:
|
2081 |
-
# Вставляем новые данные
|
2082 |
query = f"INSERT INTO contacts ({', '.join(columns_to_update)}) VALUES ({', '.join(['?' for _ in columns_to_update])})"
|
2083 |
cursor.execute(query, values_to_update)
|
2084 |
|
@@ -2111,7 +2110,6 @@ def from_allow():
|
|
2111 |
|
2112 |
|
2113 |
|
2114 |
-
|
2115 |
|
2116 |
|
2117 |
@app.route('/gc_in', methods=['GET'])
|
|
|
2057 |
else:
|
2058 |
pr5_data = {}
|
2059 |
|
|
|
2060 |
if del_flag == '1':
|
2061 |
if module in pr5_data:
|
2062 |
del pr5_data[module]
|
|
|
2065 |
|
2066 |
pr5_json = json.dumps(pr5_data)
|
2067 |
|
|
|
2068 |
utc_now = datetime.utcnow()
|
2069 |
msk_tz = pytz.timezone('Europe/Moscow')
|
2070 |
msk_now = utc_now.replace(tzinfo=pytz.utc).astimezone(msk_tz)
|
2071 |
data_on = msk_now.strftime('%Y-%m-%d %H:%M:%S')
|
2072 |
|
2073 |
+
columns_to_update = ['name', 'phone', 'email', 'pr5', 'data_on']
|
2074 |
+
values_to_update = [name, phone, email, pr5_json, data_on]
|
2075 |
+
|
2076 |
if result:
|
|
|
2077 |
set_clause = ', '.join([f"{col} = ?" for col in columns_to_update])
|
2078 |
query = f"UPDATE contacts SET {set_clause} WHERE email = ? OR phone = ?"
|
2079 |
cursor.execute(query, values_to_update + [email, phone])
|
2080 |
else:
|
|
|
2081 |
query = f"INSERT INTO contacts ({', '.join(columns_to_update)}) VALUES ({', '.join(['?' for _ in columns_to_update])})"
|
2082 |
cursor.execute(query, values_to_update)
|
2083 |
|
|
|
2110 |
|
2111 |
|
2112 |
|
|
|
2113 |
|
2114 |
|
2115 |
@app.route('/gc_in', methods=['GET'])
|