migrator functions updated

This commit is contained in:
2024-11-11 22:23:07 +03:00
parent f6135ced5f
commit ffb85a62f6
56 changed files with 567 additions and 485 deletions

View File

@@ -19,9 +19,11 @@ active_confirmed = dict(
is_notification_send=True,
)
def create_all_events_from_actions():
import api_events.events as events
from databases import EndpointRestriction
an_empty_list, duplicate_list = [], []
for event in events.__all__:
@@ -37,18 +39,20 @@ def create_all_events_from_actions():
f"Endpoint not found in {event_selected.__name__} class"
)
endpoint_restriction = EndpointRestriction.filter_one(
EndpointRestriction.endpoint_name.ilike(f"%{event_selected.action.endpoint}%"),
system=True
EndpointRestriction.endpoint_name.ilike(
f"%{event_selected.action.endpoint}%"
),
system=True,
).data
if endpoint_restriction:
if event_selected_function:
selected_event = Events.filter_one(
Events.event_type==event_selected.event_type,
Events.function_class==event,
Events.function_code==event_selected_key,
Events.endpoint_id==endpoint_restriction.id,
Events.endpoint_uu_id==str(endpoint_restriction.uu_id),
system=True
Events.event_type == event_selected.event_type,
Events.function_class == event,
Events.function_code == event_selected_key,
Events.endpoint_id == endpoint_restriction.id,
Events.endpoint_uu_id == str(endpoint_restriction.uu_id),
system=True,
).data
if not selected_event:
created_event = Events.find_or_create(
@@ -57,7 +61,7 @@ def create_all_events_from_actions():
function_code=event_selected_key,
endpoint_id=endpoint_restriction.id,
endpoint_uu_id=str(endpoint_restriction.uu_id),
**active_confirmed
**active_confirmed,
)
Events.save()
print(f"Event created: {created_event.uu_id}")
@@ -80,8 +84,8 @@ def add_events_all_services_and_occupant_types():
for event_block in tasks2events.__all__:
event_block_class = getattr(tasks2events, event_block)
service_selected = Services.filter_one(
Services.service_code==getattr(event_block_class, "service_code", None),
system=True
Services.service_code == getattr(event_block_class, "service_code", None),
system=True,
).data
if not service_selected:
raise Exception(f"{event_block_class.service_code} service is not found")

View File

@@ -140,7 +140,9 @@ def create_occupant_types_defaults():
]
for list_occupant_type in list_occupant_types:
created_type = OccupantTypes.find_or_create(**{"is_confirmed": True, **list_occupant_type})
created_type = OccupantTypes.find_or_create(
**{"is_confirmed": True, **list_occupant_type}
)
created_type.save()
created_type.is_confirmed = True
created_type.save()
@@ -401,10 +403,8 @@ def create_application_defaults():
is_notification_send=True,
)
created_list.append(app_manager_user)
app_manager_user.reset_password_token()
mongo_engine = MongoQueryIdentity(
company_uuid=company_management.uu_id
)
app_manager_user.reset_password_token(found_user=app_manager_user)
mongo_engine = MongoQueryIdentity(company_uuid=company_management.uu_id)
mongo_engine.create_domain_via_user(
payload=DomainViaUser(
user_uu_id=str(app_manager_user.uu_id),
@@ -430,7 +430,7 @@ def create_application_defaults():
)
created_list.append(sup_manager_employee)
sup_manager_employee.reset_password_token()
sup_manager_employee.reset_password_token(found_user=sup_manager_employee)
mongo_engine.create_domain_via_user(
payload=DomainViaUser(
user_uu_id=str(sup_manager_employee.uu_id),

View File

@@ -6,10 +6,10 @@ from databases import (
)
def create_endpoints_from_api_functions(routers):
from application.create_file import create_app
from databases import EndpointRestriction
api_app = create_app(routers=routers)
for route in api_app.routes:
@@ -290,7 +290,7 @@ def create_modules_and_services_and_actions():
service_code=f"SRE-{duty_object.duty_code}",
)
created_service.save()
created_service.is_confirmed=True
created_service.is_confirmed = True
created_service.save()
occupant_types = OccupantTypes.filter_all()
@@ -302,7 +302,7 @@ def create_modules_and_services_and_actions():
service_code=f"SRO-{occupant_type.occupant_code}",
)
created_service.save()
created_service.is_confirmed=True
created_service.is_confirmed = True
created_service.save()
create_services_authenticate(module_dict=user_module_module_dict)