Commit 06b68e80 authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

tested admin log, improved feedback

parent db95970a
...@@ -11,3 +11,26 @@ ...@@ -11,3 +11,26 @@
[2020-06-10 19:26:21,369] INFO in views: User admin downloaded data for application 0513d8d9 device 1 [2020-06-10 19:26:21,369] INFO in views: User admin downloaded data for application 0513d8d9 device 1
[2020-06-10 19:26:44,083] INFO in views: User admin deleted for application 0513d8d9 device 1 [2020-06-10 19:26:44,083] INFO in views: User admin deleted for application 0513d8d9 device 1
[2020-06-10 19:26:58,457] INFO in views: User admin deleted application - 0513d8d9 [2020-06-10 19:26:58,457] INFO in views: User admin deleted application - 0513d8d9
[2020-06-11 09:29:26,446] WARNING in views_admin: Administrator admin created new user lolo
[2020-06-11 09:39:23,858] WARNING in views_admin: Administrator admin created new user lolo
[2020-06-11 09:39:39,600] WARNING in views_admin: Administrator admin deleted user lolo
[2020-06-11 09:40:02,339] WARNING in views_admin: Administrator admin created new application 598bee34 for user-user
[2020-06-11 09:40:34,846] ERROR in views_admin: Administrator admin failed to add device application e38dc490 for user-user - INSERT has more expressions than target columns
LINE 5: ('asd', '1', 'asd', '\x7b226d6f64656c223a20226a736f6...
^
[2020-06-11 09:41:26,391] ERROR in views_admin: Administrator admin failed to add device application e38dc490 for user-user - INSERT has more expressions than target columns
LINE 5: ('dev1 test', '1', 'dsds', '\x7b226d6f64656c223a2022...
^
[2020-06-11 09:50:18,424] WARNING in views_admin: Administrator admin created new application 5e4932cc for user-user
[2020-06-11 09:50:36,442] WARNING in views_admin: Administrator admin added new device 1 application 5e4932cc for user-user
[2020-06-11 09:50:59,309] WARNING in views_admin: Administrator admin created alert 7d7a6d for application 5e4932cc for user-user
[2020-06-11 09:53:15,478] WARNING in views_admin: Administrator admin created alert 8b867b for application 5e4932cc for user-user
[2020-06-11 09:53:19,487] WARNING in views_admin: Administrator admin deleted alert 8b867b for application 5e4932cc for user-user
[2020-06-11 09:53:52,334] WARNING in views_admin: Administrator admin created automation 72249b for application 5e4932cc for user-user
[2020-06-11 09:54:00,999] WARNING in views_admin: Administrator admin deleted automation 72249b for application 5e4932cc for user-user
[2020-06-11 09:54:21,228] WARNING in views_admin: Administrator admin changed settings for application 5e4932cc for user-user
[2020-06-11 09:54:28,518] WARNING in views_admin: Administrator admin deleted application 5e4932cc for user-user
[2020-06-11 09:55:16,026] INFO in views: User admin created new application - test
[2020-06-11 10:01:02,029] INFO in views: User admin deleted application - 649fd3ab
...@@ -113,7 +113,6 @@ def delete_function(cur, appkey, devid, nfid): ...@@ -113,7 +113,6 @@ def delete_function(cur, appkey, devid, nfid):
# bool -> bool # bool -> bool
# str -> text # str -> text
def get_type(tstr): def get_type(tstr):
print('before get_type', tstr)
tstr = tstr.strip() tstr = tstr.strip()
if tstr == 'true': if tstr == 'true':
tstr = 'True' tstr = 'True'
...@@ -123,7 +122,6 @@ def get_type(tstr): ...@@ -123,7 +122,6 @@ def get_type(tstr):
# int, float, bool # int, float, bool
t = type(ast.literal_eval(tstr)).__name__ t = type(ast.literal_eval(tstr)).__name__
except Exception as e: except Exception as e:
print ('expection', e, ' -> ', ' from ', tstr)
t = 'text' t = 'text'
if t == 'float': if t == 'float':
......
...@@ -377,7 +377,7 @@ def application_device_configuration_remove(appkey, devid): ...@@ -377,7 +377,7 @@ def application_device_configuration_remove(appkey, devid):
if res[0]: if res[0]:
app.logger.info('User %s deleted config messsage %s for application %s device %s', session['name'], request.args.get('conf'), appkey, devid) app.logger.info('User %s deleted config messsage %s for application %s device %s', session['name'], request.args.get('conf'), appkey, devid)
flash('Configuration message successfully removed.','success') flash('Configuration message removed.','success')
else: else:
app.logger.error('User %s failed to delet config messsage %s for application %s device %s - %s', session['name'], request.args.get('conf'), appkey, devid, res[1]) app.logger.error('User %s failed to delet config messsage %s for application %s device %s - %s', session['name'], request.args.get('conf'), appkey, devid, res[1])
flash('Error removing configuration message: {}'.format(res[1]), 'danger') flash('Error removing configuration message: {}'.format(res[1]), 'danger')
...@@ -432,7 +432,7 @@ def delete_account(): ...@@ -432,7 +432,7 @@ def delete_account():
return render_template('new/public/settings.html', user=session['name']) return render_template('new/public/settings.html', user=session['name'])
else: else:
app.logger.warning('User %s deleted the account', session['name']) app.logger.warning('User %s deleted the account', session['name'])
flash('User {} was successfully deleted'.format(request.args.get('name')), 'success') flash('User {} was deleted'.format(request.args.get('name')), 'success')
return redirect(url_for('login')) return redirect(url_for('login'))
...@@ -455,7 +455,7 @@ def settings(): ...@@ -455,7 +455,7 @@ def settings():
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return redirect(request.url) return redirect(request.url)
flash('Settings successfully saved.', 'success') flash('Settings saved.', 'success')
return redirect(request.url) return redirect(request.url)
...@@ -615,7 +615,8 @@ def application_settings(appkey): ...@@ -615,7 +615,8 @@ def application_settings(appkey):
if not res[0]: if not res[0]:
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return redirect(request.url) return redirect(request.url)
flash('Settings saved', 'success')
return redirect(request.url) return redirect(request.url)
...@@ -635,7 +636,8 @@ def application_device_settings(appkey, devid): ...@@ -635,7 +636,8 @@ def application_device_settings(appkey, devid):
if not res[0]: if not res[0]:
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return redirect(request.url) return redirect(request.url)
flash('Settings saved', 'success')
return redirect(request.url) return redirect(request.url)
......
...@@ -191,7 +191,8 @@ def administration_user_application_device_settings(name, appkey, devid): ...@@ -191,7 +191,8 @@ def administration_user_application_device_settings(name, appkey, devid):
return redirect(request.url) return redirect(request.url)
app.logger.warning('Administrator %s changed settings for device %s application %s for %s', session['name'], devid, appkey, name) app.logger.warning('Administrator %s changed settings for device %s application %s for %s', session['name'], devid, appkey, name)
flash('Settings saved', 'success')
return redirect(request.url) return redirect(request.url)
...@@ -347,9 +348,10 @@ def administration_user_application_settings(name, appkey): ...@@ -347,9 +348,10 @@ def administration_user_application_settings(name, appkey):
app.logger.error('Administrator %s failed to change settings for application %s for %s - %s', session['name'], appkey, name, res[1]) app.logger.error('Administrator %s failed to change settings for application %s for %s - %s', session['name'], appkey, name, res[1])
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return redirect(request.url) return redirect(request.url)
app.logger.warning('Administrator %s changed settings for application %s for %s', session['name'], appkey, name) app.logger.warning('Administrator %s changed settings for application %s for %s', session['name'], appkey, name)
flash('Settings saved', 'success')
return redirect(request.url) return redirect(request.url)
...@@ -362,7 +364,7 @@ def administration_user_application_notification_remove(name, appkey, ntype): ...@@ -362,7 +364,7 @@ def administration_user_application_notification_remove(name, appkey, ntype):
res = nfs.delete(appkey, request.args.get('devid'), request.args.get('id')) res = nfs.delete(appkey, request.args.get('devid'), request.args.get('id'))
if res[0]: if res[0]:
app.logger.warning('Administrator %s deleted %s %s for application for %s', session['name'], ntype, request.args.get('id'), appkey, name) app.logger.warning('Administrator %s deleted %s %s for application %s for %s', session['name'], ntype, request.args.get('id'), appkey, name)
flash('{} removed'.format(ntype.capitalize()), 'success') flash('{} removed'.format(ntype.capitalize()), 'success')
return '', 200 return '', 200
else: else:
...@@ -444,7 +446,7 @@ def administration_user_application_device_configuration_remove(name, appkey, de ...@@ -444,7 +446,7 @@ def administration_user_application_device_configuration_remove(name, appkey, de
if res[0]: if res[0]:
app.logger.warning('Administrator %s deleted config message %s for device %s application %s for %s', session['name'], request.args.get('conf'), devid, appkey, name) app.logger.warning('Administrator %s deleted config message %s for device %s application %s for %s', session['name'], request.args.get('conf'), devid, appkey, name)
flash('Configuration message successfully removed.','success') flash('Configuration message removed.','success')
else: else:
app.logger.error('Administrator %s failed to delete config message %s for device %s application for %s - %s', session['name'], request.args.get('conf'), devid, appkey, name, res[1]) app.logger.error('Administrator %s failed to delete config message %s for device %s application for %s - %s', session['name'], request.args.get('conf'), devid, appkey, name, res[1])
flash('Error removing configuration message: {}'.format(res[1]), 'danger') flash('Error removing configuration message: {}'.format(res[1]), 'danger')
...@@ -598,18 +600,18 @@ def administration_user_delete_account(name): ...@@ -598,18 +600,18 @@ def administration_user_delete_account(name):
res = (True,) res = (True,)
if app_list[0]: if app_list[0]:
for app in app_list[1]: for a in app_list[1]:
devs = dd.get_list(app[1]) devs = dd.get_list(a[1])
for dev in devs[1]: for dev in devs[1]:
res = data.delete_table(app[1], dev[1]) res = data.delete_table(a[1], dev[1])
if not res[0]: if not res[0]:
break break
if res[0]: if res[0]:
res = dd.delete_table(app[1]) res = dd.delete_table(a[1])
if res[0]: if res[0]:
res = ad.delete(app[1]) res = ad.delete(a[1])
if not res[0]: if not res[0]:
break break
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment