Aidaho 3 years ago
parent 91924d12cc
commit 0e1bd121ff

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import distro import distro
from sql import out_error
from db_model import * from db_model import *
from funct import check_ver from funct import check_ver
@ -113,7 +112,7 @@ def default_values():
try: try:
Setting.insert_many(data_source).on_conflict_ignore().execute() Setting.insert_many(data_source).on_conflict_ignore().execute()
except Exception as e: except Exception as e:
out_error(e) print(str(e))
data_source = [ data_source = [
{'username': 'admin', 'email': 'admin@localhost', 'password': '21232f297a57a5a743894a0e4a801fc3', 'role': 'superAdmin', 'groups': '1'}, {'username': 'admin', 'email': 'admin@localhost', 'password': '21232f297a57a5a743894a0e4a801fc3', 'role': 'superAdmin', 'groups': '1'},
@ -122,10 +121,18 @@ def default_values():
] ]
try: try:
if Role.get(Role.name == 'superAdmin').role_id != 1: if Role.get(Role.name == 'superAdmin').role_id == 1:
create_users = True
else:
create_users = False
except Exception:
create_users = False
try:
if create_users:
User.insert_many(data_source).on_conflict_ignore().execute() User.insert_many(data_source).on_conflict_ignore().execute()
except Exception as e: except Exception as e:
out_error(e) print(str(e))
data_source = [ data_source = [
{'name': 'superAdmin', 'description': 'Has the highest level of administrative permissions and controls the actions of all other users'}, {'name': 'superAdmin', 'description': 'Has the highest level of administrative permissions and controls the actions of all other users'},
@ -137,12 +144,12 @@ def default_values():
try: try:
Role.insert_many(data_source).on_conflict_ignore().execute() Role.insert_many(data_source).on_conflict_ignore().execute()
except Exception as e: except Exception as e:
out_error(e) print(str(e))
try: try:
Groups.insert(name='All', description='All servers are included in this group by default').on_conflict_ignore().execute() Groups.insert(name='All', description='All servers are included in this group by default').on_conflict_ignore().execute()
except Exception as e: except Exception as e:
out_error(e) print(str(e))
data_source = [ data_source = [
{'code': 'RW', 'name': 'Rwanda'}, {'code': 'RW', 'name': 'Rwanda'},
@ -400,7 +407,7 @@ def default_values():
try: try:
GeoipCodes.insert_many(data_source).on_conflict_ignore().execute() GeoipCodes.insert_many(data_source).on_conflict_ignore().execute()
except Exception as e: except Exception as e:
out_error(e) print(str(e))
def update_db_v_3_4_5_22(): def update_db_v_3_4_5_22():
@ -523,7 +530,7 @@ def update_db_v_5_3_0(**kwargs):
try: try:
query_res = query.execute() query_res = query.execute()
except Exception as e: except Exception as e:
out_error(e) print(str(e))
else: else:
groups = query_res groups = query_res

Loading…
Cancel
Save