init defaults completed
This commit is contained in:
@@ -1,11 +1,32 @@
|
||||
|
||||
|
||||
confirmed_dict = {
|
||||
"is_confirmed": True,
|
||||
"active": True,
|
||||
"is_notification_send": True,
|
||||
"created_by": "System",
|
||||
"confirmed_by": "System",
|
||||
}
|
||||
|
||||
class TerminalColors:
|
||||
HEADER = '\033[95m'
|
||||
OKBLUE = '\033[94m'
|
||||
OKCYAN = '\033[96m'
|
||||
OKGREEN = '\033[92m'
|
||||
WARNING = '\033[93m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
|
||||
|
||||
def do_alembic():
|
||||
from sqlalchemy import text
|
||||
from alembic_generate import generate_alembic_with_session
|
||||
|
||||
generate_alembic_with_session(text=text)
|
||||
|
||||
|
||||
def create_application_defaults_func(create_address=False):
|
||||
def create_one_address(confirmed_dict):
|
||||
from databases import (
|
||||
AddressCity,
|
||||
AddressStreet,
|
||||
@@ -15,37 +36,6 @@ def create_application_defaults_func(create_address=False):
|
||||
AddressState,
|
||||
AddressCountry,
|
||||
)
|
||||
|
||||
from initialize_app import (
|
||||
create_modules_and_services_and_actions,
|
||||
create_endpoints_from_api_functions,
|
||||
create_all_events_from_actions,
|
||||
create_application_defaults,
|
||||
init_api_enums_build_types,
|
||||
add_events_all_services_and_occupant_types,
|
||||
add_events_to_system_super_user,
|
||||
create_occupant_types_defaults,
|
||||
)
|
||||
|
||||
create_application_defaults()
|
||||
create_occupant_types_defaults()
|
||||
init_api_enums_build_types()
|
||||
|
||||
create_endpoints_from_api_functions()
|
||||
create_modules_and_services_and_actions()
|
||||
if create_all_events_from_actions():
|
||||
add_events_all_services_and_occupant_types()
|
||||
add_events_to_system_super_user()
|
||||
|
||||
if not create_address:
|
||||
return
|
||||
confirmed_dict = {
|
||||
"is_confirmed": True,
|
||||
"active": True,
|
||||
"is_notification_send": True,
|
||||
"created_by": "System",
|
||||
"confirmed_by": "System",
|
||||
}
|
||||
country = AddressCountry.find_or_create(
|
||||
country_name="TÜRKİYE", country_code="TR", **confirmed_dict
|
||||
)
|
||||
@@ -102,9 +92,63 @@ def create_application_defaults_func(create_address=False):
|
||||
return
|
||||
|
||||
|
||||
def create_application_defaults_func(create_address=False):
|
||||
from initialize_app import (
|
||||
create_modules_and_services_and_actions,
|
||||
create_endpoints_from_api_functions,
|
||||
create_all_events_from_actions,
|
||||
create_application_defaults,
|
||||
init_api_enums_build_types,
|
||||
add_events_all_services_and_occupant_types,
|
||||
add_events_to_system_super_user,
|
||||
create_occupant_types_defaults,
|
||||
)
|
||||
import routers
|
||||
try:
|
||||
create_endpoints_from_api_functions(routers=routers)
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} create_endpoints_from_api_functions Defaults Error", e)
|
||||
try:
|
||||
create_application_defaults()
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} create_application_defaults Defaults Error", e)
|
||||
try:
|
||||
create_occupant_types_defaults()
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} create_occupant_types_defaults Defaults Error", e)
|
||||
try:
|
||||
create_modules_and_services_and_actions()
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} create_modules_and_services_and_actions Defaults Error", e)
|
||||
try:
|
||||
init_api_enums_build_types()
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} init_api_enums_build_types Defaults Error", e)
|
||||
try:
|
||||
create_all_events_from_actions()
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} create_all_events_from_actions Defaults Error", e)
|
||||
try:
|
||||
add_events_all_services_and_occupant_types()
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} add_events_all_services_and_occupant_types Defaults Error", e)
|
||||
try:
|
||||
add_events_to_system_super_user()
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} add_events_to_system_super_user Defaults Error", e)
|
||||
try:
|
||||
if not create_address:
|
||||
return
|
||||
create_one_address(confirmed_dict=confirmed_dict)
|
||||
except Exception as e:
|
||||
print(f"{TerminalColors.WARNING} create_one_address Defaults Error", e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("service_app_init is running")
|
||||
init_alembic_address = False
|
||||
print("Service App Initial Default Runner is running")
|
||||
do_alembic()
|
||||
init_alembic_address = True
|
||||
if init_alembic_address:
|
||||
do_alembic()
|
||||
create_application_defaults_func(create_address=False)
|
||||
create_application_defaults_func(create_address=False)
|
||||
print("Service App Initial Default Runner is completed")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user