Spaces:
Build error
Build error
Commit
·
f5b590a
1
Parent(s):
a87329f
fixed user reset settings button
Browse files- app/static/user/dashboard.css +1 -1
- app/user/routes.py +17 -18
app/static/user/dashboard.css
CHANGED
|
@@ -275,7 +275,7 @@ button:hover{
|
|
| 275 |
right: 30px;
|
| 276 |
}
|
| 277 |
.reset_btn_container>.reset_btn{
|
| 278 |
-
color:
|
| 279 |
position: fixed;
|
| 280 |
font-size: larger;
|
| 281 |
background-color: transparent;
|
|
|
|
| 275 |
right: 30px;
|
| 276 |
}
|
| 277 |
.reset_btn_container>.reset_btn{
|
| 278 |
+
color:black;
|
| 279 |
position: fixed;
|
| 280 |
font-size: larger;
|
| 281 |
background-color: transparent;
|
app/user/routes.py
CHANGED
|
@@ -217,26 +217,24 @@ def get_image_size(mode):
|
|
| 217 |
def get_settings():
|
| 218 |
global settings
|
| 219 |
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
cursor.execute("select
|
| 225 |
settings=cursor.fetchone()
|
| 226 |
columns=cursor.column_names
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
settings= dict(zip(columns, settings))
|
| 237 |
-
# Disconnecting from the server
|
| 238 |
-
dataBase.commit()
|
| 239 |
-
dataBase.close()
|
| 240 |
|
| 241 |
print("\n\nsee:",settings['p_thres'],"\n\n")
|
| 242 |
|
|
@@ -250,7 +248,8 @@ def reset_settings():
|
|
| 250 |
cursor.execute("select p_thres,nms_thres,small_size,large_size,d_thres,a_thres,db_mode,fr_mode from default_settings where page='user'")
|
| 251 |
settings=cursor.fetchone()
|
| 252 |
columns=cursor.column_names
|
| 253 |
-
|
|
|
|
| 254 |
|
| 255 |
# Disconnecting from the server
|
| 256 |
dataBase.commit()
|
|
|
|
| 217 |
def get_settings():
|
| 218 |
global settings
|
| 219 |
|
| 220 |
+
dataBase = access_database_as_admin()
|
| 221 |
+
cursor=dataBase.cursor()
|
| 222 |
+
cursor.execute("select * from user_settings where username=%s",[session['user']['username']])
|
| 223 |
+
settings=cursor.fetchone()
|
| 224 |
+
columns=cursor.column_names
|
| 225 |
|
| 226 |
+
if settings is None:
|
| 227 |
+
# get default settings and insert a row in user_settings
|
| 228 |
+
cursor.execute("select p_thres,nms_thres,small_size,large_size,d_thres,a_thres,db_mode,fr_mode from default_settings where page='user'")
|
| 229 |
settings=cursor.fetchone()
|
| 230 |
columns=cursor.column_names
|
| 231 |
+
cursor.execute(f"insert into user_settings(username,{','.join(columns)}) values(%s,{','.join(map(lambda x:'%s',columns))})",(session['user']['username'],)+settings)
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
settings= dict(zip(columns, settings))
|
| 235 |
+
# Disconnecting from the server
|
| 236 |
+
dataBase.commit()
|
| 237 |
+
dataBase.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
print("\n\nsee:",settings['p_thres'],"\n\n")
|
| 240 |
|
|
|
|
| 248 |
cursor.execute("select p_thres,nms_thres,small_size,large_size,d_thres,a_thres,db_mode,fr_mode from default_settings where page='user'")
|
| 249 |
settings=cursor.fetchone()
|
| 250 |
columns=cursor.column_names
|
| 251 |
+
print(settings)
|
| 252 |
+
cursor.execute(f"update user_settings set {','.join(list(map(lambda x:x+'=%s',columns)))} where username=%s;",settings+(session['user']['username'],))
|
| 253 |
|
| 254 |
# Disconnecting from the server
|
| 255 |
dataBase.commit()
|