events imports are checked
This commit is contained in:
parent
643d6d8f65
commit
a5b1e0b2f4
|
|
@ -99,6 +99,7 @@ class AddressCreateEventMethods(MethodToEvent):
|
|||
company_id=token_dict.selected_company.company_id,
|
||||
is_confirmed=True,
|
||||
)
|
||||
Addresses.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -118,7 +119,7 @@ class AddressSearchEventMethods(MethodToEvent):
|
|||
|
||||
@classmethod
|
||||
def search_address(cls, data: SearchAddress, token_dict):
|
||||
import database_sql_models
|
||||
import databases as database_sql_models
|
||||
from time import perf_counter
|
||||
|
||||
st = perf_counter()
|
||||
|
|
@ -201,6 +202,7 @@ class AddressUpdateEventMethods(MethodToEvent):
|
|||
del data_dict["post_code_uu_id"]
|
||||
|
||||
updated_address = address.update(**data_dict)
|
||||
updated_address.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -221,8 +223,8 @@ class AddressPatchEventMethods(MethodToEvent):
|
|||
@classmethod
|
||||
def patch_address(cls, address_uu_id: str, data: InsertAddress, token_dict):
|
||||
address = Addresses.find_one_or_abort(uu_id=address_uu_id)
|
||||
post_code = RelationshipEmployee2PostCode.postcode.find_one(
|
||||
member_id=address.post_code_id
|
||||
post_code = RelationshipEmployee2PostCode.filter_one(
|
||||
RelationshipEmployee2PostCode.member_id==address.post_code_id
|
||||
)
|
||||
if not post_code:
|
||||
raise HTTPException(
|
||||
|
|
@ -273,6 +275,7 @@ class AddressPostCodeCreateEventMethods(MethodToEvent):
|
|||
company_id=token_dict.selected_company.company_id,
|
||||
is_confirmed=True,
|
||||
)
|
||||
AddressStreet.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -303,6 +306,7 @@ class AddressPostCodeUpdateEventMethods(MethodToEvent):
|
|||
)
|
||||
|
||||
updated_post_code = post_code.update(**data.excluded_dump())
|
||||
updated_post_code.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ from api_services import (
|
|||
redis_cli,
|
||||
send_email,
|
||||
)
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from api_configs import ApiStatic, Auth
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_library.date_time_actions.date_functions import DateTimeLocal
|
||||
from api_library.date_time_actions.date_functions import system_arrow, client_arrow
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
|
||||
class AuthenticationLoginEventMethods(MethodToEvent):
|
||||
|
|
@ -511,7 +511,7 @@ class AuthenticationRefreshTokenEventMethods(MethodToEvent):
|
|||
found_user.last_remote_addr = getattr(
|
||||
request, "remote_addr", None
|
||||
) or request.headers.get("X-Forwarded-For", None)
|
||||
found_user.last_seen = str(DateTimeLocal.now())
|
||||
found_user.last_seen = str(system_arrow.now())
|
||||
# UserLogger.log_error(
|
||||
# str(
|
||||
# dict(
|
||||
|
|
@ -593,7 +593,7 @@ class AuthenticationForgotPasswordEventMethods(MethodToEvent):
|
|||
)
|
||||
|
||||
found_user.password_token = forgot_key
|
||||
found_user.password_token_is_valid = str(DateTimeLocal.shift(days=1))
|
||||
found_user.password_token_is_valid = str(system_arrow.shift(days=1))
|
||||
found_user.save()
|
||||
|
||||
return JSONResponse(
|
||||
|
|
@ -620,6 +620,13 @@ class AuthenticationDownloadAvatarEventMethods(MethodToEvent):
|
|||
found_user = Users.check_user_exits(
|
||||
access_key=data.access_key, domain=data.domain
|
||||
)
|
||||
expired_str = str(system_arrow.now() - system_arrow.get(str(found_user.expiry_ends)))
|
||||
expired_int = int(
|
||||
client_arrow.get(
|
||||
system_arrow.now() - system_arrow.get(str(found_user.expiry_ends))
|
||||
).days
|
||||
)
|
||||
expiry_ends = system_arrow.get(str(found_user.expiry_ends))
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -628,17 +635,9 @@ class AuthenticationDownloadAvatarEventMethods(MethodToEvent):
|
|||
"last_seen": str(found_user.last_seen),
|
||||
"avatar": found_user.avatar,
|
||||
"remember_me": found_user.remember_me,
|
||||
"expiry_ends": str(found_user.expiry_ends),
|
||||
"expired_str": str(
|
||||
DateTimeLocal.now()
|
||||
- DateTimeLocal.get(str(found_user.expiry_ends))
|
||||
),
|
||||
"expired_int": int(
|
||||
(
|
||||
DateTimeLocal.now()
|
||||
- DateTimeLocal.get(str(found_user.expiry_ends))
|
||||
).days
|
||||
),
|
||||
"expiry_ends": client_arrow.get(expiry_ends),
|
||||
"expired_str": client_arrow.get(expired_str),
|
||||
"expired_int": expired_int,
|
||||
},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ from fastapi.responses import JSONResponse
|
|||
|
||||
from databases import (
|
||||
Build,
|
||||
# RelationshipEmployee2Build,
|
||||
RelationshipEmployee2Build,
|
||||
Addresses,
|
||||
BuildParts,
|
||||
BuildTypes,
|
||||
ApiEnumDropdown,
|
||||
)
|
||||
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertBuild,
|
||||
UpdateBuild,
|
||||
PatchRecord,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
|||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildParts,
|
||||
ListOptions,
|
||||
)
|
||||
|
|
@ -58,6 +58,7 @@ class BuildingBuildPartsCreateEventMethods(MethodToEvent):
|
|||
},
|
||||
status_code=status.HTTP_406_NOT_ACCEPTABLE,
|
||||
)
|
||||
created_build.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -78,6 +79,7 @@ class BuildingBuildPartsUpdateEventMethods(MethodToEvent):
|
|||
@classmethod
|
||||
def building_build_parts_update(cls, data: InsertBuildParts, token_dict: dict):
|
||||
if updated_build := BuildParts.update_action(data=data, token=token_dict):
|
||||
updated_build.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -2,21 +2,24 @@ import typing
|
|||
|
||||
from fastapi import status, HTTPException
|
||||
|
||||
from api_events.events.events.events_bind_modules import ModulesBindOccupantEventMethods
|
||||
from databases import (
|
||||
BuildParts,
|
||||
Build,
|
||||
BuildLivingSpace,
|
||||
OccupantTypes,
|
||||
|
||||
People,
|
||||
)
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildLivingSpace,
|
||||
ListOptions,
|
||||
)
|
||||
from databases.sql_models.event.event import Modules
|
||||
|
||||
|
||||
class BuildingLivingSpacesPartsListEventMethods(MethodToEvent):
|
||||
|
||||
|
|
@ -86,24 +89,23 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
|||
data: InsertBuildLivingSpace,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
from service_app.application import DateTimeLocal
|
||||
from database_sql_models import People
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from sqlalchemy.sql import select
|
||||
|
||||
data_dict = data.dump()
|
||||
build_id_list_query = Build.select_action(
|
||||
employee_id=token_dict.selected_company.employee_id
|
||||
)
|
||||
build_part = BuildParts.filter_active(
|
||||
build_part = BuildParts.filter_one(
|
||||
BuildParts.uu_id == data.build_parts_uu_id,
|
||||
BuildParts.build_id.in_([build.id for build in build_id_list_query.all()]),
|
||||
)
|
||||
if not build_part.get(1):
|
||||
if not build_part.data:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||
detail=f"{data.build_parts_uu_id} - Build Part is not found in database. Check build part uu_id",
|
||||
)
|
||||
build_part = build_part.get(1)
|
||||
build_part = build_part.data
|
||||
|
||||
life_person = People.find_one(uu_id=data.person_uu_id or "")
|
||||
if not life_person:
|
||||
|
|
@ -137,26 +139,33 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
|||
BuildLivingSpace.occupant_type == occupant_type.id,
|
||||
BuildLivingSpace.active == True,
|
||||
BuildLivingSpace.is_confirmed == True,
|
||||
str(DateTimeLocal.now()) < BuildLivingSpace.expiry_ends,
|
||||
str(DateTimeLocal.now()) >= BuildLivingSpace.expiry_starts,
|
||||
str(system_arrow.now()) < BuildLivingSpace.expiry_ends,
|
||||
str(system_arrow.now()) >= BuildLivingSpace.expiry_starts,
|
||||
]
|
||||
)
|
||||
.order_by(BuildLivingSpace.expiry_starts.desc())
|
||||
).first()
|
||||
|
||||
last_living_space = BuildLivingSpace.find_one(
|
||||
id=living_space_id[0] if living_space_id else None
|
||||
last_living_space = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.id==living_space_id[0] if living_space_id else None
|
||||
)
|
||||
|
||||
data_dict["expiry_starts"] = str(DateTimeLocal.now())
|
||||
data_dict["expiry_starts"] = str(system_arrow.now())
|
||||
created_living_space = BuildLivingSpace.create_action(
|
||||
data=data_dict, token_dict=token_dict
|
||||
)
|
||||
|
||||
if last_living_space:
|
||||
if last_living_space.expiry_ends > DateTimeLocal.now():
|
||||
last_living_space.expiry_ends = str(DateTimeLocal.shift(minutes=-10))
|
||||
if last_living_space.expiry_ends > system_arrow.now():
|
||||
last_living_space.expiry_ends = str(system_arrow.shift(minutes=-10))
|
||||
last_living_space.save()
|
||||
|
||||
user_module = Modules.filter_one(Modules.module_code == "USR-PUB")
|
||||
ModulesBindOccupantEventMethods.modules_bind_occupant_system(
|
||||
build_living_space_id=created_living_space.id,
|
||||
modules_id=user_module.id,
|
||||
)
|
||||
created_living_space.save()
|
||||
return created_living_space
|
||||
|
||||
|
||||
|
|
@ -164,13 +173,12 @@ class BuildingLivingSpacesPartsUpdateEventMethods(MethodToEvent):
|
|||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"70b4666f-4ceb-46ec-b89e-24be8712f0e7": "building_build_parts_update"
|
||||
"70b4666f-4ceb-46ec-b89e-24be8712f0e7": "building_live_space_update",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def building_build_parts_update(cls, build_uu_id: str, data, token_dict):
|
||||
from service_app.application import DateTimeLocal
|
||||
from database_sql_models import People
|
||||
def building_live_space_update(cls, build_uu_id: str, data, token_dict):
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from sqlalchemy.sql import select
|
||||
|
||||
data_dict = data.dump()
|
||||
|
|
@ -200,11 +208,11 @@ class BuildingLivingSpacesPartsUpdateEventMethods(MethodToEvent):
|
|||
BuildLivingSpace.expiry_starts.desc()
|
||||
)
|
||||
living_space_id = BuildLivingSpace.session.execute(living_spaces).first()
|
||||
last_living_space = BuildLivingSpace.find_one(
|
||||
id=getattr(living_space_id[0], "id", None) if living_space_id else None
|
||||
last_living_space = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.id==getattr(living_space_id[0], "id", None) if living_space_id else None
|
||||
)
|
||||
|
||||
data_dict["expiry_starts"] = DateTimeLocal.now()
|
||||
data_dict["expiry_starts"] = str(system_arrow.now())
|
||||
data_dict["is_tenant_live"] = bool(data.is_tenant_live)
|
||||
data_dict["build_parts_id"] = build_part.id
|
||||
if data_dict["is_tenant_live"]:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from fastapi.responses import JSONResponse
|
|||
|
||||
from databases import Companies
|
||||
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertCompany,
|
||||
UpdateCompany,
|
||||
ListOptions,
|
||||
|
|
@ -63,6 +63,8 @@ class CompanyCreateEventMethods(MethodToEvent):
|
|||
data=data, token=token_dict.companies_list
|
||||
)
|
||||
created_company.related_company = token_dict.get("company_uu_id")
|
||||
created_company.flush()
|
||||
created_company.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -91,14 +93,14 @@ class CompanyUpdateEventMethods(MethodToEvent):
|
|||
|
||||
@classmethod
|
||||
def company_update(cls, company_uu_id: str, data: UpdateCompany, token_dict):
|
||||
find_one_company = Companies.find_one_or_abort(uu_id=company_uu_id)
|
||||
find_one_company = Companies.filter_one(Companies.uu_id==company_uu_id)
|
||||
access_authorized_company = Companies.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Companies.id == token_dict.get("")],
|
||||
)
|
||||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_company = find_one_company.update(**data_dict)
|
||||
updated_company = find_one_company.data.update(**data.excluded_dump())
|
||||
Companies.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from typing import Optional
|
||||
from typing import Optional, Union
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from validations import (
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
|
|
@ -24,7 +24,9 @@ class DepartmentListEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def department_list(cls, list_options: ListOptions, token_dict):
|
||||
def department_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
Departments.filter_attr = list_options
|
||||
records = Departments.filter_active(
|
||||
*Departments.get_smart_query(smart_query=list_options.query),
|
||||
|
|
@ -57,22 +59,14 @@ class DepartmentCreateEventMethods(MethodToEvent):
|
|||
data_dict["company_id"] = token_dict.selected_company.company_id
|
||||
data_dict["company_uu_id"] = token_dict.selected_company.company_uu_id
|
||||
created_department = Departments.find_or_create(**data_dict)
|
||||
if created_department.is_found:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Company record already exits here is the record",
|
||||
"data": created_department.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_202_ACCEPTED,
|
||||
)
|
||||
Departments.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Company record",
|
||||
"completed": False,
|
||||
"message": "Company record already exits here is the record",
|
||||
"data": created_department.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
status_code=status.HTTP_202_ACCEPTED,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -87,7 +81,7 @@ class DepartmentUpdateEventMethods(MethodToEvent):
|
|||
def department_update(
|
||||
cls, company_uu_id: str, data: DepartmentsPydantic, token_dict
|
||||
):
|
||||
find_one_company = Departments.find_one_or_abort(uu_id=company_uu_id)
|
||||
find_one_company = Departments.filter_one(Departments.uu_id==company_uu_id)
|
||||
access_authorized_company = Departments.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Departments.id == token_dict.get("")],
|
||||
|
|
@ -95,6 +89,7 @@ class DepartmentUpdateEventMethods(MethodToEvent):
|
|||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_company = find_one_company.update(**data_dict)
|
||||
Departments.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from validations import InsertDuties, UpdateDuties, SelectDuties
|
||||
from validations.root_validates import PatchRecord, ListOptions
|
||||
from api_validations.validations_request import (
|
||||
InsertDuties,
|
||||
UpdateDuties,
|
||||
SelectDuties,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from databases import Departments, Duty, Duties
|
||||
|
||||
|
|
@ -19,9 +26,11 @@ class DutiesListEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def duties_list(cls, list_options: ListOptions, token_dict):
|
||||
def duties_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
Duties.filter_attr = list_options
|
||||
records = Duties.filter_active(
|
||||
records = Duties.filter_all(
|
||||
*Duties.get_smart_query(smart_query=list_options.query),
|
||||
Duties.company_id == token_dict.selected_company.company_id
|
||||
)
|
||||
|
|
@ -40,9 +49,11 @@ class DutiesGetByUUIDEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def duties_get_by_uuid(cls, data: SelectDuties, token_dict):
|
||||
def duties_get_by_uuid(
|
||||
cls, data: SelectDuties, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
|
||||
duty = Duty.find_one(uu_id=data.duty_uu_id)
|
||||
duty = Duty.filter_one(Duty.uu_id==data.duty_uu_id).data
|
||||
if not duty:
|
||||
return JSONResponse(
|
||||
content={
|
||||
|
|
@ -81,9 +92,11 @@ class DutiesCreateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def duties_create(cls, data: InsertDuties, token_dict):
|
||||
duty = Duty.find_one(uu_id=data.duties_uu_id)
|
||||
department = Departments.find_one(uu_id=data.department_uu_id)
|
||||
def duties_create(
|
||||
cls, data: InsertDuties, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
duty = Duty.filter_one(Duty.uu_id==data.duties_uu_id).data
|
||||
department = Departments.filter_one(Duty.uu_id==data.department_uu_id).data
|
||||
|
||||
created_duties = Duties.find_or_create(
|
||||
company_id=token_dict.selected_company.company_id,
|
||||
|
|
@ -98,6 +111,7 @@ class DutiesCreateEventMethods(MethodToEvent):
|
|||
created_duties.update(users_default_duty=created_duties.id)
|
||||
|
||||
if not created_duties:
|
||||
Duty.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
|
|
@ -134,6 +148,7 @@ class DutiesUpdateEventMethods(MethodToEvent):
|
|||
if access_authorized_duties.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_duties = find_one_duties.update(**data_dict)
|
||||
Duties.save()
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Update Duties record",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from validations import InsertCompanyDuty
|
||||
from validations.root_validates import PatchRecord, ListOptions
|
||||
from api_validations.validations_request import (
|
||||
InsertCompanyDuty, PatchRecord, ListOptions
|
||||
)
|
||||
|
||||
from databases import Duty
|
||||
|
||||
|
|
@ -19,7 +22,9 @@ class DutyListEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def duty_list(cls, list_options: ListOptions, token_dict):
|
||||
def duty_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
records = Duty.filter_active(
|
||||
*Duty.get_smart_query(list_options.query),
|
||||
)
|
||||
|
|
@ -36,8 +41,11 @@ class DutyCreateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def duty_create(cls, data: InsertCompanyDuty, token_dict):
|
||||
def duty_create(
|
||||
cls, data: InsertCompanyDuty, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
created_duty = Duty.find_or_create(**data.excluded_dump())
|
||||
Duty.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -56,7 +64,7 @@ class DutyUpdateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def duty_update(cls, company_uu_id: str, data, token_dict):
|
||||
def duty_update(cls, company_uu_id: str, data, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]):
|
||||
find_one_company = Duty.find_one_or_abort(uu_id=company_uu_id)
|
||||
access_authorized_company = Duty.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5), # ?
|
||||
|
|
@ -65,6 +73,7 @@ class DutyUpdateEventMethods(MethodToEvent):
|
|||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_company = find_one_company.update(**data_dict)
|
||||
Duty.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -95,15 +104,9 @@ class DutyPatchEventMethods(MethodToEvent):
|
|||
)
|
||||
if access_authorized_company.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_company.active = bool(
|
||||
action.get("active", find_one_company.active)
|
||||
)
|
||||
find_one_company.is_confirmed = bool(
|
||||
action.get("confirm", find_one_company.is_confirmed)
|
||||
)
|
||||
find_one_company.deleted = bool(
|
||||
action.get("delete", find_one_company.deleted)
|
||||
)
|
||||
find_one_company.active = bool(action.get("active", find_one_company.active))
|
||||
find_one_company.is_confirmed = bool(action.get("confirm", find_one_company.is_confirmed))
|
||||
find_one_company.deleted = bool(action.get("delete", find_one_company.deleted))
|
||||
find_one_company.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
from datetime import datetime
|
||||
from typing import Union
|
||||
|
||||
from fastapi import status, HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertEmployees,
|
||||
BindEmployees2People,
|
||||
PatchRecord,
|
||||
|
|
@ -25,7 +26,9 @@ class EmployeeListEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def employee_list(cls, list_options: ListOptions, token_dict):
|
||||
def employee_list(
|
||||
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
Employees.filter_attr = list_options
|
||||
records = Employees.filter_active(
|
||||
*Employees.get_smart_query(smart_query=list_options.query),
|
||||
|
|
@ -44,7 +47,9 @@ class EmployeeCreateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def employee_create(cls, data: InsertEmployees, token_dict):
|
||||
def employee_create(
|
||||
cls, data: InsertEmployees, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
person = People.find_one(uu_id=data.people_uu_id)
|
||||
staff = Staff.find_one(uu_id=data.staff_uu_id)
|
||||
if not staff:
|
||||
|
|
@ -63,6 +68,7 @@ class EmployeeCreateEventMethods(MethodToEvent):
|
|||
people_id=person.id if person else None,
|
||||
people_uu_id=str(person.uu_id) if person else None,
|
||||
)
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True if not created_employee.is_found else False,
|
||||
|
|
@ -90,6 +96,7 @@ class EmployeeUpdateEventMethods(MethodToEvent):
|
|||
if access_authorized_employee.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_employee = find_one_employee.update(**data_dict)
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -116,7 +123,9 @@ class EmployeePatchEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def employee_patch(cls, employee_uu_id: str, data: PatchRecord, token_dict):
|
||||
def employee_patch(
|
||||
cls, employee_uu_id: str, data: PatchRecord, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
find_one_employee = Employees.find_one_or_abort(uu_id=employee_uu_id)
|
||||
access_authorized_employee = Employees.select_action(
|
||||
employee_id=getattr(token_dict, "employee_id", 5),
|
||||
|
|
@ -133,7 +142,6 @@ class EmployeePatchEventMethods(MethodToEvent):
|
|||
find_one_employee.deleted = bool(
|
||||
action.get("delete", find_one_employee.deleted)
|
||||
)
|
||||
find_one_employee.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -197,7 +205,7 @@ class Employee2PeopleEmployEventMethods(MethodToEvent):
|
|||
expiry_starts=data.expiry_starts,
|
||||
**token_dict.update_creds,
|
||||
)
|
||||
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -257,6 +265,7 @@ class Employee2PeopleFireEventMethods(MethodToEvent):
|
|||
is_notification_send=find_one_employee.is_notification_send,
|
||||
cryp_uu_id=find_one_employee.cryp_uu_id,
|
||||
)
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from fastapi import status
|
|||
from fastapi.responses import JSONResponse
|
||||
from fastapi.exceptions import HTTPException
|
||||
|
||||
from validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertStaff,
|
||||
SelectStaff,
|
||||
PatchRecord,
|
||||
|
|
@ -48,10 +48,9 @@ class StaffCreateEventMethods(MethodToEvent):
|
|||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Duties not found",
|
||||
)
|
||||
|
||||
data_dict["duties_id"] = duties.id
|
||||
|
||||
created_duty = Staff.find_or_create(**data_dict)
|
||||
Staff.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from databases import (
|
|||
OccupantTypes,
|
||||
)
|
||||
|
||||
from validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertDecisionBook,
|
||||
ListOptions,
|
||||
)
|
||||
|
|
@ -117,6 +117,7 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
|||
)
|
||||
data_dict["expiry_starts"] = str(data_dict["expiry_starts"])
|
||||
build_decision_book = BuildDecisionBook.find_or_create(**data_dict)
|
||||
BuildDecisionBook.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content=dict(
|
||||
|
|
@ -157,6 +158,7 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
|||
)
|
||||
data_dict["expiry_starts"] = str(data_dict["expiry_starts"])
|
||||
build_decision_book = BuildDecisionBook.find_or_create(**data_dict)
|
||||
BuildDecisionBook.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content=dict(
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ from databases import (
|
|||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from api_library.date_time_actions.date_functions import DateTimeLocal
|
||||
from api_library.date_time_actions.date_functions import system_arrow, client_arrow
|
||||
|
||||
from validations import (
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildDecisionBookItems,
|
||||
ListDecisionBook,
|
||||
)
|
||||
|
|
@ -123,7 +123,7 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
|||
for build_part_single in build_parts_list:
|
||||
local_date = start_date
|
||||
while local_date.is_between(start_date, end_date, "[]"):
|
||||
local_date = DateTimeLocal.find_last_day_of_month(local_date)
|
||||
local_date = system_arrow.find_last_day_of_month(local_date)
|
||||
payment_amount = unit_price
|
||||
if not unit_price_is_fixed:
|
||||
unit_amount = str(build_part_single.due_part_key).replace(" ", "")
|
||||
|
|
@ -176,9 +176,9 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
|||
)
|
||||
payment_types = ApiEnumDropdown.get_debit_search(search_debit="DT-D")
|
||||
if data_info_type.key == "BDT-D":
|
||||
local_date = DateTimeLocal.get(DateTimeLocal.get(decision_book.expiry_starts).date())
|
||||
end_date = DateTimeLocal.get(DateTimeLocal.get(decision_book.expiry_ends).date())
|
||||
return cls.iterate_over_build_parts(
|
||||
local_date = system_arrow.get(system_arrow.get(decision_book.expiry_starts).date())
|
||||
end_date = system_arrow.get(system_arrow.get(decision_book.expiry_ends).date())
|
||||
cls.iterate_over_build_parts(
|
||||
build_parts_list=build_parts_list.data,
|
||||
payment_types=payment_types,
|
||||
local_date=local_date,
|
||||
|
|
@ -188,10 +188,12 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
|||
unit_price_is_fixed=unit_price_is_fixed,
|
||||
book_payment_dict=book_payment_dict,
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
elif data_info_type.key == "BDT-A":
|
||||
local_date = DateTimeLocal.get(DateTimeLocal.get(debit_start_date).date())
|
||||
end_date = DateTimeLocal.get(DateTimeLocal.get(debit_end_date).date())
|
||||
return cls.iterate_over_build_parts(
|
||||
local_date = system_arrow.get(system_arrow.get(debit_start_date).date())
|
||||
end_date = system_arrow.get(system_arrow.get(debit_end_date).date())
|
||||
cls.iterate_over_build_parts(
|
||||
build_parts_list=build_parts_list.data,
|
||||
payment_types=payment_types,
|
||||
local_date=local_date,
|
||||
|
|
@ -201,11 +203,13 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
|||
unit_price_is_fixed=unit_price_is_fixed,
|
||||
book_payment_dict=book_payment_dict,
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
elif data_info_type.key == "BDT-R" or data_info_type.key == "BDT-L":
|
||||
local_date = DateTimeLocal.get(DateTimeLocal.get(debit_start_date).date())
|
||||
end_date = DateTimeLocal.get(DateTimeLocal.get(debit_end_date).date())
|
||||
decision_date = DateTimeLocal.get(decision_book.expiry_starts).date()
|
||||
meeting_date = DateTimeLocal.get(decision_book.meeting_date).date()
|
||||
local_date = system_arrow.get(system_arrow.get(debit_start_date).date())
|
||||
end_date = system_arrow.get(system_arrow.get(debit_end_date).date())
|
||||
decision_date = system_arrow.get(decision_book.expiry_starts).date()
|
||||
meeting_date = system_arrow.get(decision_book.meeting_date).date()
|
||||
|
||||
already_book_projects = BuildDecisionBookProjects.filter_all(
|
||||
BuildDecisionBookProjects.build_decision_book_id==decision_book.id,
|
||||
|
|
@ -242,22 +246,23 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
|||
project_response_living_space_uu_id=str(manager_living_space.uu_id),
|
||||
)
|
||||
book_project_created = BuildDecisionBookProjects.find_or_create(**book_project_dict)
|
||||
if not book_project_created.is_found:
|
||||
decision_book_item.update(
|
||||
item_comment=f"{book_project_created.project_no}_{book_project_created.project_name} "
|
||||
f"is assigned to {occupant_man.occupant_description}"
|
||||
)
|
||||
project_lead = ApiEnumDropdown.find_one(
|
||||
key="PTT-LDR", enum_class="ProjectTeamTypes"
|
||||
)
|
||||
project_person = BuildDecisionBookProjectPerson.find_or_create(
|
||||
build_decision_book_project_id=book_project_created.id,
|
||||
build_decision_book_project_uu_id=str(book_project_created.uu_id),
|
||||
living_space_id=manager_living_space.id,
|
||||
living_space_uu_id=str(manager_living_space.uu_id),
|
||||
project_team_type_id=project_lead.id,
|
||||
project_team_type_uu_id=str(project_lead.uu_id),
|
||||
)
|
||||
decision_book_item.update(
|
||||
item_comment=f"{book_project_created.project_no}_{book_project_created.project_name} "
|
||||
f"is assigned to {occupant_man.occupant_description}"
|
||||
)
|
||||
project_lead = ApiEnumDropdown.find_one(
|
||||
key="PTT-LDR", enum_class="ProjectTeamTypes"
|
||||
)
|
||||
project_person = BuildDecisionBookProjectPerson.find_or_create(
|
||||
build_decision_book_project_id=book_project_created.id,
|
||||
build_decision_book_project_uu_id=str(book_project_created.uu_id),
|
||||
living_space_id=manager_living_space.id,
|
||||
living_space_uu_id=str(manager_living_space.uu_id),
|
||||
project_team_type_id=project_lead.id,
|
||||
project_team_type_uu_id=str(project_lead.uu_id),
|
||||
)
|
||||
BuildDecisionBookProjects.save()
|
||||
return
|
||||
|
||||
elif data_info_type.key == "BDT-SF":
|
||||
raise HTTPException(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from databases import (
|
|||
OccupantTypes,
|
||||
)
|
||||
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
ListOptions,
|
||||
RemoveDecisionBookPerson,
|
||||
DecisionBookDecisionBookInvitationsAttend,
|
||||
|
|
@ -126,6 +126,7 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
|
|||
occupant_type=assign_occupant_type.id,
|
||||
occupant_type_uu_id=str(assign_occupant_type.uu_id),
|
||||
)
|
||||
BuildDecisionBookPerson.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
|
|
@ -200,6 +201,7 @@ class DecisionBookPersonAttendEventMethods(MethodToEvent):
|
|||
invitation_person.update(
|
||||
is_attending=bool(data.is_attend), vicarious_person_id=None
|
||||
)
|
||||
BuildDecisionBookInvitations.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
|
|
@ -336,6 +338,7 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
|
|||
occupant_type=assign_occupant_type,
|
||||
build_living_space_id=selected_living_space.id,
|
||||
)
|
||||
BuildDecisionBookPersonOccupants.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ from databases import (
|
|||
ApiEnumDropdown,
|
||||
)
|
||||
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
DecisionBookDecisionBookInvitationsUpdate,
|
||||
DecisionBookDecisionBookInvitations,
|
||||
)
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from api_library.date_time_actions.date_functions import DateTimeLocal
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
|
||||
|
||||
class BuildDecisionBookInvitationsListEventMethods(MethodToEvent):
|
||||
|
|
@ -95,8 +95,8 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
|||
|
||||
# Check planned decision book date is valid
|
||||
if (
|
||||
not DateTimeLocal.get(data.planned_date).date()
|
||||
>= DateTimeLocal.shift(days=1).date()
|
||||
not system_arrow.get(data.planned_date).date()
|
||||
>= system_arrow.shift(days=1).date()
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
|
|
@ -115,9 +115,9 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
|||
message=data.message,
|
||||
planned_date=data.planned_date,
|
||||
planned_date_expires=str(
|
||||
DateTimeLocal.get(data.planned_date).shift(days=15).date()
|
||||
system_arrow.get(data.planned_date).shift(days=15).date()
|
||||
),
|
||||
expiry_ends=str(DateTimeLocal.get(data.planned_date).shift(days=15).date()),
|
||||
expiry_ends=str(system_arrow.get(data.planned_date).shift(days=15).date()),
|
||||
is_confirmed=True,
|
||||
)
|
||||
if book_invitation.is_found:
|
||||
|
|
@ -172,7 +172,7 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
|||
build_decision_book_uu_id=str(decision_book.uu_id),
|
||||
invite_id=book_invitation.id,
|
||||
invite_uu_id=str(book_invitation.uu_id),
|
||||
send_date=str(DateTimeLocal.now().date()),
|
||||
send_date=str(system_arrow.now().date()),
|
||||
expiry_starts=decision_book.expiry_starts,
|
||||
expiry_ends=decision_book.expiry_ends,
|
||||
is_confirmed=True,
|
||||
|
|
@ -243,6 +243,7 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
|||
):
|
||||
book_person_manager.add_occupant_type(occupant_type=manager_occupant_type)
|
||||
print(f"Manager Token : {book_person_manager.token}")
|
||||
BuildDecisionBookPerson.save()
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_200_OK,
|
||||
content={
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.exceptions import HTTPException
|
||||
|
|
@ -8,9 +10,9 @@ from databases import (
|
|||
Build,
|
||||
Events,
|
||||
Event2Occupant,
|
||||
OccupantTypes,
|
||||
OccupantTypes,
|
||||
)
|
||||
from api_validations import RegisterEvents2Occupant
|
||||
from api_validations.validations_request import RegisterEvents2Occupant
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
|
@ -24,7 +26,7 @@ class EventBindOccupantEventMethods(MethodToEvent):
|
|||
|
||||
@classmethod
|
||||
def bind_events_occupant_super_user(
|
||||
cls, data: RegisterEvents2Occupant, token_dict: EmployeeTokenObject
|
||||
cls, data: RegisterEvents2Occupant, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
|
||||
if not str(token_dict.user_type) == "1":
|
||||
|
|
@ -108,6 +110,7 @@ class EventBindOccupantEventMethods(MethodToEvent):
|
|||
events_added.append(event)
|
||||
|
||||
if events_added:
|
||||
Events.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -134,7 +137,9 @@ class EventBindEmployeeEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def bind_events_employee(cls, data: RegisterEvents2Occupant, token_dict):
|
||||
def bind_events_employee(
|
||||
cls, data: RegisterEvents2Occupant, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
import typing
|
||||
|
||||
from databases import (
|
||||
Modules,
|
||||
BuildLivingSpace,
|
||||
)
|
||||
from api_validations.validations_request import RegisterModules2Occupant, RegisterModules2Employee
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_events.events.events.events_bind_services import ServiceBindOccupantEventMethods
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
|
||||
class ModulesBindOccupantEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"": "modules_bind_occupant",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def modules_bind_occupant_system(
|
||||
cls, build_living_space_id: int, modules_id: int, expires_at: str = None
|
||||
):
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(Modules.id==build_living_space_id).data
|
||||
modules = Modules.filter_one(Modules.id==modules_id).data
|
||||
|
||||
service_build_dict = dict(build_living_space_id=living_space.id)
|
||||
service_build_dict["expires_at"] = str(system_arrow.get(living_space.expiry_ends))
|
||||
if not expires_at:
|
||||
service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
|
||||
|
||||
for service in modules.retrieve_services():
|
||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||
**service_build_dict,
|
||||
service_id=service.id,
|
||||
)
|
||||
BuildLivingSpace.save()
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def modules_bind_occupant(
|
||||
cls,
|
||||
data: RegisterModules2Occupant,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
|
||||
return
|
||||
|
||||
|
||||
class ModulesBindEmployeeEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"": "modules_bind_employee",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def modules_bind_employee(
|
||||
cls,
|
||||
data: RegisterModules2Employee,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
return
|
||||
|
||||
|
||||
ModulesBindOccupantEventMethod = ModulesBindOccupantEventMethods(
|
||||
action=ActionsSchema(endpoint="/bind/modules/occupant")
|
||||
)
|
||||
ModulesBindEmployeeEventMethod = ModulesBindEmployeeEventMethods(
|
||||
action=ActionsSchema(endpoint="/bind/modules/employee")
|
||||
)
|
||||
|
|
@ -15,7 +15,7 @@ from databases import (
|
|||
Event2Employee,
|
||||
Event2Occupant,
|
||||
)
|
||||
from api_validations import RegisterServices2Occupant, RegisterServices2Employee
|
||||
from api_validations.validations_request import RegisterServices2Occupant, RegisterServices2Employee
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
|
@ -33,21 +33,9 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
|||
):
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
|
||||
living_space = BuildLivingSpace.find_or_abort(
|
||||
id=build_living_space_id,
|
||||
)
|
||||
service = Services.find_or_abort(
|
||||
id=service_id,
|
||||
)
|
||||
default_module = Modules.find_one(module_code="USR-PUB")
|
||||
add_default_service = Services.find_one(module_id=default_module.id)
|
||||
service_events = Service2Events.filter_all(
|
||||
Service2Events.service_id == service.id,
|
||||
)
|
||||
default_service_events = Service2Events.filter_all(
|
||||
Service2Events.service_id == add_default_service.id,
|
||||
)
|
||||
add_events_list = service_events.data + default_service_events.data
|
||||
living_space = BuildLivingSpace.filter_one(BuildLivingSpace.id==build_living_space_id)
|
||||
service = Services.filter_one(Services.id==service_id)
|
||||
add_events_list = Service2Events.filter_all(Service2Events.service_id == service.id).data
|
||||
if not add_events_list:
|
||||
raise Exception(
|
||||
"Service has no events registered. Please contact with your manager"
|
||||
|
|
@ -74,8 +62,7 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
|||
)
|
||||
count_row = session_execute.rowcount
|
||||
print(f"{count_row} events are added to occupant {str(living_space.uu_id)}")
|
||||
Services.session.commit()
|
||||
Services.session.flush()
|
||||
Services.save()
|
||||
|
||||
@classmethod
|
||||
def bind_services_occupant(
|
||||
|
|
@ -178,8 +165,7 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
|||
)
|
||||
count_row = session_execute.rowcount
|
||||
print(f"{count_row} events are added to employee {str(living_space.uu_id)}")
|
||||
Services.session.commit()
|
||||
Services.session.flush()
|
||||
Services.save()
|
||||
|
||||
|
||||
class ServiceBindEmployeeEventMethods(MethodToEvent):
|
||||
|
|
@ -233,8 +219,7 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
|
|||
)
|
||||
count_row = session_execute.rowcount
|
||||
print(f"{count_row} events are added to employee {employee.uu_id}")
|
||||
Services.session.commit()
|
||||
Services.session.flush()
|
||||
Services.save()
|
||||
|
||||
@classmethod
|
||||
def bind_services_employee_super_user(
|
||||
|
|
@ -308,9 +293,8 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
|
|||
)
|
||||
)
|
||||
count_row = session_execute.rowcount
|
||||
Services.session.commit()
|
||||
Services.session.flush()
|
||||
if not count_row:
|
||||
Services.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi.exceptions import HTTPException
|
||||
|
||||
from databases import (
|
||||
|
|
@ -9,7 +11,7 @@ from databases import (
|
|||
Event2Employee,
|
||||
BuildLivingSpace,
|
||||
)
|
||||
from api_validations import (
|
||||
from api_validations.validations_request import (
|
||||
RegisterEvents2Employee,
|
||||
RegisterEvents2Occupant,
|
||||
CreateEvents,
|
||||
|
|
@ -29,7 +31,7 @@ class EventsListEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def events_list(cls, list_options: ListOptions, token_dict):
|
||||
def events_list(cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]):
|
||||
records = Events.filter_active(
|
||||
*Events.get_smart_query(list_options.query),
|
||||
)
|
||||
|
|
@ -56,6 +58,7 @@ class EventsCreateEventMethods(MethodToEvent):
|
|||
active=True,
|
||||
deleted=False,
|
||||
)
|
||||
Events.save()
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "Event created successfully.",
|
||||
|
|
@ -85,6 +88,7 @@ class EventsUpdateEventMethods(MethodToEvent):
|
|||
event_date=data.event_date,
|
||||
event_location=data.event_location,
|
||||
)
|
||||
Events.save()
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "Event updated successfully.",
|
||||
|
|
@ -155,6 +159,7 @@ class EventsBindEventToOccupantMethods(MethodToEvent):
|
|||
employee = Event2Employee.find_or_create(
|
||||
**token_dict.user_creds, employee_id=employee.id, event_id=event.id
|
||||
)
|
||||
Events.save()
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "Events registered successfully.",
|
||||
|
|
@ -191,6 +196,7 @@ class EventsBindEventToEmployeeMethods(MethodToEvent):
|
|||
build_living_space_id=occupant.id,
|
||||
event_id=event.id,
|
||||
)
|
||||
Events.save()
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "Events registered successfully.",
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations import DepartmentsPydantic, ListOptions
|
||||
|
||||
from databases import Events
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
|
||||
class ModelEntitiesEvents(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def model_entities_list(cls, list_options: ListOptions, token_dict):
|
||||
Events.filter_attr = list_options
|
||||
records = Events.filter_active(
|
||||
*Events.get_smart_query(smart_query=list_options.query),
|
||||
Events.company_id == token_dict.selected_company.company_id
|
||||
)
|
||||
return return_json_response_from_alchemy(
|
||||
response=records, pagination=list_options
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def model_entities_create(cls, data: DepartmentsPydantic, token_dict):
|
||||
created_events = Events.create_action(data=data, token=token_dict)
|
||||
if created_events.is_found:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Events record already exits here is the record",
|
||||
"data": created_events.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_202_ACCEPTED,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Events record",
|
||||
"data": created_events.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def model_entities_update(
|
||||
cls, company_uu_id: str, data: DepartmentsPydantic, token_dict
|
||||
):
|
||||
find_one_events = Events.find_one_or_abort(uu_id=company_uu_id)
|
||||
access_authorized_events = Events.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Events.id == token_dict.get("")],
|
||||
action="update",
|
||||
data=data,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Events record",
|
||||
"data": access_authorized_events.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def model_entities_patch(
|
||||
cls, company_uu_id: str, data: DepartmentsPydantic, token_dict
|
||||
):
|
||||
find_one_events = Events.find_one_or_abort(uu_id=company_uu_id)
|
||||
access_authorized_events = Events.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Events.id == token_dict.get("")],
|
||||
action="patch",
|
||||
data=data,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch Events record",
|
||||
"data": access_authorized_events.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from validations import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
from api_validations.validations_request import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from validations import DepartmentsPydantic, PatchRecord
|
||||
from api_validations.validations_request import DepartmentsPydantic, PatchRecord
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from validations import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
from api_validations.validations_request import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
|
@ -7,7 +9,7 @@ from databases import (
|
|||
Companies,
|
||||
)
|
||||
|
||||
from validations import InsertPerson, UpdateUsers
|
||||
from api_validations.validations_request import InsertPerson, UpdateUsers
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
|
@ -26,8 +28,6 @@ class PeopleListEventMethods(MethodToEvent):
|
|||
|
||||
@classmethod
|
||||
def super_users_people_list(cls, list_options, token_dict):
|
||||
|
||||
|
||||
records = People.filter_active(
|
||||
*People.get_smart_query(smart_query=list_options.query)
|
||||
)
|
||||
|
|
@ -58,9 +58,11 @@ class PeopleCreateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def people_create(cls, data: InsertPerson, token_dict: dict):
|
||||
|
||||
def people_create(
|
||||
cls, data: InsertPerson, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
created_user = People.create_action(data=data, token=token_dict)
|
||||
People.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -79,8 +81,9 @@ class PeopleUpdateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def people_update(cls, data: UpdateUsers, user_uu_id: str, token_dict: dict):
|
||||
|
||||
def people_update(
|
||||
cls, data: UpdateUsers, user_uu_id: str, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
find_one_user = Users.find_one_or_abort(uu_id=user_uu_id)
|
||||
access_authorized_company = Companies.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
|
|
@ -89,6 +92,7 @@ class PeopleUpdateEventMethods(MethodToEvent):
|
|||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_user = find_one_user.update(**data_dict)
|
||||
Users.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -3,15 +3,20 @@ import typing
|
|||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
||||
from databases import MongoQueryIdentity, Users, Companies, People
|
||||
from databases.no_sql_models.validations import DomainViaUser
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
from validations import InsertUsers, UpdateUsers, PatchRecord, ListOptions
|
||||
from api_validations.validations_request import (
|
||||
InsertUsers,
|
||||
UpdateUsers,
|
||||
PatchRecord,
|
||||
ListOptions, RegisterServices2Occupant,
|
||||
)
|
||||
|
||||
|
||||
class UserListEventMethods(MethodToEvent):
|
||||
|
|
@ -55,7 +60,9 @@ class UserCreateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def user_create(cls, data: InsertUsers, token_dict):
|
||||
def user_create(
|
||||
cls, data: InsertUsers, token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
created_user = Users.create_action(create_user=data)
|
||||
created_user.related_company = token_dict.selected_company.company_uu_id
|
||||
domain_via_user = DomainViaUser(
|
||||
|
|
@ -66,7 +73,6 @@ class UserCreateEventMethods(MethodToEvent):
|
|||
company_uuid=created_user.related_company,
|
||||
)
|
||||
mongo_query_identity.create_domain_via_user(payload=domain_via_user)
|
||||
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
@ -92,7 +98,9 @@ class UserUpdateEventMethods(MethodToEvent):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def user_update(cls, data: UpdateUsers, user_uu_id: str, token_dict):
|
||||
def user_update(
|
||||
cls, data: UpdateUsers, user_uu_id: str, token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
find_one_user = Users.find_one_or_abort(uu_id=user_uu_id)
|
||||
access_authorized_company = Companies.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
|
|
@ -101,6 +109,7 @@ class UserUpdateEventMethods(MethodToEvent):
|
|||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_user = find_one_user.update(**data_dict)
|
||||
Users.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
|
|
|||
|
|
@ -1,21 +1,7 @@
|
|||
from fastapi import HTTPException, status
|
||||
from fastapi.requests import Request
|
||||
|
||||
from database_sql_models import Events
|
||||
|
||||
# url_that_not_requires_event_validation = [
|
||||
# "/authentication/login",
|
||||
# "/authentication/select",
|
||||
# "/authentication/valid",
|
||||
# "/authentication/refresh",
|
||||
# "/authentication/change_password",
|
||||
# "/authentication/create_password",
|
||||
# "/authentication/disconnect",
|
||||
# "/authentication/logout",
|
||||
# "/authentication/refresher",
|
||||
# "/authentication/forgot",
|
||||
# "/authentication/avatar",
|
||||
# ]
|
||||
from databases import Events
|
||||
|
||||
|
||||
def parse_token_object_to_dict(request: Request): # from requests import Request
|
||||
|
|
|
|||
|
|
@ -125,6 +125,10 @@ from .user import (
|
|||
ListUsers,
|
||||
DeleteUsers,
|
||||
)
|
||||
from .modules import (
|
||||
RegisterModules2Occupant,
|
||||
RegisterModules2Employee,
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
@ -216,4 +220,6 @@ __all__ = [
|
|||
"ActiveUsers",
|
||||
"ListUsers",
|
||||
"DeleteUsers",
|
||||
"RegisterModules2Occupant",
|
||||
"RegisterModules2Employee",
|
||||
]
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
from api_validations.core_validations import BaseModelRegular
|
||||
from api_validations.validations_request import (
|
||||
PydanticBaseModel,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
class RegisterModules2Occupant(BaseModelRegular):
|
||||
modules_uu_id: str
|
||||
occupant_uu_id: str
|
||||
build_part_uu_id: str
|
||||
|
||||
|
||||
class RegisterModules2Employee(BaseModelRegular):
|
||||
modules_uu_id: str
|
||||
employee_uu_id: str
|
||||
|
||||
|
||||
|
||||
|
|
@ -4,12 +4,12 @@ from api_validations.validations_request import (
|
|||
ListOptions,
|
||||
)
|
||||
|
||||
class RegisterServices2Occupant(PydanticBaseModel):
|
||||
class RegisterServices2Occupant(BaseModelRegular):
|
||||
service_uu_id: str
|
||||
occupant_uu_id: str
|
||||
build_part_uu_id: str
|
||||
|
||||
|
||||
class RegisterServices2Employee(PydanticBaseModel):
|
||||
class RegisterServices2Employee(BaseModelRegular):
|
||||
service_uu_id: str
|
||||
employee_uu_id: str
|
||||
|
|
|
|||
|
|
@ -587,27 +587,26 @@ class BuildLivingSpace(CrudCollection):
|
|||
data: dict,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
from database_sql_models import Services, OccupantTypes
|
||||
from events.events_bind_services import ServiceBindOccupantEventMethods
|
||||
from databases import Services, OccupantTypes
|
||||
from api_events.events.events.events_bind_services import ServiceBindOccupantEventMethods
|
||||
|
||||
created_living_space = BuildLivingSpace.find_or_create(**data)
|
||||
if not created_living_space.is_found:
|
||||
occupant_type = OccupantTypes.find_one(
|
||||
uu_id=created_living_space.occupant_type_uu_id
|
||||
)
|
||||
related_service = Services.find_one(
|
||||
active=True,
|
||||
related_responsibility=occupant_type.occupant_code,
|
||||
)
|
||||
if not related_service:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||
detail="Service is not found in database. Re-enter service record then try again.",
|
||||
)
|
||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||
service_id=related_service.id,
|
||||
build_living_space_id=created_living_space.id,
|
||||
occupant_type = OccupantTypes.find_one(
|
||||
uu_id=created_living_space.occupant_type_uu_id
|
||||
)
|
||||
related_service = Services.find_one(
|
||||
active=True,
|
||||
related_responsibility=occupant_type.occupant_code,
|
||||
)
|
||||
if not related_service:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||
detail="Service is not found in database. Re-enter service record then try again.",
|
||||
)
|
||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||
service_id=related_service.id,
|
||||
build_living_space_id=created_living_space.id,
|
||||
)
|
||||
return created_living_space
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ class BuildDecisionBookPerson(CrudCollection):
|
|||
build_living_space_id=related_living_space.id,
|
||||
service_id=related_service.id,
|
||||
expires_at=str(
|
||||
DateTimeLocal.get(str(decision_book.meeting_date)).shift(
|
||||
DateTimeLocal.get(decision_book.meeting_date).shift(
|
||||
days=15
|
||||
)
|
||||
),
|
||||
|
|
|
|||
|
|
@ -344,15 +344,17 @@ class Companies(CrudCollection, SelectAction):
|
|||
|
||||
@classmethod
|
||||
def create_action(cls, data: InsertCompany, token: EmployeeTokenObject):
|
||||
from database_sql_models import Addresses, Duties
|
||||
from databases import Addresses, Duties
|
||||
|
||||
data_dict = data.model_dump()
|
||||
if cls.find_one(tax_no=str(data.tax_no).strip()):
|
||||
if cls.filter_one(cls.tax_no==str(data.tax_no).strip()):
|
||||
raise Exception(
|
||||
"Company already exists. Please ask supervisor to make company visible for your duty."
|
||||
)
|
||||
|
||||
official_address = Addresses.find_one(uu_id=data.official_address_uu_id)
|
||||
official_address = Addresses.filter_one(
|
||||
Addresses.uu_id==data.official_address_uu_id
|
||||
)
|
||||
if not official_address:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,19 @@ class Modules(CrudCollection):
|
|||
module_layer = mapped_column(Integer, nullable=False, comment="Module Layer")
|
||||
is_default_module = mapped_column(Boolean, server_default="0")
|
||||
|
||||
def retrieve_services(self):
|
||||
services = Services.filter_all(Services.module_id == self.id)
|
||||
if not services.count:
|
||||
self.raise_http_exception(
|
||||
status_code="HTTP_404_NOT_FOUND",
|
||||
error_case="RECORD_NOT_FOUND",
|
||||
message=f"No services found for this module : {str(self.uu_id)}",
|
||||
data={
|
||||
"module_uu_id": str(self.uu_id),
|
||||
},
|
||||
)
|
||||
return services.data
|
||||
|
||||
__table_args__ = ({"comment": "Modules Information"},)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from api_validations.validations_request import ListOptions
|
||||
from databases.sql_models.response_model import AlchemyResponse
|
||||
from databases.sql_models.postgres_database import Base
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ class FilterAttributes:
|
|||
|
||||
pre_query = None # The query to use before the filtering such as: query = cls.query.filter_by(active=True)
|
||||
filter_attr = None # The filter attributes to use in the model.
|
||||
FilterModel: ListOptions = ListOptions
|
||||
|
||||
def flush(self):
|
||||
"""Flush the current session."""
|
||||
|
|
@ -101,14 +103,16 @@ class FilterAttributes:
|
|||
return arg[0]
|
||||
|
||||
@classmethod
|
||||
def filter_by_all(cls, **kwargs):
|
||||
def filter_by_all(cls, **kwargs):
|
||||
"""
|
||||
Filters all the records regardless of is_deleted, is_confirmed.
|
||||
"""
|
||||
filter_list = cls.get_filter_attributes()
|
||||
query = cls._query().filter_by(**kwargs)
|
||||
data = cls.add_query_to_filter(query, filter_list)
|
||||
return AlchemyResponse(query=data, first=False)
|
||||
if cls.filter_attr:
|
||||
filter_list = cls.get_filter_attributes()
|
||||
data_query = cls.add_query_to_filter(query, filter_list)
|
||||
return AlchemyResponse(query=data_query, first=False)
|
||||
return AlchemyResponse(query=query, first=False)
|
||||
|
||||
@classmethod
|
||||
def filter_by_one(cls, **kwargs):
|
||||
|
|
@ -123,17 +127,18 @@ class FilterAttributes:
|
|||
"""
|
||||
Filters all the records regardless of is_deleted, is_confirmed.
|
||||
"""
|
||||
filter_list = cls.get_filter_attributes()
|
||||
query = cls._query()
|
||||
data = cls.add_query_to_filter(query, filter_list)
|
||||
return AlchemyResponse(query=data, first=False)
|
||||
query = cls._query().filter(*args)
|
||||
if cls.filter_attr:
|
||||
filter_list = cls.get_filter_attributes()
|
||||
data_query = cls.add_query_to_filter(query, filter_list)
|
||||
return AlchemyResponse(query=data_query, first=False)
|
||||
return AlchemyResponse(query=query, first=False)
|
||||
|
||||
@classmethod
|
||||
def filter_one(cls, *args, expired: bool = False):
|
||||
"""
|
||||
Filters one record regardless of is_deleted, is_confirmed.
|
||||
"""
|
||||
|
||||
arg = cls.get_not_expired_query_arg(args, expired=expired)
|
||||
query = cls._query().filter(*arg)
|
||||
return AlchemyResponse(query=query, first=True)
|
||||
|
|
|
|||
|
|
@ -89,8 +89,6 @@ def check_if_token_is_not_valid(request, endpoint_name):
|
|||
# token_user,
|
||||
# )
|
||||
|
||||
# CompanyDutyApp.session.commit()
|
||||
# CompanyDutyApp.session.flush()
|
||||
#
|
||||
# if endpoint_name in release_endpoint:
|
||||
# return "valid", token_user
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertAddress,
|
||||
SearchAddress,
|
||||
ListOptions,
|
||||
PatchRecord,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
address_router = APIRouter(prefix="/address", tags=["Address"])
|
||||
address_router.include_router(address_router, include_in_schema=True)
|
||||
|
||||
|
||||
@address_router.post(path="/list", summary="List Active/Delete/Confirm Address")
|
||||
def address_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@address_router.post(path="/create", summary="Create Address with given auth levels")
|
||||
def address_create(request: Request, data: InsertAddress):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@address_router.post(path="/search", summary="Search Address with given auth levels")
|
||||
def address_search(request: Request, data: SearchAddress):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@address_router.post(
|
||||
path="/update/{address_uu_id}", summary="Update Address with given auth levels"
|
||||
)
|
||||
def address_update(request: Request, address_uu_id: str, data: InsertAddress):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, address_uu_id=address_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@address_router.patch(
|
||||
path="/patch/{address_uu_id}", summary="Update Address Active/Delete/Confirm"
|
||||
)
|
||||
def address_patch(request: Request, address_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, address_uu_id=address_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertPostCode,
|
||||
ListOptions,
|
||||
PatchRecord,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
post_code_router = APIRouter(prefix="/postcode", tags=["Post Code"])
|
||||
post_code_router.include_router(post_code_router, include_in_schema=True)
|
||||
|
||||
|
||||
@post_code_router.post(path="/list", summary="List Active/Delete/Confirm PostCode")
|
||||
def post_code_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@post_code_router.post(path="/create", summary="Create PostCode with given auth levels")
|
||||
def post_code_create(request: Request, data: InsertPostCode):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@post_code_router.post(
|
||||
path="/update/{post_code_uu_id}", summary="Update PostCode with given auth levels"
|
||||
)
|
||||
def post_code_update(request: Request, post_code_uu_id: str, data: InsertPostCode):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, post_code_uu_id=post_code_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@post_code_router.patch(
|
||||
path="/patch/{post_code_uu_id}", summary="Update PostCode Active/Delete/Confirm"
|
||||
)
|
||||
def post_code_patch(request: Request, post_code_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, post_code_uu_id=post_code_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
import json
|
||||
import typing
|
||||
import zlib
|
||||
from base64 import b64decode
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.requests import Request
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
internal_route = APIRouter(prefix="/internal", tags=["Internal"])
|
||||
internal_route.include_router(internal_route, include_in_schema=False)
|
||||
|
||||
|
||||
class ApiReceive(BaseModel):
|
||||
data: str
|
||||
|
||||
|
||||
class BankReceive(BaseModel):
|
||||
import_file_name: str
|
||||
iban: str
|
||||
bank_date: str
|
||||
channel_branch: str
|
||||
currency: typing.Optional[str] = "TL"
|
||||
currency_value: float
|
||||
bank_balance: float
|
||||
additional_balance: float
|
||||
process_name: str
|
||||
process_type: str
|
||||
process_comment: str
|
||||
bank_reference_code: str
|
||||
|
||||
|
||||
@internal_route.post(
|
||||
path="/isbank/retreive",
|
||||
summary="Receive isbank xls service from mail reader service",
|
||||
)
|
||||
def is_bank_retrieve_account_records(request: Request, bank_data: ApiReceive):
|
||||
from database_sql_models import AccountRecords
|
||||
|
||||
data_dict = bank_data.model_dump()
|
||||
data_bulk = json.loads(zlib.decompress(b64decode(data_dict["data"])))
|
||||
print("data_bulk", data_bulk)
|
||||
new_record_list = []
|
||||
for data_keys in data_bulk: # data_bulk is a dict
|
||||
for data_dict in data_bulk[data_keys]: # data_bulk[data_keys] is a list
|
||||
data_dict["bank_balance"] = data_dict.pop("balance")
|
||||
data_dict["import_file_name"] = str(data_keys)
|
||||
print("data_dict before pyd", data_dict)
|
||||
data_dict = BankReceive(**data_dict).model_dump()
|
||||
print("data_dict after pyd", data_dict)
|
||||
if new_account_record := AccountRecords.find_or_create(**data_dict):
|
||||
print("new_account_record.is_found", new_account_record.is_found)
|
||||
if not new_account_record.is_found:
|
||||
new_record_list.append(new_account_record.get_dict())
|
||||
if new_record_list:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Bank Record",
|
||||
"data": new_record_list,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Record already exist or can not be created",
|
||||
},
|
||||
status_code=status.HTTP_406_NOT_ACCEPTABLE,
|
||||
)
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
from fastapi import status
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.exceptions import HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from databases import ApiEnumDropdown
|
||||
from api_validations.validations_request import (
|
||||
SingleEnumClassKey,
|
||||
SingleEnumUUID,
|
||||
SingleEnumOnlyClass,
|
||||
)
|
||||
|
||||
|
||||
enums_route = APIRouter(prefix="/enums", tags=["Enums and Dropdowns of API"])
|
||||
enums_route.include_router(enums_route, include_in_schema=False)
|
||||
|
||||
|
||||
@enums_route.post(path="/get/key", summary="Get single enum via key")
|
||||
def get_single_enum_via_key_and_class(data: SingleEnumClassKey):
|
||||
enum = ApiEnumDropdown.query.filter(
|
||||
ApiEnumDropdown.enum_class.ilike(data.class_name),
|
||||
ApiEnumDropdown.key.ilike(data.key_name),
|
||||
).populate_existing()
|
||||
if record := enum.first():
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Get single enum via key",
|
||||
"data": record.get_enum_dict() if enum else None,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Enum not found",
|
||||
)
|
||||
|
||||
|
||||
@enums_route.post(path="/get/uu_id", summary="Get single enum via uu_id")
|
||||
def get_single_enum_via_uuid(data: SingleEnumUUID):
|
||||
enum = ApiEnumDropdown.query.filter(
|
||||
ApiEnumDropdown.uu_id == data.uu_id
|
||||
).populate_existing()
|
||||
if records := enum.first():
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Get single enum via uu_id",
|
||||
"data": records.get_enum_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Enum not found",
|
||||
)
|
||||
|
||||
|
||||
@enums_route.post(path="/list/class", summary="Get all enums via class")
|
||||
def list_all_enums_with_class(data: SingleEnumOnlyClass):
|
||||
enums = ApiEnumDropdown.query.filter(
|
||||
ApiEnumDropdown.enum_class.ilike(data.class_name or "")
|
||||
).populate_existing()
|
||||
if records := enums.all():
|
||||
records_list = [record.get_enum_dict() for record in records]
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Get all enums via class",
|
||||
"count": len(records_list),
|
||||
"data": records_list,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Enums not found",
|
||||
)
|
||||
|
||||
|
||||
@enums_route.post(path="/list/all", summary="Get all enums")
|
||||
def list_all_enums():
|
||||
enums = ApiEnumDropdown.query.filter().populate_existing()
|
||||
if records := enums.all():
|
||||
records_list = [record.get_enum_dict() for record in records]
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"count": len(records_list),
|
||||
"message": "Get all enums",
|
||||
"data": records_list,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Enums can not be listed",
|
||||
)
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
from fastapi import status
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.exceptions import HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from databases import OccupantTypes
|
||||
from api_validations.validations_request import (
|
||||
SingleOccupantTypeClassKey,
|
||||
SingleOccupantTypeUUID,
|
||||
)
|
||||
|
||||
|
||||
occupant_types_route = APIRouter(prefix="/occupant_types", tags=["Occupant Types"])
|
||||
occupant_types_route.include_router(occupant_types_route, include_in_schema=False)
|
||||
|
||||
|
||||
@occupant_types_route.post(
|
||||
path="/get/code", summary="Get single occupant type via code"
|
||||
)
|
||||
def get_single_occupant_type_via_code(data: SingleOccupantTypeClassKey):
|
||||
occupant_type = OccupantTypes.query.filter(
|
||||
OccupantTypes.occupant_code.ilike(data.type_code)
|
||||
).populate_existing()
|
||||
if record := occupant_type.first():
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Get single occupant type via code",
|
||||
"data": record.get_dict() if record else None,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Occupant type not found",
|
||||
)
|
||||
|
||||
|
||||
@occupant_types_route.post(
|
||||
path="/get/uu_id", summary="Get single occupant type via uu_id"
|
||||
)
|
||||
def get_single_occupant_type_via_uuid(data: SingleOccupantTypeUUID):
|
||||
occupant_type = OccupantTypes.query.filter(
|
||||
OccupantTypes.uu_id == data.uu_id
|
||||
).populate_existing()
|
||||
if records := occupant_type.first():
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Get single occupant type via uu_id",
|
||||
"data": records.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Occupant type not found",
|
||||
)
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
Login,
|
||||
Logout,
|
||||
ChangePassword,
|
||||
Remember,
|
||||
Forgot,
|
||||
CreatePassword,
|
||||
OccupantSelection,
|
||||
EmployeeSelection,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_events.events import (
|
||||
AuthenticationLoginEventMethod,
|
||||
AuthenticationSelectEventMethod,
|
||||
AuthenticationCheckTokenEventMethod,
|
||||
AuthenticationRefreshEventMethod,
|
||||
AuthenticationChangePasswordEventMethod,
|
||||
AuthenticationCreatePasswordEventMethod,
|
||||
AuthenticationDisconnectUserEventMethod,
|
||||
AuthenticationLogoutEventMethod,
|
||||
AuthenticationRefreshTokenEventMethod,
|
||||
AuthenticationForgotPasswordEventMethod,
|
||||
AuthenticationDownloadAvatarEventMethod,
|
||||
)
|
||||
|
||||
login_route = APIRouter(prefix="/authentication", tags=["Authentication"])
|
||||
login_route.include_router(login_route, include_in_schema=True)
|
||||
|
||||
|
||||
@login_route.post(path="/select", summary="Select company or occupant type")
|
||||
def authentication_select_company_or_occupant_type(
|
||||
request: Request, data: Union[EmployeeSelection, OccupantSelection]
|
||||
):
|
||||
|
||||
active_function = getattr(
|
||||
AuthenticationSelectEventMethod,
|
||||
"authentication_select_company_or_occupant_type",
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=None)
|
||||
|
||||
|
||||
@login_route.post(path="/login", summary="Login user with domain and password")
|
||||
def authentication_login_with_domain_and_creds(request: Request, data: Login):
|
||||
|
||||
active_function = getattr(
|
||||
AuthenticationLoginEventMethod, "authentication_login_with_domain_and_creds"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=None)
|
||||
|
||||
|
||||
@login_route.get(path="/valid", summary="Check access token is valid")
|
||||
def authentication_check_token_is_valid(request: Request):
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(
|
||||
AuthenticationCheckTokenEventMethod, "authentication_check_token_is_valid"
|
||||
)
|
||||
return active_function(request=request, token_dict=token_dict)
|
||||
|
||||
|
||||
@login_route.get(path="/refresh", summary="Refresh credentials with access token")
|
||||
def authentication_refresh_user_info(request: Request):
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(
|
||||
AuthenticationRefreshEventMethod, "authentication_refresh_user_info"
|
||||
)
|
||||
return active_function(request=request, token_dict=token_dict)
|
||||
|
||||
|
||||
@login_route.post(path="/change_password", summary="Change password with access token")
|
||||
def authentication_change_password(request: Request, data: ChangePassword):
|
||||
|
||||
active_function = getattr(
|
||||
AuthenticationChangePasswordEventMethod, "authentication_change_password"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=None)
|
||||
|
||||
|
||||
@login_route.post(
|
||||
path="/create_password", summary="Create password with password token"
|
||||
)
|
||||
def authentication_create_password(request: Request, data: CreatePassword):
|
||||
|
||||
active_function = getattr(
|
||||
AuthenticationCreatePasswordEventMethod, "authentication_create_password"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=None)
|
||||
|
||||
|
||||
@login_route.post(path="/disconnect", summary="Disconnect user with access token")
|
||||
def authentication_disconnect_user(request: Request, data: Logout):
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(
|
||||
AuthenticationDisconnectUserEventMethod, "authentication_disconnect_user"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=token_dict)
|
||||
|
||||
|
||||
@login_route.post(path="/logout", summary="Logout user with access token")
|
||||
def authentication_logout_user(request: Request, data: Logout):
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(
|
||||
AuthenticationLogoutEventMethod, "authentication_logout_user"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=token_dict)
|
||||
|
||||
|
||||
@login_route.post(path="/refresher", summary="Refresh token with refresh token")
|
||||
def authentication_refresher_token(request: Request, data: Remember):
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(
|
||||
AuthenticationRefreshTokenEventMethod, "authentication_refresher_token"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=token_dict)
|
||||
|
||||
|
||||
@login_route.post(path="/forgot", summary="Forgot password with email or phone number")
|
||||
def authentication_forgot_password(request: Request, data: Forgot):
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(
|
||||
AuthenticationForgotPasswordEventMethod, "authentication_forgot_password"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=token_dict)
|
||||
|
||||
|
||||
@login_route.post(path="/avatar", summary="Get link of avatar with credentials")
|
||||
def authentication_download_avatar(request: Request, data: Forgot):
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(
|
||||
AuthenticationDownloadAvatarEventMethod, "authentication_download_avatar"
|
||||
)
|
||||
return active_function(data=data, request=request, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
InsertBuild,
|
||||
UpdateBuild,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
build_route = APIRouter(prefix="/building/build", tags=["Building"])
|
||||
build_route.include_router(build_route, include_in_schema=True)
|
||||
|
||||
|
||||
@build_route.post(path="/list", summary="List Build Active/Delete/Confirm Build")
|
||||
def building_build_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_route.post(path="/create", summary="Create Build with given auth levels")
|
||||
def building_build_create(request: Request, data: InsertBuild):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_route.post(path="/update/{build_uu_id}", summary="Update Build Parts with given auth levels")
|
||||
def building_build_update(request: Request, build_uu_id: str, data: UpdateBuild):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, build_uu_id=build_uu_id, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_route.patch(path="/patch/{build_uu_id}", summary="Patch Build Parts with given auth levels")
|
||||
def building_build_patch(request: Request, build_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, build_uu_id=build_uu_id, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
from fastapi import status
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildArea,
|
||||
UpdateBuildArea,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from databases import (
|
||||
BuildArea,
|
||||
Build,
|
||||
|
||||
)
|
||||
|
||||
|
||||
build_area_route = APIRouter(prefix="/building/area", tags=["Building Area"])
|
||||
build_area_route.include_router(build_area_route, include_in_schema=True)
|
||||
|
||||
|
||||
@build_area_route.post(path="/list", summary="List Active/Delete/Confirm Build Parts")
|
||||
def build_area_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
Build.filter_attr = list_options
|
||||
records = BuildArea.filter_active(
|
||||
*BuildArea.get_smart_query(smart_query=list_options.query),
|
||||
BuildArea.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
return return_json_response_from_alchemy(response=records, pagination=list_options)
|
||||
|
||||
|
||||
@build_area_route.post(
|
||||
path="/create", summary="Create BuildParts with given auth levels"
|
||||
)
|
||||
def build_area_create(request: Request, data: InsertBuildArea):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
created_build = BuildArea.create_action(data=data, token=token_dict)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create BuildParts record",
|
||||
"data": created_build.get_dict(),
|
||||
"build": created_build,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
@build_area_route.post(
|
||||
path="/update/{build_uu_id}", summary="Update BuildParts with given auth levels"
|
||||
)
|
||||
def build_area_update(request: Request, build_uu_id: str, data: UpdateBuildArea):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
if updated_build := BuildArea.update_action(
|
||||
data=data, token=token_dict, build_uu_id=build_uu_id
|
||||
):
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update BuildParts record",
|
||||
"data": updated_build,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={"completed": True, "message": "Update BuildParts record", "data": {}},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
@build_area_route.patch(
|
||||
path="/patch/{build_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def build_area_patch(request: Request, build_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
find_one_build = BuildArea.find_one_or_abort(uu_id=build_uu_id)
|
||||
access_authorized_build = BuildArea.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[BuildArea.id == find_one_build.id],
|
||||
)
|
||||
if access_authorized_build.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_build.active = bool(action.get("active", find_one_build.active))
|
||||
find_one_build.is_confirmed = bool(
|
||||
action.get("confirm", find_one_build.is_confirmed)
|
||||
)
|
||||
find_one_build.deleted = bool(action.get("delete", find_one_build.deleted))
|
||||
find_one_build.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch BuildParts record completed",
|
||||
"data": find_one_build.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch BuildParts record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
from fastapi import status
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildParts,
|
||||
UpdateBuildParts,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from databases import BuildParts
|
||||
|
||||
|
||||
build_parts_route = APIRouter(prefix="/building/parts", tags=["Building Parts"])
|
||||
build_parts_route.include_router(build_parts_route, include_in_schema=True)
|
||||
|
||||
|
||||
@build_parts_route.post(path="/list", summary="List Active/Delete/Confirm Build Parts")
|
||||
def building_build_part_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_parts_route.post(
|
||||
path="/create", summary="Create Build Parts with given auth levels"
|
||||
)
|
||||
def building_build_part_create(request: Request, data: InsertBuildParts):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_parts_route.post(
|
||||
path="/update/{build_uu_id}", summary="Update Build Parts with given auth levels"
|
||||
)
|
||||
def building_build_part_update(
|
||||
request: Request, build_uu_id: str, data: UpdateBuildParts
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
if updated_build := BuildParts.update_action(
|
||||
data=data, token=token_dict, build_uu_id=build_uu_id
|
||||
):
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Build Parts record",
|
||||
"data": updated_build,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={"completed": True, "message": "Update Build Parts record", "data": {}},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
@build_parts_route.patch(
|
||||
path="/patch/{build_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def building_build_part_patch(request: Request, build_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
find_one_build = BuildParts.find_one_or_abort(uu_id=build_uu_id)
|
||||
access_authorized_build = BuildParts.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[BuildParts.id == find_one_build.id],
|
||||
)
|
||||
if access_authorized_build.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_build.active = bool(action.get("active", find_one_build.active))
|
||||
find_one_build.is_confirmed = bool(
|
||||
action.get("confirm", find_one_build.is_confirmed)
|
||||
)
|
||||
find_one_build.deleted = bool(action.get("delete", find_one_build.deleted))
|
||||
find_one_build.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch Build record completed",
|
||||
"data": find_one_build.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch Build record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
from fastapi import status
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.requests import Request
|
||||
|
||||
|
||||
from api_validations.validations_request import (
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
InsertBuildSites,
|
||||
UpdateBuildSites,
|
||||
)
|
||||
|
||||
from databases import BuildSites
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
|
||||
build_sites_route = APIRouter(prefix="/building/sites", tags=["Building Sites"])
|
||||
build_sites_route.include_router(build_sites_route, include_in_schema=True)
|
||||
|
||||
|
||||
@build_sites_route.post(path="/list", summary="List Active/Delete/Confirm Build Parts")
|
||||
def building_sites_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
BuildSites.filter_attr = list_options
|
||||
records = BuildSites.filter_active(
|
||||
*BuildSites.get_smart_query(smart_query=list_options.query),
|
||||
BuildSites.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
return return_json_response_from_alchemy(response=records, pagination=list_options)
|
||||
|
||||
|
||||
@build_sites_route.post(
|
||||
path="/create", summary="Create Build Sites with given auth levels"
|
||||
)
|
||||
def building_sites_create(request: Request, data: InsertBuildSites):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
created_build = BuildSites.create_action(data=data, token=token_dict)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Build Sites record",
|
||||
"data": created_build.get_dict(),
|
||||
"build": created_build,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
@build_sites_route.post(
|
||||
path="/update/{build_uu_id}", summary="Update Build Sites with given auth levels"
|
||||
)
|
||||
def building_sites_update(request: Request, build_uu_id: str, data: UpdateBuildSites):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
if updated_build := BuildSites.update_action(
|
||||
data=data, token=token_dict, build_uu_id=build_uu_id
|
||||
):
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Build Sites record",
|
||||
"data": updated_build,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={"completed": True, "message": "Update Build Sites record", "data": {}},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
@build_sites_route.patch(
|
||||
path="/patch/{build_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def building_sites_patch(request: Request, build_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
find_one_build = BuildSites.find_one_or_abort(uu_id=build_uu_id)
|
||||
access_authorized_build = BuildSites.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[BuildSites.id == find_one_build.id],
|
||||
)
|
||||
if access_authorized_build.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_build.active = bool(action.get("active", find_one_build.active))
|
||||
find_one_build.is_confirmed = bool(
|
||||
action.get("confirm", find_one_build.is_confirmed)
|
||||
)
|
||||
find_one_build.deleted = bool(action.get("delete", find_one_build.deleted))
|
||||
find_one_build.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch Build Sites record completed",
|
||||
"data": find_one_build.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch Build Sites record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
from fastapi import status
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildTypes,
|
||||
UpdateBuildTypes,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from databases import BuildTypes
|
||||
|
||||
|
||||
build_types_route = APIRouter(prefix="/building/types", tags=["Types"])
|
||||
build_types_route.include_router(build_types_route, include_in_schema=True)
|
||||
|
||||
|
||||
@build_types_route.post(path="/list", summary="List Active/Delete/Confirm Build Parts")
|
||||
def building_types_list(list_options: ListOptions):
|
||||
BuildTypes.filter_attr = list_options
|
||||
records = BuildTypes.filter_active(
|
||||
*BuildTypes.get_smart_query(smart_query=list_options.query),
|
||||
)
|
||||
return return_json_response_from_alchemy(response=records, pagination=list_options)
|
||||
|
||||
|
||||
@build_types_route.post(
|
||||
path="/create", summary="Create BuildParts with given auth levels"
|
||||
)
|
||||
def building_types_create(request: Request, data: InsertBuildTypes):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
created_build = BuildTypes.create_action(data=data, token=token_dict)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create BuildParts record",
|
||||
"data": created_build.get_dict(),
|
||||
"build": created_build,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
@build_types_route.post(
|
||||
path="/update/{build_uu_id}", summary="Update BuildParts with given auth levels"
|
||||
)
|
||||
def building_types_update(request: Request, build_uu_id: str, data: UpdateBuildTypes):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
if updated_build := BuildTypes.update_action(
|
||||
data=data, token=token_dict, build_uu_id=build_uu_id
|
||||
):
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update BuildParts record",
|
||||
"data": updated_build,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={"completed": True, "message": "Update BuildParts record", "data": {}},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
@build_types_route.patch(
|
||||
path="/patch/{build_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def building_types_patch(request: Request, build_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
find_one_build = BuildTypes.find_one_or_abort(uu_id=build_uu_id)
|
||||
access_authorized_build = BuildTypes.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[BuildTypes.id == find_one_build.id],
|
||||
)
|
||||
if access_authorized_build.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_build.active = bool(action.get("active", find_one_build.active))
|
||||
find_one_build.is_confirmed = bool(
|
||||
action.get("confirm", find_one_build.is_confirmed)
|
||||
)
|
||||
find_one_build.deleted = bool(action.get("delete", find_one_build.deleted))
|
||||
find_one_build.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch BuildParts record completed",
|
||||
"data": find_one_build.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch BuildParts record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildLivingSpace,
|
||||
UpdateBuildLivingSpace,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
build_living_space = APIRouter(prefix="/building/living_space", tags=["Living Space"])
|
||||
build_living_space.include_router(build_living_space, include_in_schema=True)
|
||||
|
||||
|
||||
@build_living_space.post(
|
||||
path="/list", summary="List Active/Delete/Confirm Build Living Space"
|
||||
)
|
||||
def building_living_space_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_living_space.post(
|
||||
path="/create", summary="Create Build Living Space with given auth levels"
|
||||
)
|
||||
def building_living_space_create(request: Request, data: InsertBuildLivingSpace):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_living_space.post(
|
||||
path="/update/{build_uu_id}",
|
||||
summary="Update Build Living Space with given auth levels",
|
||||
)
|
||||
def building_living_space_update(
|
||||
request: Request, build_uu_id: str, data: UpdateBuildLivingSpace
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, build_uu_id=build_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@build_living_space.patch(
|
||||
path="/patch/{build_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def building_living_space_patch(request: Request, build_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, build_uu_id=build_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertCompany,
|
||||
UpdateCompany,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
company_route = APIRouter(prefix="/company", tags=["Company"])
|
||||
company_route.include_router(company_route, include_in_schema=True)
|
||||
|
||||
|
||||
@company_route.post(path="/list", summary="List Active/Delete/Confirm Companies")
|
||||
def company_company_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@company_route.post(path="/create", summary="Create Company with given auth levels")
|
||||
def company_company_create(request: Request, data: InsertCompany):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@company_route.post(
|
||||
path="/update/{company_uu_id}", summary="Update Company with given auth levels"
|
||||
)
|
||||
def company_company_update(request: Request, company_uu_id: str, data: UpdateCompany):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@company_route.patch(
|
||||
path="/patch/{company_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def company_company_patch(request: Request, company_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
department_route = APIRouter(prefix="/department", tags=["Departments"])
|
||||
department_route.include_router(department_route, include_in_schema=True)
|
||||
|
||||
|
||||
@department_route.post(path="/list", summary="List Active/Delete/Confirm Departments")
|
||||
def company_department_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@department_route.post(path="/create", summary="Create Company with given auth levels")
|
||||
def company_department_create(request: Request, data: DepartmentsPydantic):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@department_route.post(
|
||||
path="/update/{company_uu_id}", summary="Update Company with given auth levels"
|
||||
)
|
||||
def company_department_update(
|
||||
request: Request, company_uu_id: str, data: DepartmentsPydantic
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
company_uu_id=company_uu_id, data=data, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@department_route.patch(
|
||||
path="/patch/{company_uu_id}", summary="Patch Company with given auth levels"
|
||||
)
|
||||
def company_department_patch(request: Request, company_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
company_uu_id=company_uu_id, data=data, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertDuties,
|
||||
UpdateDuties,
|
||||
SelectDuties,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
duties_route = APIRouter(prefix="/duties", tags=["Duties"])
|
||||
duties_route.include_router(duties_route, include_in_schema=True)
|
||||
|
||||
|
||||
@duties_route.post(path="/list", summary="List Active/Delete/Confirm Duties")
|
||||
def company_duties_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@duties_route.post(path="/get_by_duty_uuid", summary="Get Single Duty by Duty UUID")
|
||||
def company_duties_get_by_duty_uuid(request: Request, data: SelectDuties):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@duties_route.post(path="/create", summary="Create Duties with given auth levels")
|
||||
def company_duties_create(request: Request, data: InsertDuties):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@duties_route.post(
|
||||
path="/update/{duties_uu_id}", summary="Update Duties with given auth levels"
|
||||
)
|
||||
def company_duties_update(request: Request, duties_uu_id: str, data: UpdateDuties):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, duties_uu_id=duties_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@duties_route.patch(
|
||||
path="/patch/{duties_uu_id}", summary="Patch Duties with given auth levels"
|
||||
)
|
||||
def company_duties_patch(request: Request, duties_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, duties_uu_id=duties_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertCompanyDuty,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
duty_route = APIRouter(prefix="/duty", tags=["Duty"])
|
||||
duty_route.include_router(duty_route, include_in_schema=True)
|
||||
|
||||
|
||||
@duty_route.post(path="/list", summary="List Active/Delete/Confirm Duty")
|
||||
def company_duty_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@duty_route.post(path="/create", summary="Create Company with given auth levels")
|
||||
def company_duty_create(request: Request, data: InsertCompanyDuty):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@duty_route.post(
|
||||
path="/update/{company_uu_id}", summary="Update Company with given auth levels"
|
||||
)
|
||||
def company_duty_update(request: Request, company_uu_id: str, data):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@duty_route.patch(path="/patch/{company_uu_id}", summary="Update Active/Delete/Confirm")
|
||||
def company_duty_patch(request: Request, company_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertEmployees,
|
||||
UnBindEmployees2People,
|
||||
BindEmployees2People,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
employee_route = APIRouter(prefix="/employee", tags=["Employee"])
|
||||
employee_route.include_router(employee_route, include_in_schema=True)
|
||||
|
||||
|
||||
@employee_route.post(path="/list", summary="List Active/Delete/Confirm Staff")
|
||||
def company_employee_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@employee_route.post(path="/create", summary="Create Employee with given auth levels")
|
||||
def company_employee_create(request: Request, data: InsertEmployees):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@employee_route.post(
|
||||
path="/update/{employee_uu_id}", summary="Update Employee with given auth levels"
|
||||
)
|
||||
def company_employee_update(request: Request, employee_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, employee_uu_id=employee_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@employee_route.patch(
|
||||
path="/patch/{employee_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def company_employee_patch(request: Request, employee_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, employee_uu_id=employee_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@employee_route.post(path="/employ", summary="Employ Employee with given auth levels")
|
||||
def company_employee_employ(request: Request, data: BindEmployees2People):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@employee_route.post(path="/fire", summary="UnEmploy Employee with given auth levels")
|
||||
def company_employee_fire(request: Request, data: UnBindEmployees2People):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertStaff,
|
||||
SelectStaff,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
staff_route = APIRouter(prefix="/staff", tags=["Staff"])
|
||||
staff_route.include_router(staff_route, include_in_schema=True)
|
||||
|
||||
|
||||
@staff_route.post(path="/list", summary="List Active/Delete/Confirm Staff")
|
||||
def company_staff_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@staff_route.post(path="/get_by_duties_uu_id", summary="Get Staff by UUID")
|
||||
def company_staff_get_by_uu_id(request: Request, data: SelectStaff):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@staff_route.post(path="/create", summary="Create Staff with given auth levels")
|
||||
def company_staff_create(request: Request, data: InsertStaff):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@staff_route.post(
|
||||
path="/update/{staff_uu_id}", summary="Update Staff with given auth levels"
|
||||
)
|
||||
def company_staff_update(request: Request, staff_uu_id: str, data):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, staff_uu_id=staff_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@staff_route.patch(path="/patch/{staff_uu_id}", summary="Update Active/Delete/Confirm")
|
||||
def company_staff_patch(request: Request, staff_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, staff_uu_id=staff_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertDecisionBook,
|
||||
UpdateDecisionBook,
|
||||
DecisionBookDecisionBookInvitations,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
build_decision_book_route = APIRouter(
|
||||
prefix="/build/decision_book", tags=["Decision Book"]
|
||||
)
|
||||
build_decision_book_route.include_router(
|
||||
build_decision_book_route, include_in_schema=True
|
||||
)
|
||||
|
||||
|
||||
@build_decision_book_route.post(
|
||||
path="/list", summary="List Active/Delete/Confirm Build Decision Book"
|
||||
)
|
||||
def build_decision_book_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_route.post(
|
||||
path="/create", summary="Create Build Decision Book with given auth levels"
|
||||
)
|
||||
def build_decision_book_create(request: Request, data: InsertDecisionBook):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_route.post(
|
||||
path="/approval", summary="Approve Build Decision Book with given auth levels"
|
||||
)
|
||||
def build_decision_book_approval(request: Request, data):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_route.post(
|
||||
path="/update/{book_uu_id}",
|
||||
summary="Update Build Decision Book with given auth levels",
|
||||
)
|
||||
def build_decision_book_update(
|
||||
request: Request, book_uu_id: str, data: UpdateDecisionBook
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_route.patch(
|
||||
path="/patch/{book_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def build_decision_book_patch(request: Request, book_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_route.post(
|
||||
path="/invite/list", summary="List Build Decision Book Invitations"
|
||||
)
|
||||
def build_decision_book_invite(request: Request, data: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_route.post(
|
||||
path="/invite/create", summary="Create Build Decision Book Invitations"
|
||||
)
|
||||
def build_decision_book_invite_create(
|
||||
request: Request, data: DecisionBookDecisionBookInvitations
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_route.post(
|
||||
path="/invite/update", summary="Update Build Decision Book Invitations"
|
||||
)
|
||||
def build_decision_book_invite_update(request: Request, data):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
DecisionBookDecisionBookInvitationsAttend,
|
||||
DecisionBookDecisionBookInvitationsAssign,
|
||||
PatchRecord,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
build_decision_book_invitations = APIRouter(
|
||||
prefix="/build/decision_book/invitations", tags=["Decision Book Invitations"]
|
||||
)
|
||||
build_decision_book_invitations.include_router(
|
||||
build_decision_book_invitations, include_in_schema=True
|
||||
)
|
||||
|
||||
|
||||
@build_decision_book_invitations.post(
|
||||
path="/attend", summary="Decision Book Invitations Attend"
|
||||
)
|
||||
def build_decision_book_invitations_attend(
|
||||
request: Request, data: DecisionBookDecisionBookInvitationsAttend
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_invitations.post(
|
||||
path="/assign", summary="Decision Book Invitations Assign"
|
||||
)
|
||||
def build_decision_book_invitations_assign(
|
||||
request: Request, data: DecisionBookDecisionBookInvitationsAssign
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildDecisionBookItems,
|
||||
UpdateBuildDecisionBookItems,
|
||||
ListDecisionBook,
|
||||
PatchRecord,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
build_decision_book_items_route = APIRouter(
|
||||
prefix="/build/decision_book/items", tags=["Decision Book Items"]
|
||||
)
|
||||
build_decision_book_items_route.include_router(
|
||||
build_decision_book_items_route, include_in_schema=True
|
||||
)
|
||||
|
||||
|
||||
@build_decision_book_items_route.post(
|
||||
path="/list", summary="List Active/Delete/Confirm Build Decision Book Items"
|
||||
)
|
||||
def build_decision_book_items_list(request: Request, data: ListDecisionBook):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_items_route.post(
|
||||
path="/create", summary="Create Build Items Decision Book with given auth levels"
|
||||
)
|
||||
def build_decision_book_items_create(
|
||||
request: Request, data: InsertBuildDecisionBookItems
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_items_route.post(
|
||||
path="/update/{book_uu_id}",
|
||||
summary="Update Build Decision Book Items with given auth levels",
|
||||
)
|
||||
def build_decision_book_items_update(
|
||||
request: Request, book_uu_id: str, data: UpdateBuildDecisionBookItems
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, book_uu_id=book_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@build_decision_book_items_route.patch(
|
||||
path="/patch/{book_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def build_decision_book_items_patch(
|
||||
request: Request, book_uu_id: str, data: PatchRecord
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, book_uu_id=book_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertDecisionBook,
|
||||
UpdateDecisionBook,
|
||||
DecisionBookDecisionBookInvitationsAttend,
|
||||
ListOptions,
|
||||
)
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
build_decision_book_people_route = APIRouter(
|
||||
prefix="/build/decision_book/people", tags=["Decision Book People"]
|
||||
)
|
||||
build_decision_book_people_route.include_router(
|
||||
build_decision_book_people_route, include_in_schema=True
|
||||
)
|
||||
|
||||
|
||||
@build_decision_book_people_route.post(
|
||||
path="/list", summary="List Active/Delete/Confirm Build Decision Book People"
|
||||
)
|
||||
def build_decision_book_people_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_people_route.post(
|
||||
path="/add",
|
||||
summary="Add people to Build Decision People Book with given auth levels",
|
||||
)
|
||||
def build_decision_book_people_add(request: Request, data: InsertDecisionBook):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_people_route.post(
|
||||
path="/remove",
|
||||
summary="Remove people from Build Decision Book People with given auth levels",
|
||||
)
|
||||
def build_decision_book_people_remove(request: Request, data: UpdateDecisionBook):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@build_decision_book_people_route.post(
|
||||
path="/attend",
|
||||
summary="Attend to Build Decision Book Invitations with given auth levels",
|
||||
)
|
||||
def build_decision_book_invite_attend(
|
||||
request: Request, data: DecisionBookDecisionBookInvitationsAttend
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_validations.validations_request import (
|
||||
RegisterEvents2Employee,
|
||||
RegisterEvents2Occupant,
|
||||
PatchRecord,
|
||||
)
|
||||
|
||||
|
||||
bind_events_route = APIRouter(prefix="/bind/events", tags=["Binds"])
|
||||
bind_events_route.include_router(bind_events_route, include_in_schema=True)
|
||||
|
||||
|
||||
@bind_events_route.post(path="/occupant", summary="Register Event to Occupant")
|
||||
def bind_events_occupant(request: Request, data: RegisterEvents2Occupant):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@bind_events_route.post(path="/employee", summary="Register Event to Employee")
|
||||
def bind_events_employee(request: Request, data: RegisterEvents2Employee):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@bind_events_route.patch(
|
||||
path="/patch/{event_uu_id}", summary="Patch Bind Events with given auth levels"
|
||||
)
|
||||
def bind_events_patch(request: Request, event_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, event_uu_id=event_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
from fastapi import Request
|
||||
from fastapi.routing import APIRouter
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_validations.validations_request import (
|
||||
CreateEvents,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
|
||||
event_route = APIRouter(prefix="/event", tags=["Events"])
|
||||
event_route.include_router(event_route, include_in_schema=True)
|
||||
|
||||
|
||||
@event_route.post(path="/create", summary="Create Event")
|
||||
def events_create(request: Request, data: CreateEvents):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@event_route.post(path="/list", summary="List Events")
|
||||
def events_list(request: Request, data: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@event_route.post(path="/update", summary="Update Event")
|
||||
def events_update(request: Request, data: CreateEvents):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
# @event_route.patch(path="/patch", summary="Patch Event")
|
||||
# def events_patch(request: Request, data: CreateEvents):
|
||||
# token_dict = parse_token_object_to_dict(request=request)
|
||||
# return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
model_entities_route = APIRouter(prefix="/model/entities", tags=["Model Entities"])
|
||||
model_entities_route.include_router(model_entities_route, include_in_schema=True)
|
||||
|
||||
|
||||
@model_entities_route.post(path="/list", summary="List Active/Delete/Confirm Events")
|
||||
def model_entities_list(request: Request, list_options: ListOptions):
|
||||
from events.events_model_entities import ModelEntitiesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEntitiesEvents, "model_entities_list")
|
||||
return active_function(data=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@model_entities_route.post(
|
||||
path="/create", summary="Create Events with given auth levels"
|
||||
)
|
||||
def model_entities_create(request: Request, data: DepartmentsPydantic):
|
||||
from events.events_model_entities import ModelEntitiesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEntitiesEvents, "model_entities_create")
|
||||
return active_function(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@model_entities_route.post(
|
||||
path="/update/{company_uu_id}", summary="Update Events with given auth levels"
|
||||
)
|
||||
def model_entities_update(
|
||||
request: Request, company_uu_id: str, data: DepartmentsPydantic
|
||||
):
|
||||
from events.events_model_entities import ModelEntitiesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEntitiesEvents, "model_entities_update")
|
||||
return active_function(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@model_entities_route.patch(
|
||||
path="/patch/{company_uu_id}", summary="Patch Events with given auth levels"
|
||||
)
|
||||
def model_entities_patch(request: Request, company_uu_id: str, data: PatchRecord):
|
||||
from events.events_model_entities import ModelEntitiesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEntitiesEvents, "model_entities_patch")
|
||||
return active_function(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
model_route = APIRouter(prefix="/model/entities", tags=["Model Entities"])
|
||||
model_route.include_router(model_route, include_in_schema=True)
|
||||
|
||||
|
||||
@model_route.post(path="/list", summary="List Active/Delete/Confirm Events")
|
||||
def model_list(request: Request, list_options: ListOptions):
|
||||
from events.events_models import ModelEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEvents, "model_list")
|
||||
return active_function(data=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@model_route.post(path="/create", summary="Create Events with given auth levels")
|
||||
def model_create(request: Request, data: DepartmentsPydantic):
|
||||
from events.events_models import ModelEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEvents, "model_create")
|
||||
return active_function(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@model_route.post(
|
||||
path="/update/{company_uu_id}", summary="Update Events with given auth levels"
|
||||
)
|
||||
def model_update(request: Request, company_uu_id: str, data: DepartmentsPydantic):
|
||||
from events.events_models import ModelEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEvents, "model_list")
|
||||
return active_function(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@model_route.patch(
|
||||
path="/patch/{company_uu_id}", summary="Patch Events with given auth levels"
|
||||
)
|
||||
def model_patch(request: Request, company_uu_id: str, data: PatchRecord):
|
||||
from events.events_models import ModelEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModelEvents, "model_list")
|
||||
return active_function(
|
||||
data=data, company_uu_id=company_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
modules_route = APIRouter(prefix="/modules", tags=["Modules"])
|
||||
modules_route.include_router(modules_route, include_in_schema=True)
|
||||
|
||||
|
||||
@modules_route.post(path="/list", summary="List Active/Delete/Confirm Modules")
|
||||
def modules_list(request: Request, list_options: ListOptions):
|
||||
from events.events_modules import ModulesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModulesEvents, "modules_list")
|
||||
return active_function(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@modules_route.post(path="/create", summary="Create Modules with given auth levels")
|
||||
def modules_create(request: Request, data: DepartmentsPydantic):
|
||||
from events.events_modules import ModulesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModulesEvents, "modules_create")
|
||||
return active_function(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@modules_route.post(
|
||||
path="/update/{module_uu_id}", summary="Update Modules with given auth levels"
|
||||
)
|
||||
def modules_update(request: Request, module_uu_id: str, data: DepartmentsPydantic):
|
||||
from events.events_modules import ModulesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModulesEvents, "modules_update")
|
||||
return active_function(data=data, module_uu_id=module_uu_id, token_dict=token_dict)
|
||||
|
||||
|
||||
@modules_route.patch(
|
||||
path="/patch/{module_uu_id}", summary="Patch Modules with given auth levels"
|
||||
)
|
||||
def modules_patch(request: Request, module_uu_id: str, data: PatchRecord):
|
||||
from events.events_modules import ModulesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ModulesEvents, "modules_patch")
|
||||
return active_function(data=data, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
RegisterServices2Employee,
|
||||
RegisterServices2Occupant,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
bind_services_route = APIRouter(prefix="/bind/services", tags=["Binds"])
|
||||
bind_services_route.include_router(bind_services_route, include_in_schema=True)
|
||||
|
||||
|
||||
@bind_services_route.post(path="/occupant", summary="Bind Services to Occupant")
|
||||
def bind_services_occupant(request: Request, data: RegisterServices2Occupant):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@bind_services_route.post(path="/employee", summary="Bind Services to Employee")
|
||||
def bind_services_employee(request: Request, data: RegisterServices2Employee):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic, PatchRecord, ListOptions
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
services_route = APIRouter(prefix="/services", tags=["Services"])
|
||||
services_route.include_router(services_route, include_in_schema=True)
|
||||
|
||||
|
||||
@services_route.post(path="/list", summary="List Active/Delete/Confirm Modules")
|
||||
def services_list(request: Request, list_options: ListOptions):
|
||||
from events.events_services import ServicesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ServicesEvents, "services_list")
|
||||
return active_function(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@services_route.post(path="/create", summary="Create Modules with given auth levels")
|
||||
def services_create(request: Request, data: DepartmentsPydantic):
|
||||
from events.events_services import ServicesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ServicesEvents, "services_create")
|
||||
return active_function(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@services_route.post(
|
||||
path="/update/{service_uu_id}", summary="Update Modules with given auth levels"
|
||||
)
|
||||
def services_update(request: Request, service_uu_id: str, data: DepartmentsPydantic):
|
||||
from events.events_services import ServicesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ServicesEvents, "services_update")
|
||||
return active_function(
|
||||
data=data, service_uu_id=service_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@services_route.patch(
|
||||
path="/patch/{service_uu_id}", summary="Patch Modules with given auth levels"
|
||||
)
|
||||
def services_patch(request: Request, service_uu_id: str, data: PatchRecord):
|
||||
from events.events_services import ServicesEvents
|
||||
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
active_function = getattr(ServicesEvents, "services_patch")
|
||||
return active_function(
|
||||
data=data, service_uu_id=service_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertPerson, UpdateUsers, PatchRecord, ListOptions
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
people_router = APIRouter(prefix="/people", tags=["People"])
|
||||
people_router.include_router(people_router, include_in_schema=True)
|
||||
|
||||
|
||||
@people_router.post(path="/list", summary="List Active/Delete/Confirm People")
|
||||
def people_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@people_router.post(path="/create", summary="Create People with given auth levels")
|
||||
def people_create(request: Request, data: InsertPerson):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@people_router.post(
|
||||
path="/update/{user_uu_id}", summary="Update People with given auth levels"
|
||||
)
|
||||
def people_update(request: Request, user_uu_id: str, data: UpdateUsers):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, user_uu_id=user_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@people_router.patch(path="/patch/{user_uu_id}", summary="Update Active/Delete/Confirm")
|
||||
def people_patch(request: Request, user_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, user_uu_id=user_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
from fastapi import status, HTTPException
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildDecisionBookProjects,
|
||||
UpdateBuildDecisionBookProjects,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from databases import BuildDecisionBookProjects
|
||||
|
||||
|
||||
build_project_decision_book_route = APIRouter(
|
||||
prefix="/build/project/decision_book", tags=["Project Decision Book"]
|
||||
)
|
||||
build_project_decision_book_route.include_router(
|
||||
build_project_decision_book_route, include_in_schema=True
|
||||
)
|
||||
|
||||
|
||||
@build_project_decision_book_route.post(
|
||||
path="/list", summary="List Active/Delete/Confirm Project Build Decision Book"
|
||||
)
|
||||
def project_decision_book_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
BuildDecisionBookProjects.pre_query = BuildDecisionBookProjects.select_action(
|
||||
duty_id=token_dict.duty_list["duty_id"]
|
||||
)
|
||||
build_decision_book_records = BuildDecisionBookProjects.filter_active(
|
||||
*BuildDecisionBookProjects.get_smart_query(list_options.query)
|
||||
)
|
||||
return return_json_response_from_alchemy(
|
||||
response=build_decision_book_records, pagination=list_options
|
||||
)
|
||||
|
||||
|
||||
@build_project_decision_book_route.post(
|
||||
path="/create", summary="Create Build Project Decision Book with given auth levels"
|
||||
)
|
||||
def project_decision_book_create(
|
||||
request: Request, data: InsertBuildDecisionBookProjects
|
||||
):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
if build_decision_book_records := BuildDecisionBookProjects.create_action(
|
||||
data=data, token=token_dict
|
||||
):
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Build record",
|
||||
"data": build_decision_book_records.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail=f"This user can not access/modify {data.build_uu_id} - building",
|
||||
)
|
||||
|
||||
|
||||
@build_project_decision_book_route.post(
|
||||
path="/update/{book_uu_id}",
|
||||
summary="Update Project Build Decision Book with given auth levels",
|
||||
)
|
||||
def project_decision_book_update(
|
||||
request: Request, book_uu_id: str, data: UpdateBuildDecisionBookProjects
|
||||
):
|
||||
return
|
||||
|
||||
|
||||
@build_project_decision_book_route.patch(
|
||||
path="/patch/{book_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def project_decision_book_patch(request: Request, book_uu_id: str, data: PatchRecord):
|
||||
return
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
from fastapi import status, HTTPException
|
||||
from fastapi.routing import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertDecisionBook, UpdateDecisionBook, PatchRecord, ListOptions
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
from databases import BuildDecisionBook, Build
|
||||
|
||||
|
||||
build_project_decision_book_person_route = APIRouter(
|
||||
prefix="/build/decision_book/person", tags=["Decision Book Person"]
|
||||
)
|
||||
build_project_decision_book_person_route.include_router(
|
||||
build_project_decision_book_person_route, include_in_schema=True
|
||||
)
|
||||
|
||||
|
||||
@build_project_decision_book_person_route.post(
|
||||
path="/list", summary="List Active/Delete/Confirm Build Decision Book"
|
||||
)
|
||||
def project_decision_book_person_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
BuildDecisionBook.pre_query = BuildDecisionBook.select_action(
|
||||
duty_id=token_dict.duty_list["duty_id"]
|
||||
)
|
||||
build_decision_book_records = BuildDecisionBook.filter_active(
|
||||
*BuildDecisionBook.get_smart_query(list_options.query)
|
||||
)
|
||||
return return_json_response_from_alchemy(
|
||||
response=build_decision_book_records, pagination=list_options
|
||||
)
|
||||
|
||||
|
||||
@build_project_decision_book_person_route.post(
|
||||
path="/create", summary="Create Build Decision Book with given auth levels"
|
||||
)
|
||||
def project_decision_book_person_create(request: Request, data: InsertDecisionBook):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
Build.pre_query = Build.select_action(duty_id=token_dict.duty_list["duty_id"])
|
||||
if Build.find_one(uu_id=data.build_uu_id):
|
||||
build_decision_book_records = BuildDecisionBook.create_action(data=data)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Build record",
|
||||
"data": build_decision_book_records.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail=f"This user can not access/modify {data.build_uu_id} - building",
|
||||
)
|
||||
|
||||
|
||||
@build_project_decision_book_person_route.post(
|
||||
path="/update/{book_uu_id}",
|
||||
summary="Update Build Decision Book with given auth levels",
|
||||
)
|
||||
def project_decision_book_person_update(
|
||||
request: Request, book_uu_id: str, data: UpdateDecisionBook
|
||||
):
|
||||
|
||||
return
|
||||
|
||||
|
||||
@build_project_decision_book_person_route.patch(
|
||||
path="/patch/{book_uu_id}", summary="Update Active/Delete/Confirm"
|
||||
)
|
||||
def project_decision_book_person_patch(
|
||||
request: Request, book_uu_id: str, data: PatchRecord
|
||||
):
|
||||
return
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import UpdateEndpointAccessList, InsertEndpointAccess
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
endpoint_restriction_route = APIRouter(prefix="/access", tags=["Endpoint Access"])
|
||||
endpoint_restriction_route.include_router(
|
||||
endpoint_restriction_route, include_in_schema=True
|
||||
)
|
||||
|
||||
|
||||
@endpoint_restriction_route.post(
|
||||
path="/endpoint/restriction/create",
|
||||
summary="Add extra restriction to endpoints list",
|
||||
)
|
||||
def endpoint_restriction_create(request: Request, data: InsertEndpointAccess):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return
|
||||
|
||||
|
||||
@endpoint_restriction_route.post(
|
||||
path="/endpoint/bind/update", summary="Update extra restriction to endpoints list"
|
||||
)
|
||||
def endpoint_restriction_update(request: Request, data: UpdateEndpointAccessList):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return
|
||||
|
||||
|
||||
@endpoint_restriction_route.post(
|
||||
path="/endpoint/bind/list", summary="List extra restriction to endpoints list"
|
||||
)
|
||||
def endpoint_restriction_list(request: Request):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return
|
||||
|
||||
|
||||
@endpoint_restriction_route.patch(
|
||||
path="/endpoint/bind/patch", summary="Patch extra restriction to endpoints list"
|
||||
)
|
||||
def endpoint_restriction_patch(request: Request):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
from fastapi.routing import APIRouter
|
||||
from fastapi.requests import Request
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertUsers, UpdateUsers, PatchRecord, ListOptions
|
||||
)
|
||||
|
||||
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
||||
|
||||
|
||||
user_route = APIRouter(prefix="/user", tags=["User"])
|
||||
user_route.include_router(user_route, include_in_schema=True)
|
||||
|
||||
|
||||
@user_route.post(path="/list", summary="List Active/Delete/Confirm Users")
|
||||
def user_list(request: Request, list_options: ListOptions):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
||||
|
||||
|
||||
@user_route.post(path="/create", summary="Create User with given auth levels")
|
||||
def user_create(request: Request, data: InsertUsers):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@user_route.post(
|
||||
path="/update/{user_uu_id}", summary="Update User with given auth levels"
|
||||
)
|
||||
def user_update(request: Request, user_uu_id: str, data: UpdateUsers):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, user_uu_id=user_uu_id, token_dict=token_dict
|
||||
)
|
||||
|
||||
|
||||
@user_route.patch(path="/patch/{user_uu_id}", summary="Update Active/Delete/Confirm")
|
||||
def user_patch(request: Request, user_uu_id: str, data: PatchRecord):
|
||||
token_dict = parse_token_object_to_dict(request=request)
|
||||
return token_dict.available_event(
|
||||
data=data, user_uu_id=user_uu_id, token_dict=token_dict
|
||||
)
|
||||
Loading…
Reference in New Issue