first commit
This commit is contained in:
32
service_app_init/initialize_app/__init__.py
Normal file
32
service_app_init/initialize_app/__init__.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from service_app_init.initialize_app.initialize_default_department import (
|
||||
create_occupant_types_defaults,
|
||||
create_application_defaults,
|
||||
)
|
||||
from service_app_init.initialize_app.initiator import init_api_enums_build_types
|
||||
from service_app_init.initialize_app.model_initator import copy_validations_to_database
|
||||
from service_app_init.initialize_app.modules_and_services_init import (
|
||||
create_endpoints_from_api_functions,
|
||||
create_modules_and_services_and_actions,
|
||||
)
|
||||
|
||||
from service_app_init.initialize_app.event_initator import (
|
||||
add_events_all_services_and_occupant_types,
|
||||
create_all_events_from_actions,
|
||||
add_events_to_system_super_user,
|
||||
)
|
||||
from service_app_init.initialize_app.initialize_identity_address_defaults import (
|
||||
create_identity_address_defaults,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"create_application_defaults",
|
||||
"create_occupant_types_defaults",
|
||||
"init_api_enums_build_types",
|
||||
"copy_validations_to_database",
|
||||
"create_endpoints_from_api_functions",
|
||||
"create_modules_and_services_and_actions",
|
||||
"create_all_events_from_actions",
|
||||
"add_events_all_services_and_occupant_types",
|
||||
"create_identity_address_defaults",
|
||||
"add_events_to_system_super_user",
|
||||
]
|
||||
409
service_app_init/initialize_app/default_inits/cities.json
Normal file
409
service_app_init/initialize_app/default_inits/cities.json
Normal file
@@ -0,0 +1,409 @@
|
||||
|
||||
{
|
||||
"cities": [
|
||||
{
|
||||
"ref_id" : 1,
|
||||
"licence_plate" : "01",
|
||||
"city_name" : "Adana"
|
||||
},
|
||||
{
|
||||
"ref_id" : 2,
|
||||
"licence_plate" : "02",
|
||||
"city_name" : "Adıyaman"
|
||||
},
|
||||
{
|
||||
"ref_id" : 3,
|
||||
"licence_plate" : "03",
|
||||
"city_name" : "Afyonkarahisar"
|
||||
},
|
||||
{
|
||||
"ref_id" : 4,
|
||||
"licence_plate" : "04",
|
||||
"city_name" : "Ağrı"
|
||||
},
|
||||
{
|
||||
"ref_id" : 5,
|
||||
"licence_plate" : "05",
|
||||
"city_name" : "Amasya"
|
||||
},
|
||||
{
|
||||
"ref_id" : 6,
|
||||
"licence_plate" : "06",
|
||||
"city_name" : "Ankara"
|
||||
},
|
||||
{
|
||||
"ref_id" : 7,
|
||||
"licence_plate" : "07",
|
||||
"city_name" : "Antalya"
|
||||
},
|
||||
{
|
||||
"ref_id" : 8,
|
||||
"licence_plate" : "08",
|
||||
"city_name" : "Artvin"
|
||||
},
|
||||
{
|
||||
"ref_id" : 9,
|
||||
"licence_plate" : "09",
|
||||
"city_name" : "Aydın"
|
||||
},
|
||||
{
|
||||
"ref_id" : 10,
|
||||
"licence_plate" : "10",
|
||||
"city_name" : "Balıkesir"
|
||||
},
|
||||
{
|
||||
"ref_id" : 11,
|
||||
"licence_plate" : "11",
|
||||
"city_name" : "Bilecik"
|
||||
},
|
||||
{
|
||||
"ref_id" : 12,
|
||||
"licence_plate" : "12",
|
||||
"city_name" : "Bingöl"
|
||||
},
|
||||
{
|
||||
"ref_id" : 13,
|
||||
"licence_plate" : "13",
|
||||
"city_name" : "Bitlis"
|
||||
},
|
||||
{
|
||||
"ref_id" : 14,
|
||||
"licence_plate" : "14",
|
||||
"city_name" : "Bolu"
|
||||
},
|
||||
{
|
||||
"ref_id" : 15,
|
||||
"licence_plate" : "15",
|
||||
"city_name" : "Burdur"
|
||||
},
|
||||
{
|
||||
"ref_id" : 16,
|
||||
"licence_plate" : "16",
|
||||
"city_name" : "Bursa"
|
||||
},
|
||||
{
|
||||
"ref_id" : 17,
|
||||
"licence_plate" : "17",
|
||||
"city_name" : "Çanakkale"
|
||||
},
|
||||
{
|
||||
"ref_id" : 18,
|
||||
"licence_plate" : "18",
|
||||
"city_name" : "Çankırı"
|
||||
},
|
||||
{
|
||||
"ref_id" : 19,
|
||||
"licence_plate" : "19",
|
||||
"city_name" : "Çorum"
|
||||
},
|
||||
{
|
||||
"ref_id" : 20,
|
||||
"licence_plate" : "20",
|
||||
"city_name" : "Denizli"
|
||||
},
|
||||
{
|
||||
"ref_id" : 21,
|
||||
"licence_plate" : "21",
|
||||
"city_name" : "Diyarbakır"
|
||||
},
|
||||
{
|
||||
"ref_id" : 22,
|
||||
"licence_plate" : "22",
|
||||
"city_name" : "Edirne"
|
||||
},
|
||||
{
|
||||
"ref_id" : 23,
|
||||
"licence_plate" : "23",
|
||||
"city_name" : "Elazığ"
|
||||
},
|
||||
{
|
||||
"ref_id" : 24,
|
||||
"licence_plate" : "24",
|
||||
"city_name" : "Erzincan"
|
||||
},
|
||||
{
|
||||
"ref_id" : 25,
|
||||
"licence_plate" : "25",
|
||||
"city_name" : "Erzurum"
|
||||
},
|
||||
{
|
||||
"ref_id" : 26,
|
||||
"licence_plate" : "26",
|
||||
"city_name" : "Eskişehir"
|
||||
},
|
||||
{
|
||||
"ref_id" : 27,
|
||||
"licence_plate" : "27",
|
||||
"city_name" : "Gaziantep"
|
||||
},
|
||||
{
|
||||
"ref_id" : 28,
|
||||
"licence_plate" : "28",
|
||||
"city_name" : "Giresun"
|
||||
},
|
||||
{
|
||||
"ref_id" : 29,
|
||||
"licence_plate" : "29",
|
||||
"city_name" : "Gümüşhane"
|
||||
},
|
||||
{
|
||||
"ref_id" : 30,
|
||||
"licence_plate" : "30",
|
||||
"city_name" : "Hakkari"
|
||||
},
|
||||
{
|
||||
"ref_id" : 31,
|
||||
"licence_plate" : "31",
|
||||
"city_name" : "Hatay"
|
||||
},
|
||||
{
|
||||
"ref_id" : 32,
|
||||
"licence_plate" : "32",
|
||||
"city_name" : "Isparta"
|
||||
},
|
||||
{
|
||||
"ref_id" : 33,
|
||||
"licence_plate" : "33",
|
||||
"city_name" : "Mersin"
|
||||
},
|
||||
{
|
||||
"ref_id" : 34,
|
||||
"licence_plate" : "34",
|
||||
"city_name" : "İstanbul"
|
||||
},
|
||||
{
|
||||
"ref_id" : 35,
|
||||
"licence_plate" : "35",
|
||||
"city_name" : "İzmir"
|
||||
},
|
||||
{
|
||||
"ref_id" : 36,
|
||||
"licence_plate" : "36",
|
||||
"city_name" : "Kars"
|
||||
},
|
||||
{
|
||||
"ref_id" : 37,
|
||||
"licence_plate" : "37",
|
||||
"city_name" : "Kastamonu"
|
||||
},
|
||||
{
|
||||
"ref_id" : 38,
|
||||
"licence_plate" : "38",
|
||||
"city_name" : "Kayseri"
|
||||
},
|
||||
{
|
||||
"ref_id" : 39,
|
||||
"licence_plate" : "39",
|
||||
"city_name" : "Kırklareli"
|
||||
},
|
||||
{
|
||||
"ref_id" : 40,
|
||||
"licence_plate" : "40",
|
||||
"city_name" : "Kırşehir"
|
||||
},
|
||||
{
|
||||
"ref_id" : 41,
|
||||
"licence_plate" : "41",
|
||||
"city_name" : "Kocaeli"
|
||||
},
|
||||
{
|
||||
"ref_id" : 42,
|
||||
"licence_plate" : "42",
|
||||
"city_name" : "Konya"
|
||||
},
|
||||
{
|
||||
"ref_id" : 43,
|
||||
"licence_plate" : "43",
|
||||
"city_name" : "Kütahya"
|
||||
},
|
||||
{
|
||||
"ref_id" : 44,
|
||||
"licence_plate" : "44",
|
||||
"city_name" : "Malatya"
|
||||
},
|
||||
{
|
||||
"ref_id" : 45,
|
||||
"licence_plate" : "45",
|
||||
"city_name" : "Manisa"
|
||||
},
|
||||
{
|
||||
"ref_id" : 46,
|
||||
"licence_plate" : "46",
|
||||
"city_name" : "Kahramanmaraş"
|
||||
},
|
||||
{
|
||||
"ref_id" : 47,
|
||||
"licence_plate" : "47",
|
||||
"city_name" : "Mardin"
|
||||
},
|
||||
{
|
||||
"ref_id" : 48,
|
||||
"licence_plate" : "48",
|
||||
"city_name" : "Muğla"
|
||||
},
|
||||
{
|
||||
"ref_id" : 49,
|
||||
"licence_plate" : "49",
|
||||
"city_name" : "Muş"
|
||||
},
|
||||
{
|
||||
"ref_id" : 50,
|
||||
"licence_plate" : "50",
|
||||
"city_name" : "Nevşehir"
|
||||
},
|
||||
{
|
||||
"ref_id" : 51,
|
||||
"licence_plate" : "51",
|
||||
"city_name" : "Niğde"
|
||||
},
|
||||
{
|
||||
"ref_id" : 52,
|
||||
"licence_plate" : "52",
|
||||
"city_name" : "Ordu"
|
||||
},
|
||||
{
|
||||
"ref_id" : 53,
|
||||
"licence_plate" : "53",
|
||||
"city_name" : "Rize"
|
||||
},
|
||||
{
|
||||
"ref_id" : 54,
|
||||
"licence_plate" : "54",
|
||||
"city_name" : "Sakarya"
|
||||
},
|
||||
{
|
||||
"ref_id" : 55,
|
||||
"licence_plate" : "55",
|
||||
"city_name" : "Samsun"
|
||||
},
|
||||
{
|
||||
"ref_id" : 56,
|
||||
"licence_plate" : "56",
|
||||
"city_name" : "Siirt"
|
||||
},
|
||||
{
|
||||
"ref_id" : 57,
|
||||
"licence_plate" : "57",
|
||||
"city_name" : "Sinop"
|
||||
},
|
||||
{
|
||||
"ref_id" : 58,
|
||||
"licence_plate" : "58",
|
||||
"city_name" : "Sivas"
|
||||
},
|
||||
{
|
||||
"ref_id" : 59,
|
||||
"licence_plate" : "59",
|
||||
"city_name" : "Tekirdağ"
|
||||
},
|
||||
{
|
||||
"ref_id" : 60,
|
||||
"licence_plate" : "60",
|
||||
"city_name" : "Tokat"
|
||||
},
|
||||
{
|
||||
"ref_id" : 61,
|
||||
"licence_plate" : "61",
|
||||
"city_name" : "Trabzon"
|
||||
},
|
||||
{
|
||||
"ref_id" : 62,
|
||||
"licence_plate" : "62",
|
||||
"city_name" : "Tunceli"
|
||||
},
|
||||
{
|
||||
"ref_id" : 63,
|
||||
"licence_plate" : "63",
|
||||
"city_name" : "Şanlıurfa"
|
||||
},
|
||||
{
|
||||
"ref_id" : 64,
|
||||
"licence_plate" : "64",
|
||||
"city_name" : "Uşak"
|
||||
},
|
||||
{
|
||||
"ref_id" : 65,
|
||||
"licence_plate" : "65",
|
||||
"city_name" : "Van"
|
||||
},
|
||||
{
|
||||
"ref_id" : 66,
|
||||
"licence_plate" : "66",
|
||||
"city_name" : "Yozgat"
|
||||
},
|
||||
{
|
||||
"ref_id" : 67,
|
||||
"licence_plate" : "67",
|
||||
"city_name" : "Zonguldak"
|
||||
},
|
||||
{
|
||||
"ref_id" : 68,
|
||||
"licence_plate" : "68",
|
||||
"city_name" : "Aksaray"
|
||||
},
|
||||
{
|
||||
"ref_id" : 69,
|
||||
"licence_plate" : "69",
|
||||
"city_name" : "Bayburt"
|
||||
},
|
||||
{
|
||||
"ref_id" : 70,
|
||||
"licence_plate" : "70",
|
||||
"city_name" : "Karaman"
|
||||
},
|
||||
{
|
||||
"ref_id" : 71,
|
||||
"licence_plate" : "71",
|
||||
"city_name" : "Kırıkkale"
|
||||
},
|
||||
{
|
||||
"ref_id" : 72,
|
||||
"licence_plate" : "72",
|
||||
"city_name" : "Batman"
|
||||
},
|
||||
{
|
||||
"ref_id" : 73,
|
||||
"licence_plate" : "73",
|
||||
"city_name" : "Şırnak"
|
||||
},
|
||||
{
|
||||
"ref_id" : 74,
|
||||
"licence_plate" : "74",
|
||||
"city_name" : "Bartın"
|
||||
},
|
||||
{
|
||||
"ref_id" : 75,
|
||||
"licence_plate" : "75",
|
||||
"city_name" : "Ardahan"
|
||||
},
|
||||
{
|
||||
"ref_id" : 76,
|
||||
"licence_plate" : "76",
|
||||
"city_name" : "Iğdır"
|
||||
},
|
||||
{
|
||||
"ref_id" : 77,
|
||||
"licence_plate" : "77",
|
||||
"city_name" : "Yalova"
|
||||
},
|
||||
{
|
||||
"ref_id" : 78,
|
||||
"licence_plate" : "78",
|
||||
"city_name" : "Karabük"
|
||||
},
|
||||
{
|
||||
"ref_id" : 79,
|
||||
"licence_plate" : "79",
|
||||
"city_name" : "Kilis"
|
||||
},
|
||||
{
|
||||
"ref_id" : 80,
|
||||
"licence_plate" : "80",
|
||||
"city_name" : "Osmaniye"
|
||||
},
|
||||
{
|
||||
"ref_id" : 81,
|
||||
"licence_plate" : "81",
|
||||
"city_name" : "Düzce"
|
||||
}
|
||||
]}
|
||||
1600
service_app_init/initialize_app/default_inits/countries.json
Normal file
1600
service_app_init/initialize_app/default_inits/countries.json
Normal file
File diff suppressed because it is too large
Load Diff
4794
service_app_init/initialize_app/default_inits/district.json
Normal file
4794
service_app_init/initialize_app/default_inits/district.json
Normal file
File diff suppressed because it is too large
Load Diff
28871
service_app_init/initialize_app/default_inits/locality.json
Normal file
28871
service_app_init/initialize_app/default_inits/locality.json
Normal file
File diff suppressed because it is too large
Load Diff
356646
service_app_init/initialize_app/default_inits/neighborhood.json
Normal file
356646
service_app_init/initialize_app/default_inits/neighborhood.json
Normal file
File diff suppressed because it is too large
Load Diff
6
service_app_init/initialize_app/default_inits/notes.txt
Normal file
6
service_app_init/initialize_app/default_inits/notes.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
cities:
|
||||
cities.ref_id == cities.city_code
|
||||
|
||||
district_code:
|
||||
district_code.ref_id == district_code.district_code
|
||||
139
service_app_init/initialize_app/event_initator.py
Normal file
139
service_app_init/initialize_app/event_initator.py
Normal file
@@ -0,0 +1,139 @@
|
||||
def create_all_events_from_actions():
|
||||
import api_events
|
||||
from databases.sql_models import Events
|
||||
|
||||
active_confirmed = dict(
|
||||
created_by="System",
|
||||
confirmed_by="System",
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
an_empty_list, duplicate_list = [], []
|
||||
|
||||
for event in events.__all__:
|
||||
event_selected = getattr(events, event)
|
||||
for (
|
||||
event_selected_key,
|
||||
event_selected_one,
|
||||
) in event_selected.__event_keys__.items():
|
||||
an_empty_list.append(event_selected_key)
|
||||
event_selected_function = getattr(event_selected, event_selected_one, None)
|
||||
|
||||
if endpoint_match := event_selected.action_match:
|
||||
if event_selected_function:
|
||||
selected_event = Events.find_one(
|
||||
event_type=event_selected.event_type,
|
||||
function_class=event,
|
||||
function_code=event_selected_key,
|
||||
endpoint_id=endpoint_match.id,
|
||||
endpoint_uu_id=str(endpoint_match.uu_id),
|
||||
**active_confirmed,
|
||||
)
|
||||
if not selected_event:
|
||||
created_event = Events.create(
|
||||
event_type=event_selected.event_type,
|
||||
function_class=event,
|
||||
function_code=event_selected_key,
|
||||
endpoint_id=endpoint_match.id,
|
||||
endpoint_uu_id=str(endpoint_match.uu_id),
|
||||
**active_confirmed,
|
||||
)
|
||||
print(f"Event created: {created_event.uu_id}")
|
||||
|
||||
for item in an_empty_list:
|
||||
if an_empty_list.count(item) > 1:
|
||||
if item not in duplicate_list:
|
||||
duplicate_list.append(item)
|
||||
|
||||
if duplicate_list:
|
||||
raise Exception(
|
||||
f"Duplicate events found: {duplicate_list}. Check events folder look for given uu-ids."
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def add_events_all_services_and_occupant_types():
|
||||
from database_sql_models import Services, Service2Events
|
||||
import tasks2events
|
||||
|
||||
active_confirmed = dict(
|
||||
created_by="System",
|
||||
confirmed_by="System",
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
for event_block in tasks2events.__all__:
|
||||
event_block_class = getattr(tasks2events, event_block)
|
||||
service_selected = Services.find_one(
|
||||
service_code=getattr(event_block_class, "service_code", None),
|
||||
)
|
||||
if not service_selected:
|
||||
raise Exception(f"{event_block_class.service_code} service is not found")
|
||||
|
||||
service_selected.update(
|
||||
related_responsibility=getattr(event_block_class, "related_code", None)
|
||||
)
|
||||
for block in event_block_class():
|
||||
event_id, event_uu_id = block
|
||||
Service2Events.find_or_create(
|
||||
service_id=service_selected.id,
|
||||
service_uu_id=str(service_selected.uu_id),
|
||||
event_id=event_id,
|
||||
event_uu_id=event_uu_id,
|
||||
**active_confirmed,
|
||||
)
|
||||
|
||||
|
||||
def add_events_to_system_super_user():
|
||||
from events.events_bind_services import ServiceBindEmployeeEventMethods
|
||||
from database_sql_models import Services, Employees, Staff
|
||||
|
||||
add_service = Services.find_one(service_code="SRE-SUE")
|
||||
if not add_service:
|
||||
raise Exception("Service not found")
|
||||
|
||||
find_staff = Staff.find_one(staff_code="SUE")
|
||||
if not find_staff:
|
||||
raise Exception("Super User not found")
|
||||
|
||||
add_employee = Employees.find_one(staff_id=find_staff.id)
|
||||
if not add_employee:
|
||||
raise Exception("Super User Employee not found")
|
||||
|
||||
ServiceBindEmployeeEventMethods.bind_services_employee(
|
||||
service_id=add_service.id,
|
||||
employee_id=add_employee.id,
|
||||
)
|
||||
|
||||
# super_user_service = Services.find_or_create(service_code="SRE-SU")
|
||||
# if not super_user_service:
|
||||
# raise Exception("Super user is service not found")
|
||||
#
|
||||
# user_default_service = Services.find_or_create(service_code="AUTH")
|
||||
# if not user_default_service:
|
||||
# raise Exception("AUTH service is not found")
|
||||
#
|
||||
# for item in SuperUserEventBlock():
|
||||
# event_id, event_uu_id = item
|
||||
# Service2Events.find_or_create(
|
||||
# service_id=super_user_service.id,
|
||||
# service_uu_id=str(super_user_service.uu_id),
|
||||
# event_id=event_id,
|
||||
# event_uu_id=event_uu_id,
|
||||
# **active_confirmed,
|
||||
# )
|
||||
#
|
||||
# for event_block in AuthDefaultEventBlock():
|
||||
# event_id, event_uu_id = event_block
|
||||
# Service2Events.find_or_create(
|
||||
# service_id=user_default_service.id,
|
||||
# service_uu_id=str(user_default_service.uu_id),
|
||||
# event_id=event_id,
|
||||
# event_uu_id=event_uu_id,
|
||||
# **active_confirmed,
|
||||
# )
|
||||
420
service_app_init/initialize_app/initialize_default_department.py
Normal file
420
service_app_init/initialize_app/initialize_default_department.py
Normal file
@@ -0,0 +1,420 @@
|
||||
from databases.no_sql_models.validations import DomainViaUser
|
||||
from databases import MongoQueryIdentity, Event2Employee, OccupantTypes
|
||||
|
||||
|
||||
def create_occupant_types_defaults():
|
||||
|
||||
"""
|
||||
occupant_category = mapped_column(String, server_default="")
|
||||
occupant_category_type = mapped_column(String, server_default="")
|
||||
occupant_is_unique = mapped_column(Boolean, server_default="0")
|
||||
"""
|
||||
list_occupant_types = [
|
||||
{
|
||||
"occupant_type": "Toplantı Başkanı",
|
||||
"occupant_description": "Toplantı Başkanı",
|
||||
"occupant_code": "MT-PRS",
|
||||
"occupant_category": "Toplantı",
|
||||
"occupant_category_type": "MT",
|
||||
"occupant_is_unique": True,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Toplantı Katip",
|
||||
"occupant_description": "Toplantıda tutanak tutan kişi",
|
||||
"occupant_code": "MT-WRT",
|
||||
"occupant_category": "Toplantı",
|
||||
"occupant_category_type": "MT",
|
||||
"occupant_is_unique": True,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Toplantı Katılımcısı",
|
||||
"occupant_description": "Toplantıda sadece katılan kişi",
|
||||
"occupant_code": "MT-ATT",
|
||||
"occupant_category": "Toplantı",
|
||||
"occupant_category_type": "MT",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Toplantı Danışman",
|
||||
"occupant_description": "Toplantıda danışmanlık yapan kişi",
|
||||
"occupant_code": "MT-ADV",
|
||||
"occupant_category": "Toplantı",
|
||||
"occupant_category_type": "MT",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Toplantı Seçilmiş Başkanı",
|
||||
"occupant_description": "Toplantı Seçilmiş Başkanı",
|
||||
"occupant_code": "MT-VPR",
|
||||
"occupant_category": "Toplantı",
|
||||
"occupant_category_type": "MT",
|
||||
"occupant_is_unique": True,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Daire Sahibi",
|
||||
"occupant_description": "Daire Sahibi",
|
||||
"occupant_code": "FL-OWN",
|
||||
"occupant_category": "Daire",
|
||||
"occupant_category_type": "FL",
|
||||
"occupant_is_unique": True,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Daire Kiracısı",
|
||||
"occupant_description": "Daire Kiracısı",
|
||||
"occupant_code": "FL-TEN",
|
||||
"occupant_category": "Daire",
|
||||
"occupant_category_type": "FL",
|
||||
"occupant_is_unique": True,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Daire Sakini",
|
||||
"occupant_description": "Daire Sakini",
|
||||
"occupant_code": "FL-RES",
|
||||
"occupant_category": "Daire",
|
||||
"occupant_category_type": "FL",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Daire Sakini Vekili",
|
||||
"occupant_description": "Daire Sakini Vekili",
|
||||
"occupant_code": "FL-REP",
|
||||
"occupant_category": "Daire",
|
||||
"occupant_category_type": "FL",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Bina Avukatı",
|
||||
"occupant_description": "Bina Avukatı",
|
||||
"occupant_code": "BU-ATT",
|
||||
"occupant_category": "Bina",
|
||||
"occupant_category_type": "BU",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Bina Avukatı Yardımcısı",
|
||||
"occupant_description": "Bina Avukatı Yardımcısı",
|
||||
"occupant_code": "BU-ATA",
|
||||
"occupant_category": "Bina",
|
||||
"occupant_category_type": "BU",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Bina Denetmen Yardımcısı",
|
||||
"occupant_description": "Bina Denetmen Yardımcısı",
|
||||
"occupant_code": "BU-SPA",
|
||||
"occupant_category": "Bina",
|
||||
"occupant_category_type": "BU",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Bina Denetmeni",
|
||||
"occupant_description": "Bina Denetmeni",
|
||||
"occupant_code": "BU-SPV",
|
||||
"occupant_category": "Bina",
|
||||
"occupant_category_type": "BU",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Bina Yönetici Yardımcısı",
|
||||
"occupant_description": "Bina Yönetici Yardımcısı",
|
||||
"occupant_code": "BU-MNA",
|
||||
"occupant_category": "Bina",
|
||||
"occupant_category_type": "BU",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Bina Yöneticisi",
|
||||
"occupant_description": "Bina Yöneticisi",
|
||||
"occupant_code": "BU-MNG",
|
||||
"occupant_category": "Bina",
|
||||
"occupant_category_type": "BU",
|
||||
"occupant_is_unique": True,
|
||||
},
|
||||
{
|
||||
"occupant_type": "Bina Muhasabecisi",
|
||||
"occupant_description": "Bina Muhasabecisi",
|
||||
"occupant_code": "BU-ACC",
|
||||
"occupant_category": "Bina",
|
||||
"occupant_category_type": "BU",
|
||||
"occupant_is_unique": False,
|
||||
},
|
||||
]
|
||||
|
||||
for list_occupant_type in list_occupant_types:
|
||||
OccupantTypes.find_or_create(**{"is_confirmed": True, **list_occupant_type})
|
||||
|
||||
|
||||
def create_application_defaults():
|
||||
|
||||
from database_sql_models import (
|
||||
Companies,
|
||||
Departments,
|
||||
Duty,
|
||||
Duties,
|
||||
Employees,
|
||||
People,
|
||||
Users,
|
||||
Staff,
|
||||
RelationshipDutyCompany,
|
||||
)
|
||||
|
||||
created_by, confirmed_by = "System", "System"
|
||||
company_management = Companies.find_or_create(
|
||||
**{
|
||||
"formal_name": "Evyos LTD",
|
||||
"public_name": "Evyos Verimlilik Sistemleri",
|
||||
"company_type": "LTD",
|
||||
"commercial_type": "Commercial",
|
||||
"tax_no": "123132123132",
|
||||
"company_tag": "Evyos",
|
||||
"default_lang_type": "TR",
|
||||
"default_money_type": "TL",
|
||||
"created_by": created_by,
|
||||
"confirmed_by": confirmed_by,
|
||||
"is_commercial": True,
|
||||
**dict(
|
||||
is_confirmed=True, active=True, deleted=False, is_notification_send=True
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
Duties.init_a_company_default_duties(
|
||||
company_id=company_management.id, company_uu_id=str(company_management.uu_id)
|
||||
)
|
||||
bulk_duty = Duty.find_one(
|
||||
duty_code="BULK",
|
||||
)
|
||||
|
||||
RelationshipDutyCompany.find_or_create(
|
||||
duties_id=bulk_duty.id,
|
||||
owner_id=company_management.id,
|
||||
member_id=company_management.id,
|
||||
parent_id=None,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
|
||||
it_dept = Departments.find_one(
|
||||
department_name="IT Department",
|
||||
department_code="ITD001",
|
||||
company_id=company_management.id,
|
||||
company_uu_id=str(company_management.uu_id),
|
||||
**dict(
|
||||
is_confirmed=True, active=True, deleted=False, is_notification_send=True
|
||||
),
|
||||
)
|
||||
|
||||
Duty.find_or_create(
|
||||
**dict(
|
||||
duty_name="Database Manager",
|
||||
duty_code="DM",
|
||||
duty_description="Database Manager",
|
||||
created_by=created_by,
|
||||
confirmed_by=confirmed_by,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
)
|
||||
Duty.find_or_create(
|
||||
**dict(
|
||||
duty_name="Network Manager",
|
||||
duty_code="NM",
|
||||
duty_description="Network Manager",
|
||||
created_by=created_by,
|
||||
confirmed_by=confirmed_by,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
)
|
||||
application_manager_duty = Duty.find_or_create(
|
||||
duty_name="Application Manager",
|
||||
duty_code="AM",
|
||||
duty_description="Application Manager",
|
||||
created_by=created_by,
|
||||
confirmed_by=confirmed_by,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
application_super_user_duty = Duty.find_or_create(
|
||||
duty_name="Super User",
|
||||
duty_code="SUE",
|
||||
duty_description="Super User",
|
||||
created_by=created_by,
|
||||
confirmed_by=confirmed_by,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
|
||||
application_manager_duties = Duties.find_or_create(
|
||||
department_id=it_dept.id,
|
||||
department_uu_id=str(it_dept.uu_id),
|
||||
duties_id=application_manager_duty.id,
|
||||
duties_uu_id=str(application_manager_duty.uu_id),
|
||||
company_id=company_management.id,
|
||||
company_uu_id=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
super_user_duties = Duties.find_or_create(
|
||||
department_id=it_dept.id,
|
||||
department_uu_id=str(it_dept.uu_id),
|
||||
duties_id=application_super_user_duty.id,
|
||||
duties_uu_id=str(application_manager_duty.uu_id),
|
||||
company_id=company_management.id,
|
||||
company_uu_id=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
|
||||
app_manager = People.find_or_create(
|
||||
**{
|
||||
"firstname": "Berkay Application Manager",
|
||||
"surname": "Karatay",
|
||||
"sex_code": "M",
|
||||
"middle_name": "",
|
||||
"father_name": "Father",
|
||||
"mother_name": "Mother",
|
||||
"country_code": "TR",
|
||||
"national_identity_id": "12312312312",
|
||||
"birth_place": "Ankara",
|
||||
"birth_date": "01.07.1990",
|
||||
"tax_no": "1231231231",
|
||||
"created_by": created_by,
|
||||
"confirmed_by": confirmed_by,
|
||||
**dict(
|
||||
is_confirmed=True, active=True, deleted=False, is_notification_send=True
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
sup_manager = People.find_or_create(
|
||||
**{
|
||||
"firstname": "Berkay Super User",
|
||||
"surname": "Karatay",
|
||||
"sex_code": "M",
|
||||
"middle_name": "",
|
||||
"father_name": "Father",
|
||||
"mother_name": "Mother",
|
||||
"country_code": "TR",
|
||||
"national_identity_id": "12312312313",
|
||||
"birth_place": "Ankara",
|
||||
"birth_date": "01.07.1990",
|
||||
"tax_no": "1231231232",
|
||||
"created_by": created_by,
|
||||
"confirmed_by": confirmed_by,
|
||||
**dict(
|
||||
is_confirmed=True, active=True, deleted=False, is_notification_send=True
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
application_manager_staff = Staff.find_or_create(
|
||||
staff_description="Application Manager",
|
||||
staff_name="Application Manager Employee",
|
||||
staff_code="AME",
|
||||
duties_id=application_manager_duties.id,
|
||||
duties_uu_id=str(application_manager_duty.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
super_user_staff = Staff.find_or_create(
|
||||
staff_description="Super User",
|
||||
staff_name="Super User Employee",
|
||||
staff_code="SUE",
|
||||
duties_id=super_user_duties.id,
|
||||
duties_uu_id=str(application_manager_duty.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
app_manager_employee = Employees.find_or_create(
|
||||
staff_id=application_manager_staff.id,
|
||||
staff_uu_id=str(application_manager_staff.uu_id),
|
||||
people_id=app_manager.id,
|
||||
people_uu_id=str(app_manager.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
super_user_employee = Employees.find_or_create(
|
||||
staff_id=super_user_staff.id,
|
||||
staff_uu_id=str(super_user_staff.uu_id),
|
||||
people_id=sup_manager.id,
|
||||
people_uu_id=str(sup_manager.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
app_manager_user = Users.find_or_create(
|
||||
person_id=app_manager.id,
|
||||
person_uu_id=str(app_manager.uu_id),
|
||||
user_tag=app_manager.person_tag,
|
||||
email="karatay.berkay.man@evyos.com.tr",
|
||||
phone_number="+901111111111",
|
||||
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
|
||||
created_by=created_by,
|
||||
confirmed_by=confirmed_by,
|
||||
related_company=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
if not app_manager_user.is_found:
|
||||
app_manager_user.reset_password_token()
|
||||
MongoQueryIdentity(
|
||||
company_uuid=company_management.uu_id
|
||||
).create_domain_via_user(
|
||||
payload=DomainViaUser(
|
||||
user_uu_id=str(app_manager_user.uu_id),
|
||||
main_domain="evyos.com.tr",
|
||||
other_domains_list=["evyos.com.tr"],
|
||||
)
|
||||
)
|
||||
|
||||
sup_manager_employee = Users.find_or_create(
|
||||
person_id=sup_manager.id,
|
||||
person_uu_id=str(sup_manager.uu_id),
|
||||
user_tag=sup_manager.person_tag,
|
||||
email="karatay.berkay.sup@evyos.com.tr",
|
||||
phone_number="+901111111112",
|
||||
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
|
||||
created_by=created_by,
|
||||
confirmed_by=confirmed_by,
|
||||
related_company=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
|
||||
if not sup_manager_employee.is_found:
|
||||
sup_manager_employee.reset_password_token()
|
||||
MongoQueryIdentity(
|
||||
company_uuid=company_management.uu_id
|
||||
).create_domain_via_user(
|
||||
payload=DomainViaUser(
|
||||
user_uu_id=str(sup_manager_employee.uu_id),
|
||||
main_domain="evyos.com.tr",
|
||||
other_domains_list=["evyos.com.tr"],
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,185 @@
|
||||
from json import loads
|
||||
from os import path
|
||||
|
||||
|
||||
path_to_folder = "initialize_app/default_inits"
|
||||
list_of_snippets = [
|
||||
"countries.json",
|
||||
"cities.json",
|
||||
"district.json",
|
||||
"locality.json",
|
||||
"neighborhood.json",
|
||||
]
|
||||
|
||||
|
||||
def create_country_defaults(path_to_joined_folder, confirmed_by_system):
|
||||
from database_sql_models import (
|
||||
AddressCountry,
|
||||
)
|
||||
|
||||
with open(path_to_joined_folder("countries.json"), "r") as file:
|
||||
countries = loads(file.read())
|
||||
|
||||
print("Countries are read from file ------------------")
|
||||
if not countries:
|
||||
print("Countries json file is empty")
|
||||
|
||||
for country in countries.get("tr_co"):
|
||||
country_obj = AddressCountry.find_or_create(
|
||||
country_name=country.get("country_name"),
|
||||
country_code=country.get("country_code"),
|
||||
ref_id=str(country.get("ref_id")),
|
||||
**confirmed_by_system,
|
||||
)
|
||||
|
||||
|
||||
def create_cities_defaults(path_to_joined_folder, confirmed_by_system, state_id):
|
||||
from database_sql_models import (
|
||||
AddressCity,
|
||||
)
|
||||
|
||||
with open(path_to_joined_folder("cities.json"), "r") as file:
|
||||
cities = loads(file.read())
|
||||
print("Cities are read from file ------------------")
|
||||
if not cities:
|
||||
print("Cities json file is empty")
|
||||
|
||||
for city in cities.get("cities"):
|
||||
city_obj = AddressCity.find_or_create(
|
||||
state_id=state_id,
|
||||
city_name=city.get("city_name"),
|
||||
city_code=city.get("licence_plate"),
|
||||
licence_plate=city.get("licence_plate"),
|
||||
ref_id=str(city.get("ref_id")),
|
||||
**confirmed_by_system,
|
||||
)
|
||||
print(f"City {city_obj.city_name} is created")
|
||||
|
||||
|
||||
def create_district_defaults(path_to_joined_folder, confirmed_by_system):
|
||||
from database_sql_models import (
|
||||
AddressCity,
|
||||
AddressDistrict,
|
||||
)
|
||||
|
||||
with open(path_to_joined_folder("district.json"), "r") as file:
|
||||
districts = loads(file.read())
|
||||
print("Districts are read from file ------------------")
|
||||
if not districts:
|
||||
print("Districts json file is empty")
|
||||
|
||||
for district in districts.get("tr_ilce"):
|
||||
city = AddressCity.find_one(ref_id=str(district.get("city_id")))
|
||||
if not city:
|
||||
print(f"City with ref_id {district.get('city_id')} is not found")
|
||||
|
||||
district_obj = AddressDistrict.find_or_create(
|
||||
city_id=city.id,
|
||||
district_name=district.get("district_name"),
|
||||
district_code=str(district.get("ref_id")),
|
||||
ref_id=str(district.get("ref_id")),
|
||||
**confirmed_by_system,
|
||||
)
|
||||
print(f"District {district_obj} is created")
|
||||
|
||||
|
||||
def create_locality_defaults(path_to_joined_folder, confirmed_by_system):
|
||||
from database_sql_models import (
|
||||
AddressDistrict,
|
||||
AddressLocality,
|
||||
)
|
||||
|
||||
with open(path_to_joined_folder("locality.json"), "r") as file:
|
||||
localities = loads(file.read())
|
||||
print("Localities are read from file ------------------")
|
||||
if not localities:
|
||||
print("Localities json file is empty")
|
||||
|
||||
for locality in localities.get("tr_semt"):
|
||||
district = AddressDistrict.find_one(ref_id=str(locality.get("district_id")))
|
||||
if not district:
|
||||
print(
|
||||
f"District with ref_id {locality.get('district_id')} is not found"
|
||||
)
|
||||
|
||||
locality_obj = AddressLocality.find_or_create(
|
||||
district_id=district.id,
|
||||
locality_name=locality.get("locality_name"),
|
||||
locality_code=str(locality.get("post_code")),
|
||||
ref_id=str(locality.get("ref_id")),
|
||||
**confirmed_by_system,
|
||||
)
|
||||
print(f"Locality {locality_obj} is created")
|
||||
|
||||
|
||||
def create_neighborhood_defaults(path_to_joined_folder, confirmed_by_system):
|
||||
from database_sql_models import (
|
||||
AddressLocality,
|
||||
AddressNeighborhood,
|
||||
AddressDistrict,
|
||||
)
|
||||
|
||||
with open(path_to_joined_folder("neighborhood.json"), "r") as file:
|
||||
neighborhoods = loads(file.read())
|
||||
print("Neighborhoods are read from file ------------------")
|
||||
if not neighborhoods:
|
||||
print("Neighborhoods json file is empty")
|
||||
|
||||
for neighborhood in neighborhoods.get("tr_mahalle_koy"):
|
||||
locality = AddressLocality.find_one(
|
||||
ref_id=str(neighborhood.get("locality_id"))
|
||||
)
|
||||
district = AddressDistrict.find_one(
|
||||
ref_id=str(neighborhood.get("district_id"))
|
||||
)
|
||||
|
||||
if not district:
|
||||
print(
|
||||
f"District with ref_id {neighborhood.get('district_id')} is not found"
|
||||
)
|
||||
|
||||
neighborhood_obj = AddressNeighborhood.find_or_create(
|
||||
locality_id=locality.id if locality else None,
|
||||
district_id=district.id,
|
||||
neighborhood_name=neighborhood.get("neighborhood_name"),
|
||||
neighborhood_code=str(neighborhood.get("ref_id")),
|
||||
ref_id=str(neighborhood.get("ref_id")),
|
||||
**confirmed_by_system,
|
||||
)
|
||||
print(f"Neighborhood {neighborhood_obj} is created")
|
||||
|
||||
|
||||
def create_identity_address_defaults():
|
||||
from database_sql_models import (
|
||||
AddressCountry,
|
||||
AddressState,
|
||||
)
|
||||
|
||||
print("Creating address defaults ------------------")
|
||||
|
||||
path_to_joined_folder = lambda json_name: path.join(path_to_folder, json_name)
|
||||
confirmed_by_system = dict(
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
created_by="System",
|
||||
confirmed_by="System",
|
||||
)
|
||||
|
||||
create_country_defaults(path_to_joined_folder, confirmed_by_system)
|
||||
|
||||
turkey = AddressCountry.find_one(ref_id="90")
|
||||
turkey_state = AddressState.find_or_create(
|
||||
state_name="Türkiye",
|
||||
state_code="TR",
|
||||
country_id=turkey.id,
|
||||
**confirmed_by_system,
|
||||
)
|
||||
|
||||
create_cities_defaults(path_to_joined_folder, confirmed_by_system, turkey_state.id)
|
||||
create_district_defaults(path_to_joined_folder, confirmed_by_system)
|
||||
create_locality_defaults(path_to_joined_folder, confirmed_by_system)
|
||||
create_neighborhood_defaults(path_to_joined_folder, confirmed_by_system)
|
||||
print("All address defaults are created ------------------")
|
||||
return True
|
||||
242
service_app_init/initialize_app/initiator.py
Normal file
242
service_app_init/initialize_app/initiator.py
Normal file
@@ -0,0 +1,242 @@
|
||||
def init_api_enums_build_types():
|
||||
from database_sql_models import BuildTypes
|
||||
from database_sql_models.others.enums import ApiEnumDropdown
|
||||
from validations import InsertBuildTypes
|
||||
|
||||
insert_types = [
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT_KZN",
|
||||
"type_name": "Apartman Kazan Dairesi",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT_GRJ",
|
||||
"type_name": "Apartman Garaj",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT_DP",
|
||||
"type_name": "Apartman Depo",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "DAIRE",
|
||||
"type_name": "Apartman Dairesi",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT",
|
||||
"type_name": "Apartman Binası",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT_YNT",
|
||||
"type_name": "Apartman Yönetimi",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT_PRK",
|
||||
"type_name": "Apartman Açık Park Alanı",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT_YSL",
|
||||
"type_name": "Apartman Yeşil Alan",
|
||||
"lang": "TR",
|
||||
},
|
||||
{
|
||||
"function_code": "EVYOS",
|
||||
"type_code": "APT_YOL",
|
||||
"type_name": "Apartman Ara Yol",
|
||||
"lang": "TR",
|
||||
},
|
||||
]
|
||||
for insert_type in insert_types:
|
||||
build_types = InsertBuildTypes(
|
||||
function_code="EVYOS",
|
||||
lang=insert_type["lang"],
|
||||
type_code=str(insert_type["type_code"]).upper(),
|
||||
type_name=insert_type["type_name"],
|
||||
is_confirmed=True,
|
||||
)
|
||||
BuildTypes.find_or_create(**build_types.model_dump())
|
||||
|
||||
insert_enums = [
|
||||
{"enum_class": "BuildDuesTypes", "type_code": "BDT-D", "type_name": "Debit"},
|
||||
{
|
||||
"enum_class": "BuildDuesTypes",
|
||||
"type_code": "BDT-A",
|
||||
"type_name": "Add Debit",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildDuesTypes",
|
||||
"type_code": "BDT-R",
|
||||
"type_name": "Renovation",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildDuesTypes",
|
||||
"type_code": "BDT-L",
|
||||
"type_name": "Lawyer expence",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildDuesTypes",
|
||||
"type_code": "BDT-sf",
|
||||
"type_name": "Service fee",
|
||||
},
|
||||
{
|
||||
"enum_class": "AccountingReceiptTypes",
|
||||
"type_code": "ART-A",
|
||||
"type_name": "Kasa Tahsil Fişi",
|
||||
},
|
||||
{
|
||||
"enum_class": "AccountingReceiptTypes",
|
||||
"type_code": "ART-E",
|
||||
"type_name": "Kasa Tediye Fişi",
|
||||
},
|
||||
{
|
||||
"enum_class": "AccountingReceiptTypes",
|
||||
"type_code": "ART-M",
|
||||
"type_name": "Mahsup Fişi",
|
||||
},
|
||||
{
|
||||
"enum_class": "AccountingReceiptTypes",
|
||||
"type_code": "ART-O",
|
||||
"type_name": "Açılış Fişi",
|
||||
},
|
||||
{
|
||||
"enum_class": "AccountingReceiptTypes",
|
||||
"type_code": "ART-C",
|
||||
"type_name": "Kapanış Fişi",
|
||||
},
|
||||
{"enum_class": "IbanBudgetType", "type_code": "IBT-I", "type_name": "Iban"},
|
||||
{"enum_class": "IbanBudgetType", "type_code": "IBT-B", "type_name": "Budget"},
|
||||
{
|
||||
"enum_class": "IbanBudgetType",
|
||||
"type_code": "IBT-TR",
|
||||
"type_name": "Transaction records",
|
||||
},
|
||||
{"enum_class": "ProjectTypes", "type_code": "R", "type_name": "Tadilat"},
|
||||
{
|
||||
"enum_class": "ProjectTypes",
|
||||
"type_code": "PT-C",
|
||||
"type_name": "Mahkeme süreçleri",
|
||||
},
|
||||
{
|
||||
"enum_class": "ProjectTypes",
|
||||
"type_code": "PT-Z",
|
||||
"type_name": "Sıfır Bakiye",
|
||||
},
|
||||
{
|
||||
"enum_class": "EdmBudgetType",
|
||||
"type_code": "PT-B",
|
||||
"type_name": "Banka records",
|
||||
},
|
||||
{
|
||||
"enum_class": "EdmBudgetType",
|
||||
"type_code": "PT-S",
|
||||
"type_name": "Sistem kaydı",
|
||||
},
|
||||
{
|
||||
"enum_class": "EdmBudgetType",
|
||||
"type_code": "EBT-C",
|
||||
"type_name": "Build, Flat or Site records",
|
||||
},
|
||||
{"enum_class": "ExpireType", "type_code": "1", "type_name": "daily"},
|
||||
{"enum_class": "ExpireType", "type_code": "7", "type_name": "weekly"},
|
||||
{"enum_class": "ExpireType", "type_code": "30", "type_name": "monthly"},
|
||||
{"enum_class": "ExpireType", "type_code": "90", "type_name": "quarter"},
|
||||
{"enum_class": "ExpireType", "type_code": "180", "type_name": "six_month"},
|
||||
{"enum_class": "ExpireType", "type_code": "365", "type_name": "yearly"},
|
||||
{"enum_class": "PhoneType", "type_code": "M", "type_name": "cep tel"},
|
||||
{"enum_class": "PhoneType", "type_code": "L", "type_name": "sabit telefon"},
|
||||
{"enum_class": "PhoneType", "type_code": "F", "type_name": "fax"},
|
||||
{"enum_class": "PhoneType", "type_code": "C", "type_name": "santral"},
|
||||
{
|
||||
"enum_class": "PhoneType",
|
||||
"type_code": "G",
|
||||
"type_name": "ülke genelindeki hatlar 444",
|
||||
},
|
||||
{"enum_class": "PerComType", "type_code": "1", "type_name": "Person"},
|
||||
{"enum_class": "PerComType", "type_code": "2", "type_name": "Company"},
|
||||
{"enum_class": "Directions", "type_code": "NN", "type_name": "North"},
|
||||
{"enum_class": "Directions", "type_code": "EE", "type_name": "East"},
|
||||
{"enum_class": "Directions", "type_code": "SS", "type_name": "South"},
|
||||
{"enum_class": "Directions", "type_code": "WW", "type_name": "West"},
|
||||
{"enum_class": "Directions", "type_code": "NE", "type_name": "North East"},
|
||||
{"enum_class": "Directions", "type_code": "NW", "type_name": "North West"},
|
||||
{"enum_class": "Directions", "type_code": "SE", "type_name": "South East"},
|
||||
{"enum_class": "Directions", "type_code": "SW", "type_name": "South West"},
|
||||
{
|
||||
"enum_class": "MeetingTypes",
|
||||
"type_code": "MT-RBM",
|
||||
"type_name": "Regular Building Meeting",
|
||||
},
|
||||
{
|
||||
"enum_class": "MeetingTypes",
|
||||
"type_code": "MT-DBM",
|
||||
"type_name": "Disaster Building Meeting",
|
||||
},
|
||||
{
|
||||
"enum_class": "MeetingTypes",
|
||||
"type_code": "MT-EBM",
|
||||
"type_name": "Emergency Building Meeting",
|
||||
},
|
||||
{
|
||||
"enum_class": "DebitTypes",
|
||||
"type_code": "DT-D",
|
||||
"type_name": "Debit Sender",
|
||||
},
|
||||
{
|
||||
"enum_class": "DebitTypes",
|
||||
"type_code": "DT-R",
|
||||
"type_name": "Credit Receiver",
|
||||
},
|
||||
{
|
||||
"enum_class": "DebitTypes",
|
||||
"type_code": "DT-Z",
|
||||
"type_name": "Zero Balance",
|
||||
},
|
||||
{
|
||||
"enum_class": "ProjectTeamTypes",
|
||||
"type_code": "PTT-LDR",
|
||||
"type_name": "Project Leader",
|
||||
},
|
||||
{
|
||||
"enum_class": "ProjectTeamTypes",
|
||||
"type_code": "PTT-RSP",
|
||||
"type_name": "Project Responsible",
|
||||
},
|
||||
{
|
||||
"enum_class": "ProjectTeamTypes",
|
||||
"type_code": "PTT-EMP",
|
||||
"type_name": "Project Employee",
|
||||
},
|
||||
{
|
||||
"enum_class": "ProjectTeamTypes",
|
||||
"type_code": "PTT-FIN",
|
||||
"type_name": "Project Finance Responsible",
|
||||
},
|
||||
]
|
||||
for insert_enum in insert_enums:
|
||||
ApiEnumDropdown.find_or_create(
|
||||
enum_class=insert_enum["enum_class"],
|
||||
value=insert_enum["type_name"],
|
||||
key=str(insert_enum["type_code"]).upper(),
|
||||
description=insert_enum["type_name"],
|
||||
)
|
||||
|
||||
# for insert_meeting_type in insert_meeting_types:
|
||||
# ApiEnumDropdown.find_or_create(
|
||||
# enum_class=insert_meeting_type["enum_class"],
|
||||
# value=insert_meeting_type["value"],
|
||||
# key=str(insert_meeting_type["key"]).upper(),
|
||||
# description=insert_meeting_type["description"],
|
||||
# )
|
||||
44
service_app_init/initialize_app/model_initator.py
Normal file
44
service_app_init/initialize_app/model_initator.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import validations
|
||||
|
||||
# from database_sql_models.event.event import Models, ModelEntities
|
||||
|
||||
|
||||
def get_upper_only(text: str):
|
||||
sc_letter, th_letter = text[1], text[2]
|
||||
upper_letters = "".join(letter for letter in text if str(letter).isupper())
|
||||
return upper_letters[0] + sc_letter + th_letter + upper_letters[1:]
|
||||
|
||||
|
||||
def copy_validations_to_database():
|
||||
for validation in validations.__all__:
|
||||
validation_pydantic = getattr(validations, validation)
|
||||
model_dict = {
|
||||
"model_owner": "system",
|
||||
"model_type": "BaseModel",
|
||||
"model_name": validation_pydantic.__name__,
|
||||
"model_description": "",
|
||||
"model_code": get_upper_only(validation_pydantic.__name__),
|
||||
"is_confirmed": True,
|
||||
"deleted": False,
|
||||
"active": True,
|
||||
}
|
||||
# created_model = Models.find_or_create(**model_dict)
|
||||
fields = validation_pydantic.model_fields
|
||||
for field, info in fields.items():
|
||||
default_value = (
|
||||
None
|
||||
if getattr(info, "default").__str__() == "PydanticUndefined"
|
||||
else getattr(info, "default")
|
||||
)
|
||||
model_field_dict = {
|
||||
"field_name": field,
|
||||
"field_type": str(info.annotation),
|
||||
"field_required": bool(info.is_required()),
|
||||
"model_id": created_model.id,
|
||||
"is_confirmed": True,
|
||||
"deleted": False,
|
||||
"active": True,
|
||||
}
|
||||
if default_value:
|
||||
model_field_dict.update({"field_default_value": str(default_value)})
|
||||
# ModelEntities.find_or_create(**model_field_dict)
|
||||
333
service_app_init/initialize_app/modules_and_services_init.py
Normal file
333
service_app_init/initialize_app/modules_and_services_init.py
Normal file
@@ -0,0 +1,333 @@
|
||||
import typing
|
||||
|
||||
from database_sql_models import (
|
||||
Modules,
|
||||
Duty,
|
||||
Services,
|
||||
Service2Events,
|
||||
OccupantTypes,
|
||||
EndpointRestriction,
|
||||
)
|
||||
|
||||
|
||||
def create_endpoints_from_api_functions():
|
||||
from app import app as api_app
|
||||
|
||||
for route in api_app.routes:
|
||||
route_path, route_summary = (
|
||||
str(getattr(route, "path")),
|
||||
str(getattr(route, "name")) or "",
|
||||
)
|
||||
# if route_path in Config.INSECURE_PATHS:
|
||||
# continue
|
||||
# print('route_path ', route_path, 'route_summary', route_summary)
|
||||
create_dict = dict(
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
methods = [method.lower() for method in getattr(route, "methods")]
|
||||
for route_method in methods:
|
||||
restriction = EndpointRestriction.find_or_create(
|
||||
**dict(
|
||||
endpoint_method=route_method,
|
||||
endpoint_name=route_path,
|
||||
endpoint_desc=route_summary.replace("_", " "),
|
||||
endpoint_function=route_summary,
|
||||
**create_dict,
|
||||
)
|
||||
)
|
||||
if not restriction.is_found:
|
||||
restriction.endpoint_code = f"AR{str(restriction.id).zfill(3)}"
|
||||
restriction.save()
|
||||
return
|
||||
|
||||
|
||||
def create_services_building(module_dict: dict):
|
||||
"""
|
||||
4. Service [Bina] Yönetim - OPTIONAL
|
||||
5. Service [Bina] Yasal İşler - OPTIONAL
|
||||
6. Service [Bina] Temizlik - OPTIONAL
|
||||
7. Service [Bina] Isınma Sistemi - OPTIONAL
|
||||
8. Service [Bina] Güvenlik Sistemi + OPTIONAL
|
||||
9. Service [Bina] Bakım + OPTIONAL
|
||||
10. Service [Bina] Onarım + OPTIONAL
|
||||
11 Service [Bina] Gözlem + OPTIONAL
|
||||
"""
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Management",
|
||||
service_description="Building Management Service",
|
||||
service_code="SR-BLD-MNG",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Legal Affairs",
|
||||
service_description="Building Legal Affairs Service",
|
||||
service_code="SR-BLD-LGL",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Cleaning",
|
||||
service_description="Building Cleaning Service",
|
||||
service_code="SR-BLD-CLN",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Heating System",
|
||||
service_description="Building Heating System Service",
|
||||
service_code="SR-BLD-HTS",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Security System",
|
||||
service_description="Building Security System Service",
|
||||
service_code="SR-BLD-SEC",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Maintenance",
|
||||
service_description="Building Maintenance Service",
|
||||
service_code="SR-BLD-MNT",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Repair",
|
||||
service_description="Building Repair Service",
|
||||
service_code="SR-BLD-RPR",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Building Observation",
|
||||
service_description="Building Observation Service",
|
||||
service_code="SR-BLD-OBS",
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def create_services_flat(module_dict: dict):
|
||||
"""
|
||||
11. Service [Daire] Kiralama + OPTIONAL
|
||||
12. Service [Daire] Satış + OPTIONAL
|
||||
13. Service [Daire] Tadiilat + OPTIONAL
|
||||
14. Service [Daire] Temizlik + OPTIONAL
|
||||
11 Service [Daire] Gözlem + OPTIONAL
|
||||
"""
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Flat Rent",
|
||||
service_description="Flat Rent Service",
|
||||
service_code="SR-FLT-RNT",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Flat Sale",
|
||||
service_description="Flat Sale Service",
|
||||
service_code="SR-FLT-SAL",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Flat Renovation",
|
||||
service_description="Flat Renovation Service",
|
||||
service_code="SR-FLT-RNV",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Flat Cleaning",
|
||||
service_description="Flat Cleaning Service",
|
||||
service_code="SR-FLT-CLN",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Flat Observation",
|
||||
service_description="Flat Observation Service",
|
||||
service_code="SR-FLT-OBS",
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
def create_services_authenticate(module_dict: dict):
|
||||
authentication_service = Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Authenticate",
|
||||
service_description="Authenticate Service",
|
||||
service_code="AUTH",
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
def create_services_meeting(module_dict: dict):
|
||||
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Meeting Regular",
|
||||
service_description="Regular Meeting Service",
|
||||
service_code="MEET-REG",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Meeting Emergency",
|
||||
service_description="Emergency Meeting Service",
|
||||
service_code="MEET-EMR",
|
||||
)
|
||||
Services.find_or_create(
|
||||
**module_dict,
|
||||
service_name="Meeting Demand",
|
||||
service_description="Demand Meeting Service",
|
||||
service_code="MEET-DMN",
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def create_modules_and_services_and_actions():
|
||||
|
||||
erp_module = Modules.find_or_create(
|
||||
**{
|
||||
"module_name": "EVYOS ERP",
|
||||
"module_description": "EVYOS Enterprise Resource Planning",
|
||||
"module_code": "EVYOS-ERP",
|
||||
"module_layer": 1,
|
||||
"is_default_module": False,
|
||||
"is_confirmed": True,
|
||||
}
|
||||
)
|
||||
|
||||
build_module = Modules.find_or_create(
|
||||
**{
|
||||
"module_name": "Bina Yönetim Modülü",
|
||||
"module_description": "Building Management Module",
|
||||
"module_code": "BLD-MNG",
|
||||
"module_layer": 1,
|
||||
"is_default_module": False,
|
||||
"is_confirmed": True,
|
||||
}
|
||||
)
|
||||
|
||||
user_module = Modules.find_or_create(
|
||||
**{
|
||||
"module_name": "Kullancı Modülü",
|
||||
"module_description": "Kullanıcı Genel Modülü",
|
||||
"module_code": "USR-PUB",
|
||||
"module_layer": 1,
|
||||
"is_default_module": True,
|
||||
"is_confirmed": True,
|
||||
}
|
||||
)
|
||||
|
||||
erp_module_module_dict = dict(
|
||||
module_id=erp_module.id,
|
||||
module_uu_id=str(erp_module.uu_id),
|
||||
is_confirmed=True,
|
||||
)
|
||||
build_module_module_dict = dict(
|
||||
module_id=build_module.id,
|
||||
module_uu_id=str(build_module.uu_id),
|
||||
is_confirmed=True,
|
||||
)
|
||||
user_module_module_dict = dict(
|
||||
module_id=user_module.id,
|
||||
module_uu_id=str(user_module.uu_id),
|
||||
is_confirmed=True,
|
||||
)
|
||||
|
||||
duty_objects = Duty.filter_all(
|
||||
Duty.duty_code.notin_(["BULK", "OCCUPANT", "BM0001"])
|
||||
)
|
||||
for duty_object in duty_objects.data:
|
||||
Services.find_or_create(
|
||||
**erp_module_module_dict,
|
||||
service_name=duty_object.duty_name,
|
||||
service_description=duty_object.duty_description,
|
||||
service_code=f"SRE-{duty_object.duty_code}",
|
||||
)
|
||||
|
||||
occupant_types = OccupantTypes.filter_all()
|
||||
for occupant_type in occupant_types.data:
|
||||
Services.find_or_create(
|
||||
**build_module_module_dict,
|
||||
service_name=occupant_type.occupant_type,
|
||||
service_description=occupant_type.occupant_description,
|
||||
service_code=f"SRO-{occupant_type.occupant_code}",
|
||||
)
|
||||
|
||||
create_services_authenticate(module_dict=user_module_module_dict)
|
||||
create_services_meeting(module_dict=build_module_module_dict)
|
||||
create_services_building(module_dict=build_module_module_dict)
|
||||
create_services_flat(module_dict=build_module_module_dict)
|
||||
|
||||
return
|
||||
#
|
||||
# super_admin_module_created=None
|
||||
# create_address_service(add_module=super_admin_module_created)
|
||||
# create_post_code_service(add_module=super_admin_module_created)
|
||||
# create_authentication_service(add_module=super_admin_module_created)
|
||||
# create_build_service(add_module=super_admin_module_created)
|
||||
# create_build_parts_service(add_module=super_admin_module_created)
|
||||
# create_build_area_service(add_module=super_admin_module_created)
|
||||
# create_build_sites_service(add_module=super_admin_module_created)
|
||||
# # create_build_types_service(add_module=super_admin_module_created)
|
||||
# create_living_spaces_service(add_module=super_admin_module_created)
|
||||
# create_company_service(add_module=super_admin_module_created)
|
||||
# create_department_service(add_module=super_admin_module_created)
|
||||
# create_duties_service(add_module=super_admin_module_created)
|
||||
# create_duty_service(add_module=super_admin_module_created)
|
||||
# create_employee_service(add_module=super_admin_module_created)
|
||||
# create_staff_service(add_module=super_admin_module_created)
|
||||
#
|
||||
# create_decision_book_service(add_module=super_admin_module_created)
|
||||
# create_decision_book_items_service(add_module=super_admin_module_created)
|
||||
# create_build_decision_book_items_debits_service(
|
||||
# add_module=super_admin_module_created
|
||||
# )
|
||||
# # create_build_decision_book_person_service(add_module=super_admin_module_created)
|
||||
# # create_build_decision_book_person_service(add_module=super_admin_module_created)
|
||||
#
|
||||
# create_actions_service(add_module=super_admin_module_created)
|
||||
# create_events_service(add_module=super_admin_module_created)
|
||||
# create_model_service(add_module=super_admin_module_created)
|
||||
# create_model_entities_service(add_module=super_admin_module_created)
|
||||
# create_modules_service(add_module=super_admin_module_created)
|
||||
# create_services_service(add_module=super_admin_module_created)
|
||||
# create_event_to_bind_people_service(add_module=super_admin_module_created)
|
||||
# create_bind_service_service(add_module=super_admin_module_created)
|
||||
#
|
||||
# create_people_service(add_module=super_admin_module_created)
|
||||
# create_project_decision_book_service(add_module=super_admin_module_created)
|
||||
# create_project_decision_book_items_service(add_module=super_admin_module_created)
|
||||
# create_build_project_decision_book_items_debits_service(
|
||||
# add_module=super_admin_module_created
|
||||
# )
|
||||
# create_build_project_decision_book_person_service(
|
||||
# add_module=super_admin_module_created
|
||||
# )
|
||||
# create_endpoint_restriction_service(add_module=super_admin_module_created)
|
||||
# create_users_service(add_module=super_admin_module_created)
|
||||
#
|
||||
# return
|
||||
|
||||
# account_service_endpoint = EndpointRestriction.find_one(
|
||||
# endpoint_function="account_service"
|
||||
# )
|
||||
# account_service = Services.find_or_create(
|
||||
# service_name="Account",
|
||||
# service_description="Account Service",
|
||||
# service_code="ACC",
|
||||
# )
|
||||
# address_service = Services.find_or_create(
|
||||
# service_name="Address",
|
||||
# service_description="Address Service",
|
||||
# service_code="ADD",
|
||||
# )
|
||||
# api_service = Services.find_or_create(
|
||||
# service_name="Api",
|
||||
# service_description="Api Service",
|
||||
# service_code="API",
|
||||
# )
|
||||
# application_service = Services.find_or_create(
|
||||
# service_name="Application",
|
||||
# service_description="Application Service",
|
||||
# service_code="APP",
|
||||
# )
|
||||
1741
service_app_init/initialize_app/old_func.py
Normal file
1741
service_app_init/initialize_app/old_func.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user