Anuj-Panthri commited on
Commit
f5b590a
·
1 Parent(s): a87329f

fixed user reset settings button

Browse files
Files changed (2) hide show
  1. app/static/user/dashboard.css +1 -1
  2. 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:white;
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
- if (settings.keys().__len__()==0):
 
 
 
 
221
 
222
- dataBase = access_database_as_admin()
223
- cursor=dataBase.cursor()
224
- cursor.execute("select * from user_settings where username=%s",[session['user']['username']])
225
  settings=cursor.fetchone()
226
  columns=cursor.column_names
227
-
228
- if settings is None:
229
- # get default settings and insert a row in user_settings
230
- 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'")
231
- settings=cursor.fetchone()
232
- columns=cursor.column_names
233
- cursor.execute(f"insert into user_settings(username,{','.join(columns)}) values(%s,{','.join(map(lambda x:'%s',columns))})",(session['user']['username'],)+settings)
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
- cursor.execute(f"insert into user_settings(username,{','.join(columns)}) values(%s,{','.join(map(lambda x:'%s',columns))})",(session['user']['username'],)+settings)
 
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()