first commit
This commit is contained in:
113
service_app_init/runner.py
Normal file
113
service_app_init/runner.py
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
|
||||
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):
|
||||
from databases import (
|
||||
AddressCity,
|
||||
AddressStreet,
|
||||
AddressLocality,
|
||||
AddressDistrict,
|
||||
AddressNeighborhood,
|
||||
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
|
||||
)
|
||||
state = AddressState.find_or_create(
|
||||
state_name="TÜRKİYE",
|
||||
state_code="TR",
|
||||
phone_code="90",
|
||||
country_id=country.id,
|
||||
country_uu_id=str(country.uu_id),
|
||||
**confirmed_dict
|
||||
)
|
||||
city = AddressCity.find_or_create(
|
||||
city_name="ANKARA",
|
||||
city_code="6",
|
||||
licence_plate="06",
|
||||
state_id=state.id,
|
||||
state_uu_id=str(state.uu_id),
|
||||
**confirmed_dict
|
||||
)
|
||||
district = AddressDistrict.find_or_create(
|
||||
district_name="ÇANKAYA",
|
||||
district_code="1231",
|
||||
city_id=city.id,
|
||||
city_uu_id=str(city.uu_id),
|
||||
**confirmed_dict
|
||||
)
|
||||
locality = AddressLocality.find_or_create(
|
||||
locality_name="MERKEZ",
|
||||
locality_code="2431",
|
||||
type_code="3",
|
||||
type_description=None,
|
||||
district_id=district.id,
|
||||
district_uu_id=str(district.uu_id),
|
||||
**confirmed_dict
|
||||
)
|
||||
neighborhood = AddressNeighborhood.find_or_create(
|
||||
neighborhood_name="AYRANCI MAHALLESİ",
|
||||
neighborhood_code="1522",
|
||||
type_code="1",
|
||||
type_description="MAHALLESİ",
|
||||
locality_id=locality.id,
|
||||
locality_uu_id=str(locality.uu_id),
|
||||
**confirmed_dict
|
||||
)
|
||||
street = AddressStreet.find_or_create(
|
||||
street_name="REŞAT NURİ CADDESİ",
|
||||
type_description="CADDESİ",
|
||||
type_code="3",
|
||||
street_code="52270",
|
||||
neighborhood_id=neighborhood.id,
|
||||
neighborhood_uu_id=str(neighborhood.uu_id),
|
||||
**confirmed_dict
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("service_app_init is running")
|
||||
init_alembic_address = False
|
||||
if init_alembic_address:
|
||||
do_alembic()
|
||||
create_application_defaults_func(create_address=False)
|
||||
|
||||
Reference in New Issue
Block a user