test application updated@build living space
This commit is contained in:
parent
d2cc195ccf
commit
7e1b26f3c4
|
|
@ -35,17 +35,13 @@ class AccountRecordsListEventMethods(MethodToEvent):
|
||||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||||
AccountRecords.company_id
|
AccountRecords.company_id
|
||||||
== token_dict.selected_occupant.responsible_company_id,
|
== token_dict.selected_occupant.responsible_company_id,
|
||||||
*AccountRecords.valid_record_args(AccountRecords),
|
|
||||||
)
|
)
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif isinstance(token_dict, EmployeeTokenObject):
|
||||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||||
AccountRecords.company_id == token_dict.selected_company.company_id,
|
AccountRecords.company_id == token_dict.selected_company.company_id,
|
||||||
*AccountRecords.valid_record_args(AccountRecords),
|
|
||||||
)
|
)
|
||||||
records = AccountRecords.filter_all(
|
AccountRecords.filter_attr = list_options
|
||||||
*AccountRecords.smart_query(list_options.query),
|
records = AccountRecords.filter_all()
|
||||||
*AccountRecords.valid_record_args(AccountRecords),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True, message="Update Build record", result=records
|
completed=True, message="Update Build record", result=records
|
||||||
)
|
)
|
||||||
|
|
@ -90,7 +86,6 @@ class AccountRecordsCreateEventMethods(MethodToEvent):
|
||||||
# employee_id=token_dict.selected_employee.employee_id,
|
# employee_id=token_dict.selected_employee.employee_id,
|
||||||
# )
|
# )
|
||||||
# build_ids_list = Build.filter_all(
|
# build_ids_list = Build.filter_all(
|
||||||
# *Build.valid_record_args(Build),
|
|
||||||
# )
|
# )
|
||||||
# build_iban = BuildIbans.filter_one(
|
# build_iban = BuildIbans.filter_one(
|
||||||
# BuildIbans.iban == data.iban,
|
# BuildIbans.iban == data.iban,
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,6 @@ class AddressListEventMethods(MethodToEvent):
|
||||||
street_id[0]
|
street_id[0]
|
||||||
for street_id in AddressPostcode.select_only(
|
for street_id in AddressPostcode.select_only(
|
||||||
AddressPostcode.id.in_(post_code_id_list),
|
AddressPostcode.id.in_(post_code_id_list),
|
||||||
*AddressPostcode.valid_record_args(AddressPostcode),
|
|
||||||
select_args=[AddressPostcode.street_id],
|
select_args=[AddressPostcode.street_id],
|
||||||
order_by=AddressPostcode.street_id.desc(),
|
order_by=AddressPostcode.street_id.desc(),
|
||||||
).data
|
).data
|
||||||
|
|
@ -65,11 +64,9 @@ class AddressListEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
Addresses.pre_query = Addresses.filter_all(
|
Addresses.pre_query = Addresses.filter_all(
|
||||||
Addresses.street_id.in_(get_street_ids),
|
Addresses.street_id.in_(get_street_ids),
|
||||||
*Addresses.valid_record_args(Addresses),
|
|
||||||
).query
|
).query
|
||||||
Addresses.filter_attr = list_options
|
Addresses.filter_attr = list_options
|
||||||
records = Addresses.filter_all(
|
records = Addresses.filter_all(
|
||||||
*Addresses.valid_record_args(Addresses),
|
|
||||||
).data
|
).data
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
|
|
@ -109,7 +106,6 @@ class AddressCreateEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
post_code = AddressPostcode.filter_one(
|
post_code = AddressPostcode.filter_one(
|
||||||
AddressPostcode.uu_id == data.post_code_uu_id,
|
AddressPostcode.uu_id == data.post_code_uu_id,
|
||||||
*AddressPostcode.valid_record_args(AddressPostcode),
|
|
||||||
).data
|
).data
|
||||||
if not post_code:
|
if not post_code:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -122,16 +118,9 @@ class AddressCreateEventMethods(MethodToEvent):
|
||||||
data_dict["street_uu_id"] = str(post_code.street_uu_id)
|
data_dict["street_uu_id"] = str(post_code.street_uu_id)
|
||||||
del data_dict["post_code_uu_id"]
|
del data_dict["post_code_uu_id"]
|
||||||
address = Addresses.find_or_create(**data_dict)
|
address = Addresses.find_or_create(**data_dict)
|
||||||
relation_employee = RelationshipEmployee2PostCode.find_or_create(
|
|
||||||
employee_id=token_dict.selected_company.employee_id,
|
|
||||||
member_id=post_code.id,
|
|
||||||
company_id=token_dict.selected_company.company_id,
|
|
||||||
)
|
|
||||||
address.save()
|
address.save()
|
||||||
address.update(is_confirmed=True)
|
address.update(is_confirmed=True)
|
||||||
address.save()
|
address.save()
|
||||||
relation_employee.update(is_confirmed=True)
|
|
||||||
relation_employee.save()
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={
|
content={
|
||||||
"completed": True,
|
"completed": True,
|
||||||
|
|
@ -231,7 +220,6 @@ class AddressUpdateEventMethods(MethodToEvent):
|
||||||
if isinstance(token_dict, EmployeeTokenObject):
|
if isinstance(token_dict, EmployeeTokenObject):
|
||||||
address = Addresses.filter_one(
|
address = Addresses.filter_one(
|
||||||
Addresses.uu_id == address_uu_id,
|
Addresses.uu_id == address_uu_id,
|
||||||
*Addresses.valid_record_args(Addresses),
|
|
||||||
).data
|
).data
|
||||||
if not address:
|
if not address:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -273,13 +261,9 @@ class AddressPatchEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
address = Addresses.filter_one(
|
address = Addresses.filter_one(
|
||||||
Addresses.uu_id == address_uu_id,
|
Addresses.uu_id == address_uu_id,
|
||||||
*Addresses.valid_record_args(Addresses),
|
|
||||||
).data
|
).data
|
||||||
post_code = RelationshipEmployee2PostCode.filter_one(
|
post_code = RelationshipEmployee2PostCode.filter_one(
|
||||||
RelationshipEmployee2PostCode.member_id == address.post_code_id,
|
RelationshipEmployee2PostCode.member_id == address.post_code_id,
|
||||||
*RelationshipEmployee2PostCode.valid_record_args(
|
|
||||||
RelationshipEmployee2PostCode
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
if not post_code:
|
if not post_code:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -318,7 +302,6 @@ class AddressPostCodeCreateEventMethods(MethodToEvent):
|
||||||
data_dump = data.excluded_dump()
|
data_dump = data.excluded_dump()
|
||||||
street = AddressStreet.filter_one(
|
street = AddressStreet.filter_one(
|
||||||
AddressStreet.uu_id == data.street_uu_id,
|
AddressStreet.uu_id == data.street_uu_id,
|
||||||
*AddressStreet.valid_record_args(AddressStreet),
|
|
||||||
).data
|
).data
|
||||||
if not street:
|
if not street:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -370,7 +353,6 @@ class AddressPostCodeUpdateEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
post_code = AddressPostcode.filter_one(
|
post_code = AddressPostcode.filter_one(
|
||||||
AddressPostcode.uu_id == post_code_uu_id,
|
AddressPostcode.uu_id == post_code_uu_id,
|
||||||
*AddressPostcode.valid_record_args(AddressPostcode),
|
|
||||||
).data
|
).data
|
||||||
if not post_code:
|
if not post_code:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -420,7 +402,6 @@ class AddressPostCodeListEventMethods(MethodToEvent):
|
||||||
post_code_list = AddressPostcode.__many__table__.filter_all(
|
post_code_list = AddressPostcode.__many__table__.filter_all(
|
||||||
AddressPostcode.__many__table__.company_id
|
AddressPostcode.__many__table__.company_id
|
||||||
== token_dict.selected_company.company_id,
|
== token_dict.selected_company.company_id,
|
||||||
*AddressPostcode.valid_record_args(AddressPostcode.__many__table__),
|
|
||||||
).data
|
).data
|
||||||
if not post_code_list:
|
if not post_code_list:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -432,12 +413,9 @@ class AddressPostCodeListEventMethods(MethodToEvent):
|
||||||
AddressPostcode.id.in_(
|
AddressPostcode.id.in_(
|
||||||
[post_code.member_id for post_code in post_code_list]
|
[post_code.member_id for post_code in post_code_list]
|
||||||
),
|
),
|
||||||
*AddressPostcode.valid_record_args(AddressPostcode),
|
|
||||||
).query
|
).query
|
||||||
AddressPostcode.filter_attr = list_options
|
AddressPostcode.filter_attr = list_options
|
||||||
records = AddressPostcode.filter_all(
|
records = AddressPostcode.filter_all().data
|
||||||
*AddressPostcode.valid_record_args(AddressPostcode),
|
|
||||||
).data
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="List Address records",
|
message="List Address records",
|
||||||
|
|
|
||||||
|
|
@ -116,13 +116,11 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
if selected_company := Companies.filter_one(
|
if selected_company := Companies.filter_one(
|
||||||
Companies.uu_id == data.company_uu_id,
|
Companies.uu_id == data.company_uu_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
).data:
|
).data:
|
||||||
department_ids = [
|
department_ids = [
|
||||||
department.id
|
department.id
|
||||||
for department in Departments.filter_all(
|
for department in Departments.filter_all(
|
||||||
Departments.company_id == selected_company.id,
|
Departments.company_id == selected_company.id,
|
||||||
*Departments.valid_record_args(Departments),
|
|
||||||
).data
|
).data
|
||||||
]
|
]
|
||||||
duties_ids = [
|
duties_ids = [
|
||||||
|
|
@ -130,41 +128,37 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||||
for duties in Duties.filter_all(
|
for duties in Duties.filter_all(
|
||||||
Duties.company_id == selected_company.id,
|
Duties.company_id == selected_company.id,
|
||||||
Duties.department_id.in_(department_ids),
|
Duties.department_id.in_(department_ids),
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
).data
|
).data
|
||||||
]
|
]
|
||||||
staff_ids = [
|
staff_ids = [
|
||||||
staff.id
|
staff.id
|
||||||
for staff in Staff.filter_all(
|
for staff in Staff.filter_all(
|
||||||
Staff.duties_id.in_(duties_ids), *Staff.valid_record_args(Staff)
|
Staff.duties_id.in_(duties_ids),
|
||||||
).data
|
).data
|
||||||
]
|
]
|
||||||
employee = Employees.filter_one(
|
employee = Employees.filter_one(
|
||||||
Employees.people_id == token_user.person_id,
|
Employees.people_id == token_user.person_id,
|
||||||
Employees.staff_id.in_(staff_ids),
|
Employees.staff_id.in_(staff_ids),
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
|
|
||||||
reachable_event_list_id, reachable_event_list_uu_id = (
|
reachable_event_list_id, reachable_event_list_uu_id = (
|
||||||
Event2Employee.get_event_id_by_employee_id(employee_id=employee.id)
|
Event2Employee.get_event_id_by_employee_id(employee_id=employee.id)
|
||||||
)
|
)
|
||||||
staff = Staff.filter_one(
|
staff = Staff.filter_one(
|
||||||
Staff.id == employee.staff_id, *Staff.valid_record_args(Staff)
|
Staff.id == employee.staff_id,
|
||||||
).data
|
).data
|
||||||
duties = Duties.filter_one(
|
duties = Duties.filter_one(
|
||||||
Duties.id == staff.duties_id, *Duties.valid_record_args(Duties)
|
Duties.id == staff.duties_id,
|
||||||
).data
|
).data
|
||||||
department = Departments.filter_one(
|
department = Departments.filter_one(
|
||||||
Departments.id == duties.department_id,
|
Departments.id == duties.department_id,
|
||||||
*Departments.valid_record_args(Departments),
|
|
||||||
).data
|
).data
|
||||||
bulk_id = Duty.filter_one(
|
bulk_id = Duty.filter_one(
|
||||||
Duty.duty_code == "BULK", *Duty.valid_record_args(Duty)
|
Duty.duty_code == "BULK",
|
||||||
).data
|
).data
|
||||||
bulk_duty_id = Duties.filter_one(
|
bulk_duty_id = Duties.filter_one(
|
||||||
Duties.company_id == selected_company.id,
|
Duties.company_id == selected_company.id,
|
||||||
Duties.duties_id == bulk_id.id,
|
Duties.duties_id == bulk_id.id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
).data
|
).data
|
||||||
update_selected_to_redis(
|
update_selected_to_redis(
|
||||||
request=request,
|
request=request,
|
||||||
|
|
@ -202,7 +196,6 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
build_part = BuildParts.filter_one(
|
build_part = BuildParts.filter_one(
|
||||||
BuildParts.uu_id == data.build_part_uu_id,
|
BuildParts.uu_id == data.build_part_uu_id,
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
).data
|
).data
|
||||||
if not build_part:
|
if not build_part:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -210,27 +203,22 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||||
detail="Build Part is not found",
|
detail="Build Part is not found",
|
||||||
)
|
)
|
||||||
build = Build.filter_one(
|
build = Build.filter_one(
|
||||||
Build.id == build_part.build_id, *Build.valid_record_args(Build)
|
Build.id == build_part.build_id
|
||||||
).data
|
).data
|
||||||
related_company = RelationshipEmployee2Build.filter_one(
|
related_company = RelationshipEmployee2Build.filter_one(
|
||||||
RelationshipEmployee2Build.member_id == build.id,
|
RelationshipEmployee2Build.member_id == build.id,
|
||||||
*RelationshipEmployee2Build.valid_record_args(
|
|
||||||
RelationshipEmployee2Build
|
|
||||||
),
|
|
||||||
).data
|
).data
|
||||||
company_related = Companies.filter_one(
|
company_related = Companies.filter_one(
|
||||||
Companies.id == related_company.company_id,
|
Companies.id == related_company.company_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
).data
|
).data
|
||||||
responsible_employee = Employees.filter_one(
|
responsible_employee = Employees.filter_one(
|
||||||
Employees.id == related_company.employee_id,
|
Employees.id == related_company.employee_id,
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
if selected_occupant_type := BuildLivingSpace.filter_one(
|
if selected_occupant_type := BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.occupant_type == occupant_type.id,
|
BuildLivingSpace.occupant_type == occupant_type.id,
|
||||||
BuildLivingSpace.person_id == token_user.person_id,
|
BuildLivingSpace.person_id == token_user.person_id,
|
||||||
BuildLivingSpace.build_parts_id == build_part.id,
|
BuildLivingSpace.build_parts_id == build_part.id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data:
|
).data:
|
||||||
reachable_event_list_id, reachable_event_list_uu_id = (
|
reachable_event_list_id, reachable_event_list_uu_id = (
|
||||||
Event2Occupant.get_event_id_by_build_living_space_id(
|
Event2Occupant.get_event_id_by_build_living_space_id(
|
||||||
|
|
@ -317,7 +305,6 @@ class AuthenticationRefreshEventMethods(MethodToEvent):
|
||||||
UsersTokens.domain == found_user.domain_name,
|
UsersTokens.domain == found_user.domain_name,
|
||||||
UsersTokens.user_id == found_user.id,
|
UsersTokens.user_id == found_user.id,
|
||||||
UsersTokens.token_type == "RememberMe",
|
UsersTokens.token_type == "RememberMe",
|
||||||
*UsersTokens.valid_record_args(UsersTokens),
|
|
||||||
).data
|
).data
|
||||||
access_dict = {
|
access_dict = {
|
||||||
"access_token": access_token,
|
"access_token": access_token,
|
||||||
|
|
@ -354,7 +341,7 @@ class AuthenticationChangePasswordEventMethods(MethodToEvent):
|
||||||
token_user = get_object_via_access_key(request=request)
|
token_user = get_object_via_access_key(request=request)
|
||||||
if token_user.user_type == 1:
|
if token_user.user_type == 1:
|
||||||
if found_user := Users.filter_one(
|
if found_user := Users.filter_one(
|
||||||
Users.uu_id == token_user.uu_id, *Users.valid_record_args(Users)
|
Users.uu_id == token_user.uu_id
|
||||||
).data:
|
).data:
|
||||||
if found_user.check_password(data.old_password):
|
if found_user.check_password(data.old_password):
|
||||||
found_user.set_password(data.new_password)
|
found_user.set_password(data.new_password)
|
||||||
|
|
@ -395,7 +382,7 @@ class AuthenticationCreatePasswordEventMethods(MethodToEvent):
|
||||||
status_code=status.HTTP_406_NOT_ACCEPTABLE, detail="Password must match"
|
status_code=status.HTTP_406_NOT_ACCEPTABLE, detail="Password must match"
|
||||||
)
|
)
|
||||||
if found_user := Users.filter_one(
|
if found_user := Users.filter_one(
|
||||||
Users.password_token == data.password_token, *Users.valid_record_args(Users)
|
Users.password_token == data.password_token
|
||||||
).data:
|
).data:
|
||||||
found_user.create_password(password=data.password)
|
found_user.create_password(password=data.password)
|
||||||
found_user.password_token = None
|
found_user.password_token = None
|
||||||
|
|
@ -441,7 +428,7 @@ class AuthenticationDisconnectUserEventMethods(MethodToEvent):
|
||||||
|
|
||||||
if token_user := get_object_via_access_key(request=request):
|
if token_user := get_object_via_access_key(request=request):
|
||||||
found_user = Users.filter_one(
|
found_user = Users.filter_one(
|
||||||
Users.uu_id == token_user.get("uu_id"), *Users.valid_record_args(Users)
|
Users.uu_id == token_user.get("uu_id")
|
||||||
).data
|
).data
|
||||||
if not found_user:
|
if not found_user:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
@ -458,7 +445,6 @@ class AuthenticationDisconnectUserEventMethods(MethodToEvent):
|
||||||
redis_cli.delete(key)
|
redis_cli.delete(key)
|
||||||
selected_user = Users.filter_one(
|
selected_user = Users.filter_one(
|
||||||
Users.uu_id == token_user.get("uu_id"),
|
Users.uu_id == token_user.get("uu_id"),
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data
|
).data
|
||||||
selected_user.remove_refresher_token(
|
selected_user.remove_refresher_token(
|
||||||
domain=data.domain, disconnect=True
|
domain=data.domain, disconnect=True
|
||||||
|
|
@ -510,7 +496,6 @@ class AuthenticationLogoutEventMethods(MethodToEvent):
|
||||||
redis_cli.delete(key)
|
redis_cli.delete(key)
|
||||||
selected_user = Users.filter_one(
|
selected_user = Users.filter_one(
|
||||||
Users.uu_id == token_user.get("uu_id"),
|
Users.uu_id == token_user.get("uu_id"),
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data
|
).data
|
||||||
selected_user.remove_refresher_token(domain=data.domain)
|
selected_user.remove_refresher_token(domain=data.domain)
|
||||||
# UserLogger.log_error(
|
# UserLogger.log_error(
|
||||||
|
|
@ -568,7 +553,7 @@ class AuthenticationRefreshTokenEventMethods(MethodToEvent):
|
||||||
status_code=status.HTTP_202_ACCEPTED,
|
status_code=status.HTTP_202_ACCEPTED,
|
||||||
)
|
)
|
||||||
if found_user := Users.filter_one(
|
if found_user := Users.filter_one(
|
||||||
Users.id == token_refresher.user_id, *Users.valid_record_args(Users)
|
Users.id == token_refresher.user_id,
|
||||||
).data:
|
).data:
|
||||||
found_user: Users = found_user
|
found_user: Users = found_user
|
||||||
access_key = save_access_token_to_redis(
|
access_key = save_access_token_to_redis(
|
||||||
|
|
|
||||||
|
|
@ -117,45 +117,37 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
if selected_company := Companies.filter_one(
|
if selected_company := Companies.filter_one(
|
||||||
Companies.uu_id == data.company_uu_id,
|
Companies.uu_id == data.company_uu_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
).data:
|
).data:
|
||||||
department_ids = [
|
department_ids = [
|
||||||
department.id
|
department.id
|
||||||
for department in Departments.filter_all(
|
for department in Departments.filter_all(
|
||||||
Departments.company_id == selected_company.id,
|
Departments.company_id == selected_company.id,
|
||||||
*Departments.valid_record_args(Departments),
|
|
||||||
).data
|
).data
|
||||||
]
|
]
|
||||||
duties_ids = [
|
duties_ids = [
|
||||||
duties.id
|
duties.id
|
||||||
for duties in Duties.filter_all(
|
for duties in Duties.filter_all(
|
||||||
Duties.company_id == selected_company.id,
|
Duties.company_id == selected_company.id,
|
||||||
Duties.department_id.in_(department_ids),
|
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
).data
|
).data
|
||||||
]
|
]
|
||||||
staff_ids = [
|
staff_ids = [
|
||||||
staff.id
|
staff.id
|
||||||
for staff in Staff.filter_all(
|
for staff in Staff.filter_all(
|
||||||
Staff.duties_id.in_(duties_ids),
|
Staff.duties_id.in_(duties_ids),
|
||||||
*Staff.valid_record_args(Staff),
|
|
||||||
).data
|
).data
|
||||||
]
|
]
|
||||||
employee = Employees.filter_one(
|
employee = Employees.filter_one(
|
||||||
Employees.people_id == token_dict.person_id,
|
Employees.people_id == token_dict.person_id,
|
||||||
Employees.staff_id.in_(staff_ids),
|
Employees.staff_id.in_(staff_ids),
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
reachable_event_list_id, reachable_event_list_uu_id = (
|
reachable_event_list_id, reachable_event_list_uu_id = (
|
||||||
Event2Employee.get_event_id_by_employee_id(employee_id=employee.id)
|
Event2Employee.get_event_id_by_employee_id(employee_id=employee.id)
|
||||||
)
|
)
|
||||||
staff = Staff.filter_one(
|
staff = Staff.filter_one(
|
||||||
Staff.id == employee.staff_id,
|
Staff.id == employee.staff_id,
|
||||||
*Staff.valid_record_args(Staff),
|
|
||||||
).data
|
).data
|
||||||
duties = Duties.filter_one(
|
duties = Duties.filter_one(
|
||||||
Duties.id == staff.duties_id,
|
Duties.id == staff.duties_id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
).data
|
).data
|
||||||
department = Departments.filter_one(
|
department = Departments.filter_one(
|
||||||
Departments.id == duties.department_id,
|
Departments.id == duties.department_id,
|
||||||
|
|
@ -212,27 +204,20 @@ class AuthenticationSelectEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
build = Build.filter_one(
|
build = Build.filter_one(
|
||||||
Build.id == build_part.build_id,
|
Build.id == build_part.build_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).data
|
).data
|
||||||
related_company = RelationshipEmployee2Build.filter_one(
|
related_company = RelationshipEmployee2Build.filter_one(
|
||||||
RelationshipEmployee2Build.member_id == build.id,
|
RelationshipEmployee2Build.member_id == build.id,
|
||||||
*RelationshipEmployee2Build.valid_record_args(
|
|
||||||
RelationshipEmployee2Build
|
|
||||||
),
|
|
||||||
).data
|
).data
|
||||||
company_related = Companies.filter_one(
|
company_related = Companies.filter_one(
|
||||||
Companies.id == related_company.company_id,
|
Companies.id == related_company.company_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
).data
|
).data
|
||||||
responsible_employee = Employees.filter_one(
|
responsible_employee = Employees.filter_one(
|
||||||
Employees.id == related_company.employee_id,
|
Employees.id == related_company.employee_id,
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
if selected_occupant_type := BuildLivingSpace.filter_one(
|
if selected_occupant_type := BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.occupant_type == occupant_type.id,
|
BuildLivingSpace.occupant_type == occupant_type.id,
|
||||||
BuildLivingSpace.person_id == token_dict.person_id,
|
BuildLivingSpace.person_id == token_dict.person_id,
|
||||||
BuildLivingSpace.build_parts_id == build_part.id,
|
BuildLivingSpace.build_parts_id == build_part.id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data:
|
).data:
|
||||||
reachable_event_list_id, reachable_event_list_uu_id = (
|
reachable_event_list_id, reachable_event_list_uu_id = (
|
||||||
Event2Occupant.get_event_id_by_build_living_space_id(
|
Event2Occupant.get_event_id_by_build_living_space_id(
|
||||||
|
|
@ -311,13 +296,11 @@ class AuthenticationRefreshEventMethods(MethodToEvent):
|
||||||
if token_user := get_object_via_access_key(request=request):
|
if token_user := get_object_via_access_key(request=request):
|
||||||
if found_user := Users.filter_one(
|
if found_user := Users.filter_one(
|
||||||
Users.uu_id == token_user.get("uu_id"),
|
Users.uu_id == token_user.get("uu_id"),
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data:
|
).data:
|
||||||
user_token = UsersTokens.filter_one(
|
user_token = UsersTokens.filter_one(
|
||||||
UsersTokens.domain == found_user.domain_name,
|
UsersTokens.domain == found_user.domain_name,
|
||||||
UsersTokens.user_id == found_user.id,
|
UsersTokens.user_id == found_user.id,
|
||||||
UsersTokens.token_type == "RememberMe",
|
UsersTokens.token_type == "RememberMe",
|
||||||
*UsersTokens.valid_record_args(UsersTokens),
|
|
||||||
).data
|
).data
|
||||||
access_dict = {
|
access_dict = {
|
||||||
"access_token": access_token,
|
"access_token": access_token,
|
||||||
|
|
@ -353,7 +336,6 @@ class AuthenticationChangePasswordEventMethods(MethodToEvent):
|
||||||
if token_dict.user_type == 1:
|
if token_dict.user_type == 1:
|
||||||
if found_user := Users.filter_one(
|
if found_user := Users.filter_one(
|
||||||
Users.uu_id == token_dict.person_uu_id,
|
Users.uu_id == token_dict.person_uu_id,
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data:
|
).data:
|
||||||
if found_user.check_password(data.old_password):
|
if found_user.check_password(data.old_password):
|
||||||
found_user.set_password(data.new_password)
|
found_user.set_password(data.new_password)
|
||||||
|
|
@ -395,7 +377,6 @@ class AuthenticationCreatePasswordEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
found_user = Users.filter_one(
|
found_user = Users.filter_one(
|
||||||
Users.password_token == data.password_token,
|
Users.password_token == data.password_token,
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data
|
).data
|
||||||
if not found_user:
|
if not found_user:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
@ -442,7 +423,6 @@ class AuthenticationDisconnectUserEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
found_user = Users.filter_one(
|
found_user = Users.filter_one(
|
||||||
Users.uu_id == token_dict.person_uu_id,
|
Users.uu_id == token_dict.person_uu_id,
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data
|
).data
|
||||||
if not found_user:
|
if not found_user:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
|
||||||
|
|
@ -41,16 +41,13 @@ class BuildListEventMethods(MethodToEvent):
|
||||||
if isinstance(token_dict, OccupantTokenObject):
|
if isinstance(token_dict, OccupantTokenObject):
|
||||||
Build.pre_query = Build.filter_all(
|
Build.pre_query = Build.filter_all(
|
||||||
Build.id == token_dict.selected_occupant.build_id,
|
Build.id == token_dict.selected_occupant.build_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).query
|
).query
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif isinstance(token_dict, EmployeeTokenObject):
|
||||||
Build.pre_query = Build.select_action(
|
Build.pre_query = Build.select_action(
|
||||||
employee_id=token_dict.selected_company.employee_id
|
employee_id=token_dict.selected_company.employee_id
|
||||||
)
|
)
|
||||||
Build.filter_attr = list_options
|
Build.filter_attr = list_options
|
||||||
records = Build.filter_all(
|
records = Build.filter_all()
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="Building Records are listed",
|
message="Building Records are listed",
|
||||||
|
|
@ -187,7 +184,6 @@ class BuildUpdateEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
if Build.filter_all(
|
if Build.filter_all(
|
||||||
Build.person_id == token_dict.person_id,
|
Build.person_id == token_dict.person_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).data:
|
).data:
|
||||||
Build.pre_query = None
|
Build.pre_query = None
|
||||||
updated_build = Build.update_action(
|
updated_build = Build.update_action(
|
||||||
|
|
@ -219,7 +215,6 @@ class BuildPatchEventMethods(MethodToEvent):
|
||||||
def build_patch(cls, build_uu_id: str, data: PatchRecord, token_dict):
|
def build_patch(cls, build_uu_id: str, data: PatchRecord, token_dict):
|
||||||
find_one_build = Build.filter_one(
|
find_one_build = Build.filter_one(
|
||||||
Build.uu_id==build_uu_id,
|
Build.uu_id==build_uu_id,
|
||||||
*Build.valid_record_args(Build)
|
|
||||||
)
|
)
|
||||||
access_authorized_build = Build.select_action(
|
access_authorized_build = Build.select_action(
|
||||||
employee_id=token_dict.selected_company.employee_id,
|
employee_id=token_dict.selected_company.employee_id,
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,9 @@ class BuildAreaListEventMethods(MethodToEvent):
|
||||||
if isinstance(token_dict, OccupantTokenObject):
|
if isinstance(token_dict, OccupantTokenObject):
|
||||||
build_ids = Build.filter_all(
|
build_ids = Build.filter_all(
|
||||||
Build.id == token_dict.selected_occupant.build_id,
|
Build.id == token_dict.selected_occupant.build_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).data
|
).data
|
||||||
BuildArea.pre_query = BuildArea.filter_all(
|
BuildArea.pre_query = BuildArea.filter_all(
|
||||||
BuildArea.build_id.in_([build.id for build in build_ids]),
|
BuildArea.build_id.in_([build.id for build in build_ids]),
|
||||||
*BuildArea.valid_record_args(BuildArea),
|
|
||||||
).query
|
).query
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif isinstance(token_dict, EmployeeTokenObject):
|
||||||
build_ids = Build.select_action(
|
build_ids = Build.select_action(
|
||||||
|
|
@ -44,12 +42,9 @@ class BuildAreaListEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
BuildArea.pre_query = BuildArea.filter_all(
|
BuildArea.pre_query = BuildArea.filter_all(
|
||||||
BuildArea.build_id.in_([build.id for build in build_ids]),
|
BuildArea.build_id.in_([build.id for build in build_ids]),
|
||||||
*BuildArea.valid_record_args(BuildArea),
|
|
||||||
).query
|
).query
|
||||||
BuildArea.filter_attr = list_options
|
BuildArea.filter_attr = list_options
|
||||||
records = BuildArea.filter_all(
|
records = BuildArea.filter_all()
|
||||||
*BuildArea.valid_record_args(BuildArea),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True, message="List of Build Area", result=records
|
completed=True, message="List of Build Area", result=records
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,7 @@ class BuildingBuildPartsListEventMethods(MethodToEvent):
|
||||||
BuildParts.build_id.in_(build_list_ids),
|
BuildParts.build_id.in_(build_list_ids),
|
||||||
).query
|
).query
|
||||||
BuildParts.filter_attr = list_options
|
BuildParts.filter_attr = list_options
|
||||||
records = BuildParts.filter_all(
|
records = BuildParts.filter_all()
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="Building Parts Records are listed",
|
message="Building Parts Records are listed",
|
||||||
|
|
@ -111,7 +109,6 @@ class BuildingBuildPartsPatchEventMethods(MethodToEvent):
|
||||||
def building_build_parts_patch(cls, data, token_dict):
|
def building_build_parts_patch(cls, data, token_dict):
|
||||||
find_one_build = BuildParts.filter_one(
|
find_one_build = BuildParts.filter_one(
|
||||||
BuildParts.uu_id == data.uu_id,
|
BuildParts.uu_id == data.uu_id,
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
).data
|
).data
|
||||||
access_authorized_build = BuildParts.select_action(
|
access_authorized_build = BuildParts.select_action(
|
||||||
duty_id=token_dict.selected_company.duty_id,
|
duty_id=token_dict.selected_company.duty_id,
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,9 @@ class BuildSitesListEventMethods(MethodToEvent):
|
||||||
if isinstance(token_dict, OccupantTokenObject):
|
if isinstance(token_dict, OccupantTokenObject):
|
||||||
occupants_build = Build.filter_one(
|
occupants_build = Build.filter_one(
|
||||||
Build.id == token_dict.selected_occupant.build_id,
|
Build.id == token_dict.selected_occupant.build_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).data
|
).data
|
||||||
BuildSites.pre_query = BuildSites.filter_all(
|
BuildSites.pre_query = BuildSites.filter_all(
|
||||||
BuildSites.address_id == occupants_build.address_id,
|
BuildSites.address_id == occupants_build.address_id,
|
||||||
*BuildSites.valid_record_args(BuildSites),
|
|
||||||
).query
|
).query
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif isinstance(token_dict, EmployeeTokenObject):
|
||||||
employees_build = Build.select_action(
|
employees_build = Build.select_action(
|
||||||
|
|
@ -53,12 +51,9 @@ class BuildSitesListEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
BuildSites.pre_query = BuildSites.filter_all(
|
BuildSites.pre_query = BuildSites.filter_all(
|
||||||
BuildSites.address_id.in_(employees_build_list)
|
BuildSites.address_id.in_(employees_build_list)
|
||||||
*BuildSites.valid_record_args(BuildSites),
|
|
||||||
).query
|
).query
|
||||||
BuildSites.filter_attr = list_options
|
BuildSites.filter_attr = list_options
|
||||||
records = BuildSites.filter_all(
|
records = BuildSites.filter_all()
|
||||||
*BuildSites.valid_record_args(BuildSites),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True, message="Update Build record", result=records
|
completed=True, message="Update Build record", result=records
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,7 @@ class BuildTypesListEventMethods(MethodToEvent):
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
if isinstance(token_dict, EmployeeTokenObject):
|
if isinstance(token_dict, EmployeeTokenObject):
|
||||||
BuildTypes.filter_attr = list_options
|
BuildTypes.filter_attr = list_options
|
||||||
results = BuildTypes.filter_all(
|
results = BuildTypes.filter_all()
|
||||||
*BuildTypes.valid_record_args(BuildTypes)
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
result=results,
|
result=results,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ class BuildingLivingSpacesPartsListEventMethods(MethodToEvent):
|
||||||
if isinstance(token_dict, OccupantTokenObject):
|
if isinstance(token_dict, OccupantTokenObject):
|
||||||
occupants_build_id = Build.filter_one(
|
occupants_build_id = Build.filter_one(
|
||||||
Build.id == token_dict.selected_occupant.build_id,
|
Build.id == token_dict.selected_occupant.build_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).data
|
).data
|
||||||
if not occupants_build_id:
|
if not occupants_build_id:
|
||||||
Build.raise_http_exception(
|
Build.raise_http_exception(
|
||||||
|
|
@ -47,7 +46,6 @@ class BuildingLivingSpacesPartsListEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
occupants_build_parts = BuildParts.filter_all(
|
occupants_build_parts = BuildParts.filter_all(
|
||||||
BuildParts.build_id.in_(occupants_build_id.id),
|
BuildParts.build_id.in_(occupants_build_id.id),
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
).data
|
).data
|
||||||
if not occupants_build_parts:
|
if not occupants_build_parts:
|
||||||
Build.raise_http_exception(
|
Build.raise_http_exception(
|
||||||
|
|
@ -60,12 +58,9 @@ class BuildingLivingSpacesPartsListEventMethods(MethodToEvent):
|
||||||
BuildLivingSpace.build_parts_id.in_(
|
BuildLivingSpace.build_parts_id.in_(
|
||||||
[build_part.id for build_part in occupants_build_parts]
|
[build_part.id for build_part in occupants_build_parts]
|
||||||
),
|
),
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).query
|
).query
|
||||||
BuildLivingSpace.filter_attr = list_options
|
BuildLivingSpace.filter_attr = list_options
|
||||||
records = BuildLivingSpace.filter_all(
|
records = BuildLivingSpace.filter_all()
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
)
|
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif isinstance(token_dict, EmployeeTokenObject):
|
||||||
build_id_list_query = Build.select_action(
|
build_id_list_query = Build.select_action(
|
||||||
employee_id=token_dict.selected_company.employee_id
|
employee_id=token_dict.selected_company.employee_id
|
||||||
|
|
@ -81,7 +76,6 @@ class BuildingLivingSpacesPartsListEventMethods(MethodToEvent):
|
||||||
BuildParts.build_id.in_(
|
BuildParts.build_id.in_(
|
||||||
[build.id for build in build_id_list_query.all()]
|
[build.id for build in build_id_list_query.all()]
|
||||||
),
|
),
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data
|
).data
|
||||||
if not build_part_id_list_query:
|
if not build_part_id_list_query:
|
||||||
Build.raise_http_exception(
|
Build.raise_http_exception(
|
||||||
|
|
@ -94,12 +88,9 @@ class BuildingLivingSpacesPartsListEventMethods(MethodToEvent):
|
||||||
BuildLivingSpace.build_parts_id.in_(
|
BuildLivingSpace.build_parts_id.in_(
|
||||||
[build_part.id for build_part in build_part_id_list_query]
|
[build_part.id for build_part in build_part_id_list_query]
|
||||||
),
|
),
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).query
|
).query
|
||||||
BuildLivingSpace.filter_attr = list_options
|
BuildLivingSpace.filter_attr = list_options
|
||||||
records = BuildLivingSpace.filter_all(
|
records = BuildLivingSpace.filter_all()
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="Building Living Spaces are listed successfully",
|
message="Building Living Spaces are listed successfully",
|
||||||
|
|
@ -122,14 +113,13 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
from api_library.date_time_actions.date_functions import system_arrow
|
from api_library.date_time_actions.date_functions import system_arrow
|
||||||
|
|
||||||
data_dict = data.dump()
|
data_dict = data.excluded_dump()
|
||||||
build_id_list_query = Build.select_action(
|
build_id_list_query = Build.select_action(
|
||||||
employee_id=token_dict.selected_company.employee_id
|
employee_id=token_dict.selected_company.employee_id
|
||||||
)
|
)
|
||||||
build_part = BuildParts.filter_one(
|
build_part = BuildParts.filter_one(
|
||||||
BuildParts.uu_id == data.build_parts_uu_id,
|
BuildParts.uu_id == data.build_parts_uu_id,
|
||||||
BuildParts.build_id.in_([build.id for build in build_id_list_query.all()]),
|
BuildParts.build_id.in_([build.id for build in build_id_list_query.all()]),
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data
|
).data
|
||||||
if not build_part:
|
if not build_part:
|
||||||
BuildLivingSpace.raise_http_exception(
|
BuildLivingSpace.raise_http_exception(
|
||||||
|
|
@ -141,8 +131,7 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
life_person = People.filter_one(
|
life_person = People.filter_one(
|
||||||
People.uu_id == data.person_uu_id or "",
|
People.uu_id == data.person_uu_id,
|
||||||
*People.valid_record_args(People),
|
|
||||||
).data
|
).data
|
||||||
if not life_person:
|
if not life_person:
|
||||||
BuildLivingSpace.raise_http_exception(
|
BuildLivingSpace.raise_http_exception(
|
||||||
|
|
@ -175,7 +164,6 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
||||||
BuildLivingSpace.build_parts_id == build_part.id,
|
BuildLivingSpace.build_parts_id == build_part.id,
|
||||||
BuildLivingSpace.person_id == life_person.id,
|
BuildLivingSpace.person_id == life_person.id,
|
||||||
BuildLivingSpace.occupant_type == occupant_type.id,
|
BuildLivingSpace.occupant_type == occupant_type.id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
select_args=[BuildLivingSpace.id],
|
select_args=[BuildLivingSpace.id],
|
||||||
order_by=BuildLivingSpace.expiry_starts.desc(),
|
order_by=BuildLivingSpace.expiry_starts.desc(),
|
||||||
limit=1,
|
limit=1,
|
||||||
|
|
@ -183,27 +171,30 @@ class BuildingLivingSpacesPartsCreateEventMethods(MethodToEvent):
|
||||||
|
|
||||||
last_living_space = BuildLivingSpace.filter_one(
|
last_living_space = BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.id == living_space_id[0] if living_space_id else None,
|
BuildLivingSpace.id == living_space_id[0] if living_space_id else None,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
).data
|
||||||
)
|
|
||||||
|
|
||||||
data_dict["expiry_starts"] = str(system_arrow.now())
|
|
||||||
created_living_space = BuildLivingSpace.create_action(
|
created_living_space = BuildLivingSpace.create_action(
|
||||||
data=data_dict, token_dict=token_dict
|
data=data_dict, token_dict=token_dict
|
||||||
)
|
)
|
||||||
|
|
||||||
if last_living_space:
|
if last_living_space:
|
||||||
if last_living_space.expiry_ends > str(system_arrow.now()):
|
dt = system_arrow.get(last_living_space.expiry_ends)
|
||||||
last_living_space.expiry_ends = str(system_arrow.shift(minutes=-10))
|
if dt > system_arrow.now():
|
||||||
|
minute_df = int(dt.time().minute) - 10
|
||||||
|
last_living_space.expiry_ends = str(dt.replace(
|
||||||
|
minute=60 - abs(minute_df) if minute_df < 0 else minute_df
|
||||||
|
))
|
||||||
last_living_space.save()
|
last_living_space.save()
|
||||||
|
|
||||||
user_module = Modules.filter_one(
|
user_module = Modules.filter_one(
|
||||||
Modules.module_code == "USR-PUB", system=True
|
Modules.module_code == "USR-PUB", system=True
|
||||||
).data
|
).data
|
||||||
|
created_living_space.save()
|
||||||
|
created_living_space.update(is_confirmed=True)
|
||||||
|
created_living_space.save()
|
||||||
ModulesBindOccupantEventMethods.modules_bind_occupant_system(
|
ModulesBindOccupantEventMethods.modules_bind_occupant_system(
|
||||||
build_living_space_id=created_living_space.id,
|
build_living_space_id=created_living_space.id,
|
||||||
modules_id=user_module.id,
|
modules_id=user_module.id,
|
||||||
)
|
)
|
||||||
created_living_space.save()
|
|
||||||
return created_living_space
|
return created_living_space
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -233,7 +224,6 @@ class BuildingLivingSpacesPartsUpdateEventMethods(MethodToEvent):
|
||||||
BuildParts.build_id.in_(
|
BuildParts.build_id.in_(
|
||||||
[build.id for build in build_id_list_query.all()]
|
[build.id for build in build_id_list_query.all()]
|
||||||
),
|
),
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
).data
|
).data
|
||||||
if not build_part:
|
if not build_part:
|
||||||
BuildLivingSpace.raise_http_exception(
|
BuildLivingSpace.raise_http_exception(
|
||||||
|
|
@ -266,7 +256,6 @@ class BuildingLivingSpacesPartsUpdateEventMethods(MethodToEvent):
|
||||||
|
|
||||||
last_living_space = BuildLivingSpace.filter_one(
|
last_living_space = BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.id == living_space_id if living_space_id else None,
|
BuildLivingSpace.id == living_space_id if living_space_id else None,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data
|
).data
|
||||||
|
|
||||||
data_dict["expiry_starts"] = str(system_arrow.now())
|
data_dict["expiry_starts"] = str(system_arrow.now())
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,7 @@ class CompanyListEventMethods(MethodToEvent):
|
||||||
Companies.id == token_dict.selected_occupant.responsible_company_id
|
Companies.id == token_dict.selected_occupant.responsible_company_id
|
||||||
).query
|
).query
|
||||||
Companies.filter_attr = list_options
|
Companies.filter_attr = list_options
|
||||||
records = Companies.filter_all(
|
records = Companies.filter_all()
|
||||||
*Companies.valid_record_args(Companies)
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="Building Living Spaces are listed successfully",
|
message="Building Living Spaces are listed successfully",
|
||||||
|
|
@ -97,7 +95,6 @@ class CompanyUpdateEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
find_one_company = Companies.filter_one(
|
find_one_company = Companies.filter_one(
|
||||||
Companies.uu_id == company_uu_id,
|
Companies.uu_id == company_uu_id,
|
||||||
Companies.valid_record_args(Companies),
|
|
||||||
).data
|
).data
|
||||||
if not find_one_company:
|
if not find_one_company:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
@ -133,7 +130,6 @@ class CompanyPatchEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
find_one_company = Companies.filter_one(
|
find_one_company = Companies.filter_one(
|
||||||
Companies.uu_id==company_uu_id,
|
Companies.uu_id==company_uu_id,
|
||||||
*Companies.valid_record_args(Companies)
|
|
||||||
).data
|
).data
|
||||||
access_authorized_company = Companies.select_action(
|
access_authorized_company = Companies.select_action(
|
||||||
duty_id_list=[
|
duty_id_list=[
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ class DepartmentListEventMethods(MethodToEvent):
|
||||||
Departments.filter_attr = list_options
|
Departments.filter_attr = list_options
|
||||||
records = Departments.filter_all(
|
records = Departments.filter_all(
|
||||||
Departments.company_id == token_dict.selected_company.company_id,
|
Departments.company_id == token_dict.selected_company.company_id,
|
||||||
*Departments.valid_record_args(Departments)
|
|
||||||
)
|
)
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ class DutiesGetByUUIDEventMethods(MethodToEvent):
|
||||||
records = Duties.filter_all(
|
records = Duties.filter_all(
|
||||||
Duties.duties_id == duty.id,
|
Duties.duties_id == duty.id,
|
||||||
Duties.company_id == token_dict.selected_company.company_id,
|
Duties.company_id == token_dict.selected_company.company_id,
|
||||||
*Duties.valid_record_args(Duties)
|
|
||||||
)
|
)
|
||||||
if not records.data:
|
if not records.data:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,10 @@ class EmployeeListEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
employees_staff = Staff.filter_all(
|
employees_staff = Staff.filter_all(
|
||||||
Staff.duties_id.in_(token_dict.duty_id_list),
|
Staff.duties_id.in_(token_dict.duty_id_list),
|
||||||
*Staff.valid_record_args(Staff),
|
|
||||||
).data
|
).data
|
||||||
Employees.filter_attr = list_options
|
Employees.filter_attr = list_options
|
||||||
records = Employees.filter_all(
|
records = Employees.filter_all(
|
||||||
Employees.staff_id.in_([staff.id for staff in employees_staff]),
|
Employees.staff_id.in_([staff.id for staff in employees_staff]),
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
)
|
)
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
|
|
@ -60,11 +58,9 @@ class EmployeeCreateEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
person = People.filter_one(
|
person = People.filter_one(
|
||||||
People.uu_id == data.people_uu_id,
|
People.uu_id == data.people_uu_id,
|
||||||
*People.valid_record_args(People),
|
|
||||||
).data
|
).data
|
||||||
staff = Staff.filter_one(
|
staff = Staff.filter_one(
|
||||||
Staff.uu_id == data.staff_uu_id,
|
Staff.uu_id == data.staff_uu_id,
|
||||||
*Staff.valid_record_args(Staff),
|
|
||||||
).data
|
).data
|
||||||
if not staff:
|
if not staff:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
@ -108,7 +104,6 @@ class EmployeeUpdateEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
find_one_employee = Employees.filter_one(
|
find_one_employee = Employees.filter_one(
|
||||||
Employees.uu_id == employee_uu_id,
|
Employees.uu_id == employee_uu_id,
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
access_authorized_employee = Employees.select_action(
|
access_authorized_employee = Employees.select_action(
|
||||||
employee_id=getattr(token_dict, "employee_id", 5),
|
employee_id=getattr(token_dict, "employee_id", 5),
|
||||||
|
|
@ -199,10 +194,9 @@ class Employee2PeopleEmployEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
selected_staff = Staff.filter_one(
|
selected_staff = Staff.filter_one(
|
||||||
Staff.uu_id == data.staff_uu_id,
|
Staff.uu_id == data.staff_uu_id,
|
||||||
*Staff.valid_record_args(Staff),
|
|
||||||
).data
|
).data
|
||||||
selected_people = People.filter_one(
|
selected_people = People.filter_one(
|
||||||
People.uu_id == data.people_uu_id, *People.valid_record_args
|
People.uu_id == data.people_uu_id
|
||||||
).data
|
).data
|
||||||
if not selected_staff:
|
if not selected_staff:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -217,7 +211,6 @@ class Employee2PeopleEmployEventMethods(MethodToEvent):
|
||||||
|
|
||||||
find_one_employee = Employees.filter_all(
|
find_one_employee = Employees.filter_all(
|
||||||
Employees.staff_id == selected_staff.id,
|
Employees.staff_id == selected_staff.id,
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
|
|
||||||
staff_name_upper = str(selected_staff.staff_name).upper()
|
staff_name_upper = str(selected_staff.staff_name).upper()
|
||||||
|
|
@ -265,7 +258,6 @@ class Employee2PeopleFireEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
selected_people = People.filter_one(
|
selected_people = People.filter_one(
|
||||||
People.uu_id == data.people_uu_id,
|
People.uu_id == data.people_uu_id,
|
||||||
*People.valid_record_args(People),
|
|
||||||
).data
|
).data
|
||||||
if not selected_people:
|
if not selected_people:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -275,7 +267,6 @@ class Employee2PeopleFireEventMethods(MethodToEvent):
|
||||||
|
|
||||||
find_one_employee: Employees = Employees.filter_one(
|
find_one_employee: Employees = Employees.filter_one(
|
||||||
Employees.people_id == selected_people.id,
|
Employees.people_id == selected_people.id,
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
if not find_one_employee:
|
if not find_one_employee:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,7 @@ class StaffListEventMethods(MethodToEvent):
|
||||||
@classmethod
|
@classmethod
|
||||||
def staff_list(cls, list_options: ListOptions, token_dict: EmployeeTokenObject):
|
def staff_list(cls, list_options: ListOptions, token_dict: EmployeeTokenObject):
|
||||||
Staff.filter_attr = list_options
|
Staff.filter_attr = list_options
|
||||||
records = Staff.filter_all(
|
records = Staff.filter_all()
|
||||||
*Staff.valid_record_args(Staff)
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="Staff are listed successfully",
|
message="Staff are listed successfully",
|
||||||
|
|
@ -46,7 +44,6 @@ class StaffCreateEventMethods(MethodToEvent):
|
||||||
data_dict = data.excluded_dump()
|
data_dict = data.excluded_dump()
|
||||||
duties = Duties.filter_one(
|
duties = Duties.filter_one(
|
||||||
Duties.uu_id == data.duties_uu_id,
|
Duties.uu_id == data.duties_uu_id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
).data
|
).data
|
||||||
if not duties:
|
if not duties:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -77,10 +74,10 @@ class StaffGetByUUIDEventMethods(MethodToEvent):
|
||||||
def staff_get_by_uu_id(cls, data: SelectStaff, token_dict: EmployeeTokenObject):
|
def staff_get_by_uu_id(cls, data: SelectStaff, token_dict: EmployeeTokenObject):
|
||||||
if data.duties_uu_id:
|
if data.duties_uu_id:
|
||||||
duties_id = Duties.filter_one(
|
duties_id = Duties.filter_one(
|
||||||
Duties.uu_id == data.duties_uu_id, *Duties.valid_record_args(Duties)
|
Duties.uu_id == data.duties_uu_id,
|
||||||
).data
|
).data
|
||||||
selected_staffs = Staff.filter_all(
|
selected_staffs = Staff.filter_all(
|
||||||
Staff.duties_id == duties_id.id, *Staff.valid_record_args(Staff)
|
Staff.duties_id == duties_id.id
|
||||||
)
|
)
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={
|
content={
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,11 @@ class DecisionBookListEventMethods(MethodToEvent):
|
||||||
BuildDecisionBook.filter_attr = list_options
|
BuildDecisionBook.filter_attr = list_options
|
||||||
records = BuildDecisionBook.filter_all(
|
records = BuildDecisionBook.filter_all(
|
||||||
BuildDecisionBook.build_id.in_([build.id for build in build_id_list]),
|
BuildDecisionBook.build_id.in_([build.id for build in build_id_list]),
|
||||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
|
||||||
).data
|
).data
|
||||||
elif isinstance(token_dict, OccupantTokenObject):
|
elif isinstance(token_dict, OccupantTokenObject):
|
||||||
BuildDecisionBook.filter_attr = list_options
|
BuildDecisionBook.filter_attr = list_options
|
||||||
records = BuildDecisionBook.filter_all(
|
records = BuildDecisionBook.filter_all(
|
||||||
BuildDecisionBook.build_id == token_dict.selected_occupant.build_id,
|
BuildDecisionBook.build_id == token_dict.selected_occupant.build_id,
|
||||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
|
||||||
).data
|
).data
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
|
|
@ -84,7 +82,6 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
build = Build.filter_one(
|
build = Build.filter_one(
|
||||||
Build.uu_id == data.build_uu_id,
|
Build.uu_id == data.build_uu_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).data
|
).data
|
||||||
if not build:
|
if not build:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -101,7 +98,6 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
company = Companies.filter_one(
|
company = Companies.filter_one(
|
||||||
Companies.uu_id == data.resp_company_uu_id,
|
Companies.uu_id == data.resp_company_uu_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
).data
|
).data
|
||||||
if not company:
|
if not company:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -143,11 +139,9 @@ class DecisionBookCreateEventMethods(MethodToEvent):
|
||||||
|
|
||||||
occupant_build = Build.filter_one(
|
occupant_build = Build.filter_one(
|
||||||
Build.id == token_dict.selected_occupant.build_id,
|
Build.id == token_dict.selected_occupant.build_id,
|
||||||
*Build.valid_record_args(Build),
|
|
||||||
).data
|
).data
|
||||||
occupant_company = Companies.filter_one(
|
occupant_company = Companies.filter_one(
|
||||||
Companies.id == token_dict.selected_occupant.responsible_company_id,
|
Companies.id == token_dict.selected_occupant.responsible_company_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
).data
|
).data
|
||||||
data_dict["build_id"] = occupant_build.id
|
data_dict["build_id"] = occupant_build.id
|
||||||
data_dict["build_uu_id"] = str(occupant_build.uu_id)
|
data_dict["build_uu_id"] = str(occupant_build.uu_id)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ class DecisionBookDecisionBookItemsListEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
decision_book = BuildDecisionBook.filter_one(
|
decision_book = BuildDecisionBook.filter_one(
|
||||||
BuildDecisionBook.uu_id == data.build_decision_book_uu_id,
|
BuildDecisionBook.uu_id == data.build_decision_book_uu_id,
|
||||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
|
||||||
).data
|
).data
|
||||||
if not decision_book:
|
if not decision_book:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -105,7 +104,6 @@ class DecisionBookDecisionBookItemsListEventMethods(MethodToEvent):
|
||||||
# )
|
# )
|
||||||
# BuildDecisionBookItems.filter_attr = list_options
|
# BuildDecisionBookItems.filter_attr = list_options
|
||||||
# records = BuildDecisionBookItems.filter_all(
|
# records = BuildDecisionBookItems.filter_all(
|
||||||
# *BuildDecisionBookItems.valid_record_args(BuildDecisionBookItems)
|
|
||||||
# )
|
# )
|
||||||
# return return_json_response_from_alchemy(response=records, pagination=list_options)
|
# return return_json_response_from_alchemy(response=records, pagination=list_options)
|
||||||
return
|
return
|
||||||
|
|
@ -178,7 +176,6 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||||
build_parts_list = BuildParts.filter_all(
|
build_parts_list = BuildParts.filter_all(
|
||||||
BuildParts.human_livable == True,
|
BuildParts.human_livable == True,
|
||||||
BuildParts.build_id == build_id,
|
BuildParts.build_id == build_id,
|
||||||
*BuildParts.valid_record_args(BuildParts)
|
|
||||||
)
|
)
|
||||||
book_payment_dict = dict(
|
book_payment_dict = dict(
|
||||||
payment_plan_time_periods=str(data_info_type.key),
|
payment_plan_time_periods=str(data_info_type.key),
|
||||||
|
|
@ -236,7 +233,6 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||||
management_room = BuildParts.filter_one(
|
management_room = BuildParts.filter_one(
|
||||||
BuildParts.build_id == build_id,
|
BuildParts.build_id == build_id,
|
||||||
BuildParts.part_no == 0,
|
BuildParts.part_no == 0,
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
).data
|
).data
|
||||||
occupant_man = OccupantTypes.filter_by_one(
|
occupant_man = OccupantTypes.filter_by_one(
|
||||||
occupant_code="MT-VPR", occupant_category_type="MT"
|
occupant_code="MT-VPR", occupant_category_type="MT"
|
||||||
|
|
@ -244,7 +240,6 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||||
manager_living_space = BuildLivingSpace.filter_one(
|
manager_living_space = BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.build_parts_id == management_room.id,
|
BuildLivingSpace.build_parts_id == management_room.id,
|
||||||
BuildLivingSpace.occupant_type == occupant_man.id,
|
BuildLivingSpace.occupant_type == occupant_man.id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data
|
).data
|
||||||
if not manager_living_space.data:
|
if not manager_living_space.data:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -325,11 +320,9 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||||
|
|
||||||
decision_book_person = BuildDecisionBookPerson.filter_one(
|
decision_book_person = BuildDecisionBookPerson.filter_one(
|
||||||
BuildDecisionBookPerson.token == data.token,
|
BuildDecisionBookPerson.token == data.token,
|
||||||
*BuildDecisionBookPerson.valid_record_args(BuildDecisionBookPerson),
|
|
||||||
).data
|
).data
|
||||||
decision_book = BuildDecisionBook.filter_one(
|
decision_book = BuildDecisionBook.filter_one(
|
||||||
BuildDecisionBook.id == decision_book_person.build_decision_book_id,
|
BuildDecisionBook.id == decision_book_person.build_decision_book_id,
|
||||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
|
||||||
).data
|
).data
|
||||||
BuildDecisionBookItems.check_meeting_is_valid_to_start_add_attendance(
|
BuildDecisionBookItems.check_meeting_is_valid_to_start_add_attendance(
|
||||||
decision_book=decision_book,
|
decision_book=decision_book,
|
||||||
|
|
@ -337,7 +330,6 @@ class DecisionBookDecisionBookItemsCreateEventMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
book_items = BuildDecisionBookItems.filter_all(
|
book_items = BuildDecisionBookItems.filter_all(
|
||||||
BuildDecisionBookItems.build_decision_book_id == decision_book.id,
|
BuildDecisionBookItems.build_decision_book_id == decision_book.id,
|
||||||
*BuildDecisionBookItems.valid_record_args(BuildDecisionBookItems)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data_dict["item_order"] = int(book_items.count) + 1
|
data_dict["item_order"] = int(book_items.count) + 1
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,10 @@ class DecisionBookDecisionBookItemsDebitsListEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
BuildDecisionBookItems.pre_query = BuildDecisionBookItems.filter_all(
|
BuildDecisionBookItems.pre_query = BuildDecisionBookItems.filter_all(
|
||||||
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
||||||
*BuildDecisionBookItems.valid_record_args(BuildDecisionBookItems)
|
|
||||||
).query
|
).query
|
||||||
BuildDecisionBookItems.filter_attr = None
|
BuildDecisionBookItems.filter_attr = None
|
||||||
records = BuildDecisionBookItems.filter_all(
|
records = BuildDecisionBookItems.filter_all(
|
||||||
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
||||||
*BuildDecisionBookItems.valid_record_args(BuildDecisionBookItems)
|
|
||||||
)
|
)
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
|
|
@ -93,12 +91,10 @@ class DecisionBookDecisionBookItemsDebitsCreateEventMethods(MethodToEvent):
|
||||||
decision_book_items_debits["deleted_by"] = None
|
decision_book_items_debits["deleted_by"] = None
|
||||||
BuildDecisionBookItems.pre_query = BuildDecisionBookItems.filter_all(
|
BuildDecisionBookItems.pre_query = BuildDecisionBookItems.filter_all(
|
||||||
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
||||||
*BuildDecisionBookItems.valid_record_args(BuildDecisionBookItems)
|
|
||||||
).query
|
).query
|
||||||
BuildDecisionBookItems.filter_attr = None
|
BuildDecisionBookItems.filter_attr = None
|
||||||
records = BuildDecisionBookItems.filter_all(
|
records = BuildDecisionBookItems.filter_all(
|
||||||
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
BuildDecisionBookItems.decision_book_id == decision_book_id,
|
||||||
*BuildDecisionBookItems.valid_record_args(BuildDecisionBookItems)
|
|
||||||
)
|
)
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ class DecisionBookPersonAddEventMethods(MethodToEvent):
|
||||||
elif isinstance(token_dict, OccupantTokenObject):
|
elif isinstance(token_dict, OccupantTokenObject):
|
||||||
decision_book = BuildDecisionBook.filter_one(
|
decision_book = BuildDecisionBook.filter_one(
|
||||||
BuildDecisionBook.uu_id == data.build_decision_book_uu_id,
|
BuildDecisionBook.uu_id == data.build_decision_book_uu_id,
|
||||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
|
||||||
).data
|
).data
|
||||||
if not decision_book:
|
if not decision_book:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -281,7 +280,6 @@ class DecisionBookPersonAssignOccupantEventMethods(MethodToEvent):
|
||||||
|
|
||||||
build_parts_of_token = BuildParts.filter_all(
|
build_parts_of_token = BuildParts.filter_all(
|
||||||
BuildParts.build_id == token_dict.selected_occupant.build_id,
|
BuildParts.build_id == token_dict.selected_occupant.build_id,
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
).data
|
).data
|
||||||
selected_living_space = BuildLivingSpace.filter_one(
|
selected_living_space = BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.uu_id == data.build_living_space_uu_id,
|
BuildLivingSpace.uu_id == data.build_living_space_uu_id,
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,6 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||||
# Get all the parts of the building that is occupant in token
|
# Get all the parts of the building that is occupant in token
|
||||||
build_parts = BuildParts.filter_all(
|
build_parts = BuildParts.filter_all(
|
||||||
BuildParts.build_id == occupant_building.id,
|
BuildParts.build_id == occupant_building.id,
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get all build living spaces that is found in building with distinct person id
|
# Get all build living spaces that is found in building with distinct person id
|
||||||
|
|
@ -188,7 +187,6 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||||
BuildDecisionBookPerson.invite_id == book_invitation.id,
|
BuildDecisionBookPerson.invite_id == book_invitation.id,
|
||||||
BuildDecisionBookPerson.build_living_space_id
|
BuildDecisionBookPerson.build_living_space_id
|
||||||
== build_living_spaces_user.id,
|
== build_living_spaces_user.id,
|
||||||
*BuildDecisionBookPerson.valid_record_args(BuildDecisionBookPerson),
|
|
||||||
).data:
|
).data:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
|
|
@ -219,7 +217,6 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||||
|
|
||||||
manager_living_spaces = BuildLivingSpace.filter_all(
|
manager_living_spaces = BuildLivingSpace.filter_all(
|
||||||
BuildLivingSpace.person_id == token_dict.person_id,
|
BuildLivingSpace.person_id == token_dict.person_id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
)
|
)
|
||||||
manager_people = BuildDecisionBookPerson.filter_all(
|
manager_people = BuildDecisionBookPerson.filter_all(
|
||||||
BuildDecisionBookPerson.invite_id == book_invitation.id,
|
BuildDecisionBookPerson.invite_id == book_invitation.id,
|
||||||
|
|
@ -229,14 +226,11 @@ class BuildDecisionBookInvitationsCreateEventMethods(MethodToEvent):
|
||||||
for manager_living_space in manager_living_spaces.data
|
for manager_living_space in manager_living_spaces.data
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
)
|
)
|
||||||
manager_people_occupants = BuildDecisionBookPersonOccupants.filter_all(
|
manager_people_occupants = BuildDecisionBookPersonOccupants.filter_all(
|
||||||
BuildDecisionBookPersonOccupants.build_decision_book_person_id
|
BuildDecisionBookPersonOccupants.build_decision_book_person_id
|
||||||
== manager_people.get(1).id,
|
== manager_people.get(1).id,
|
||||||
*BuildDecisionBookPersonOccupants.valid_record_args(
|
|
||||||
BuildDecisionBookPersonOccupants
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
manager_people_occupants.query.delete()
|
manager_people_occupants.query.delete()
|
||||||
manager_people.query.delete()
|
manager_people.query.delete()
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ class EventBindOccupantEventMethods(MethodToEvent):
|
||||||
|
|
||||||
events_to_add_to_occupant = Events.filter_all(
|
events_to_add_to_occupant = Events.filter_all(
|
||||||
Events.uu_id.in_(list(data.event_uu_id_list)),
|
Events.uu_id.in_(list(data.event_uu_id_list)),
|
||||||
*Events.valid_record_args(Events),
|
|
||||||
)
|
)
|
||||||
if not events_to_add_to_occupant.data:
|
if not events_to_add_to_occupant.data:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,20 @@ class ModulesBindOccupantEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
|
|
||||||
living_space = BuildLivingSpace.filter_one(
|
living_space = BuildLivingSpace.filter_one(
|
||||||
Modules.id == build_living_space_id,
|
BuildLivingSpace.id == build_living_space_id,
|
||||||
Modules.active == True,
|
|
||||||
).data
|
).data
|
||||||
modules = Modules.filter_one(
|
modules = Modules.filter_one(
|
||||||
Modules.id == modules_id, Modules.active == True
|
Modules.id == modules_id
|
||||||
).data
|
).data
|
||||||
|
|
||||||
|
if not living_space or not modules:
|
||||||
|
print(f"Giving living Space or Modules: {modules.module_name} not found")
|
||||||
|
return
|
||||||
service_build_dict = dict(build_living_space_id=living_space.id)
|
service_build_dict = dict(build_living_space_id=living_space.id)
|
||||||
service_build_dict["expires_at"] = str(
|
if expires_at:
|
||||||
system_arrow.get(living_space.expiry_ends)
|
|
||||||
)
|
|
||||||
if not expires_at:
|
|
||||||
service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
|
service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
|
||||||
|
else:
|
||||||
|
service_build_dict["expires_at"] = str(system_arrow.get(living_space.expiry_ends))
|
||||||
|
|
||||||
for service in modules.retrieve_services():
|
for service in modules.retrieve_services():
|
||||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||||
|
|
|
||||||
|
|
@ -35,22 +35,19 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
||||||
cls, build_living_space_id: int, service_id: int, expires_at: str = None
|
cls, build_living_space_id: int, service_id: int, expires_at: str = None
|
||||||
):
|
):
|
||||||
from sqlalchemy.dialects.postgresql import insert
|
from sqlalchemy.dialects.postgresql import insert
|
||||||
|
|
||||||
living_space = BuildLivingSpace.filter_one(
|
living_space = BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.id == build_living_space_id,
|
BuildLivingSpace.id == build_living_space_id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data
|
|
||||||
service = Services.filter_one(
|
|
||||||
Services.id == service_id, *Services.valid_record_args(Services)
|
|
||||||
).data
|
).data
|
||||||
|
service = Services.filter_one(Services.id == service_id).data
|
||||||
add_events_list = Service2Events.filter_all(
|
add_events_list = Service2Events.filter_all(
|
||||||
Service2Events.service_id == service.id,
|
Service2Events.service_id == service.id,
|
||||||
*Service2Events.valid_record_args(Service2Events),
|
|
||||||
).data
|
).data
|
||||||
|
if not living_space:
|
||||||
|
print("Living Space is not valid. Service is not binded")
|
||||||
|
return
|
||||||
if not add_events_list:
|
if not add_events_list:
|
||||||
raise Exception(
|
print(f"Service has no events registered. Please contact with your manager")
|
||||||
"Service has no events registered. Please contact with your manager"
|
return
|
||||||
)
|
|
||||||
|
|
||||||
event_ids_list = [
|
event_ids_list = [
|
||||||
{
|
{
|
||||||
|
|
@ -131,7 +128,6 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
||||||
|
|
||||||
service_events = Service2Events.filter_all(
|
service_events = Service2Events.filter_all(
|
||||||
Service2Events.service_id == service.id,
|
Service2Events.service_id == service.id,
|
||||||
Service2Events.valid_record_args(Service2Events),
|
|
||||||
).data
|
).data
|
||||||
if not service_events:
|
if not service_events:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -143,7 +139,6 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
||||||
BuildLivingSpace.build_parts_id == occupants_build_part.id,
|
BuildLivingSpace.build_parts_id == occupants_build_part.id,
|
||||||
BuildLivingSpace.occupant_types_id == occupant_occupant_type.id,
|
BuildLivingSpace.occupant_types_id == occupant_occupant_type.id,
|
||||||
BuildLivingSpace.person_id == token_dict.person_id,
|
BuildLivingSpace.person_id == token_dict.person_id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data
|
).data
|
||||||
if not living_space:
|
if not living_space:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|
@ -197,7 +192,6 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
|
||||||
).data
|
).data
|
||||||
service_events = Service2Events.filter_all(
|
service_events = Service2Events.filter_all(
|
||||||
Service2Events.service_id == service.id,
|
Service2Events.service_id == service.id,
|
||||||
*Service2Events.valid_record_args(Service2Events),
|
|
||||||
).data
|
).data
|
||||||
if not service_events:
|
if not service_events:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
@ -271,7 +265,6 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
|
||||||
|
|
||||||
service_events = Service2Events.filter_all(
|
service_events = Service2Events.filter_all(
|
||||||
Service2Events.service_id == service.id,
|
Service2Events.service_id == service.id,
|
||||||
*Service2Events.valid_record_args(Service2Events),
|
|
||||||
).data
|
).data
|
||||||
if not service_events:
|
if not service_events:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,7 @@ class EventsListEventMethods(MethodToEvent):
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||||
):
|
):
|
||||||
Events.filter_attr = list_options
|
Events.filter_attr = list_options
|
||||||
records = Events.filter_all(
|
records = Events.filter_all()
|
||||||
*Events.valid_record_args(Events)
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="DecisionBook are listed successfully",
|
message="DecisionBook are listed successfully",
|
||||||
|
|
@ -143,7 +141,6 @@ class EventsBindEventToOccupantMethods(MethodToEvent):
|
||||||
def bind_events_employee(cls, data: RegisterEvents2Employee, token_dict):
|
def bind_events_employee(cls, data: RegisterEvents2Employee, token_dict):
|
||||||
events = Events.filter_all(
|
events = Events.filter_all(
|
||||||
Events.uu_id.in_(data.event_id),
|
Events.uu_id.in_(data.event_id),
|
||||||
*Events.valid_record_args(Events),
|
|
||||||
).data
|
).data
|
||||||
if not events:
|
if not events:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -153,16 +150,13 @@ class EventsBindEventToOccupantMethods(MethodToEvent):
|
||||||
employee_is_not_valid = False
|
employee_is_not_valid = False
|
||||||
employee = Employees.filter_one(
|
employee = Employees.filter_one(
|
||||||
Employees.employee_uu_id == data.employee_uu_id,
|
Employees.employee_uu_id == data.employee_uu_id,
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
if employee:
|
if employee:
|
||||||
staff = Staff.filter_one(
|
staff = Staff.filter_one(
|
||||||
Staff.id == employee.staff_id,
|
Staff.id == employee.staff_id,
|
||||||
*Staff.valid_record_args(Staff),
|
|
||||||
).data
|
).data
|
||||||
duties = Duties.filter_one(
|
duties = Duties.filter_one(
|
||||||
Duties.id == staff.duties_id,
|
Duties.id == staff.duties_id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
).data
|
).data
|
||||||
if duties.company_id not in token_dict.companies_id_list:
|
if duties.company_id not in token_dict.companies_id_list:
|
||||||
employee_is_not_valid = True
|
employee_is_not_valid = True
|
||||||
|
|
@ -196,7 +190,6 @@ class EventsBindEventToEmployeeMethods(MethodToEvent):
|
||||||
def bind_events_occupant(cls, data: RegisterEvents2Occupant, token_dict):
|
def bind_events_occupant(cls, data: RegisterEvents2Occupant, token_dict):
|
||||||
events = Events.filter_all(
|
events = Events.filter_all(
|
||||||
Events.uu_id.in_(data.event_id),
|
Events.uu_id.in_(data.event_id),
|
||||||
*Events.valid_record_args(Events),
|
|
||||||
).data
|
).data
|
||||||
if not events:
|
if not events:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -205,7 +198,6 @@ class EventsBindEventToEmployeeMethods(MethodToEvent):
|
||||||
)
|
)
|
||||||
occupant = BuildLivingSpace.filter_one(
|
occupant = BuildLivingSpace.filter_one(
|
||||||
BuildLivingSpace.uu_id == data.build_living_space_uu_id,
|
BuildLivingSpace.uu_id == data.build_living_space_uu_id,
|
||||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
|
||||||
).data
|
).data
|
||||||
if not occupant:
|
if not occupant:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,7 @@ class PeopleListEventMethods(MethodToEvent):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
People.filter_attr = list_options
|
People.filter_attr = list_options
|
||||||
records = People.filter_all(
|
records = People.filter_all()
|
||||||
*People.valid_record_args(People),
|
|
||||||
)
|
|
||||||
elif isinstance(token_dict, OccupantTokenObject):
|
elif isinstance(token_dict, OccupantTokenObject):
|
||||||
related_users = Users.filter_all(
|
related_users = Users.filter_all(
|
||||||
Users.related_company
|
Users.related_company
|
||||||
|
|
@ -49,12 +47,9 @@ class PeopleListEventMethods(MethodToEvent):
|
||||||
).data
|
).data
|
||||||
People.pre_query = People.filter_all(
|
People.pre_query = People.filter_all(
|
||||||
People.id.in_([user.person_id for user in related_users]),
|
People.id.in_([user.person_id for user in related_users]),
|
||||||
*People.valid_record_args(People),
|
|
||||||
).query
|
).query
|
||||||
People.filter_attr = list_options
|
People.filter_attr = list_options
|
||||||
records = People.filter_all(
|
records = People.filter_all()
|
||||||
*People.valid_record_args(People),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="People are listed successfully",
|
message="People are listed successfully",
|
||||||
|
|
@ -68,9 +63,7 @@ class PeopleListEventMethods(MethodToEvent):
|
||||||
token_dict: EmployeeTokenObject,
|
token_dict: EmployeeTokenObject,
|
||||||
):
|
):
|
||||||
People.filter_attr = list_options
|
People.filter_attr = list_options
|
||||||
records = People.filter_all(
|
records = People.filter_all().data
|
||||||
*People.valid_record_args(People),
|
|
||||||
).data
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="People are listed successfully",
|
message="People are listed successfully",
|
||||||
|
|
@ -85,9 +78,7 @@ class PeopleListEventMethods(MethodToEvent):
|
||||||
):
|
):
|
||||||
if isinstance(token_dict, EmployeeTokenObject):
|
if isinstance(token_dict, EmployeeTokenObject):
|
||||||
People.filter_attr = list_options
|
People.filter_attr = list_options
|
||||||
records = People.filter_all(
|
records = People.filter_all().data
|
||||||
*People.valid_record_args(People),
|
|
||||||
).data
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="People are listed successfully",
|
message="People are listed successfully",
|
||||||
|
|
@ -142,7 +133,6 @@ class PeopleUpdateEventMethods(MethodToEvent):
|
||||||
if isinstance(token_dict, EmployeeTokenObject):
|
if isinstance(token_dict, EmployeeTokenObject):
|
||||||
find_one_user = Users.filter_one(
|
find_one_user = Users.filter_one(
|
||||||
Users.uu_id == user_uu_id,
|
Users.uu_id == user_uu_id,
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data
|
).data
|
||||||
access_authorized_company = Companies.select_action(
|
access_authorized_company = Companies.select_action(
|
||||||
duty_id_list=[
|
duty_id_list=[
|
||||||
|
|
@ -164,7 +154,6 @@ class PeopleUpdateEventMethods(MethodToEvent):
|
||||||
elif isinstance(token_dict, OccupantTokenObject):
|
elif isinstance(token_dict, OccupantTokenObject):
|
||||||
find_one_user = People.filter_one(
|
find_one_user = People.filter_one(
|
||||||
People.uu_id == user_uu_id,
|
People.uu_id == user_uu_id,
|
||||||
*People.valid_record_args(People),
|
|
||||||
).data
|
).data
|
||||||
access_authorized_company = Companies.select_action(
|
access_authorized_company = Companies.select_action(
|
||||||
duty_id_list=[getattr(token_dict, "duty_id")],
|
duty_id_list=[getattr(token_dict, "duty_id")],
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,12 @@ class UserListEventMethods(MethodToEvent):
|
||||||
people_id_list = (
|
people_id_list = (
|
||||||
user.person_id
|
user.person_id
|
||||||
for user in Users.filter_all(
|
for user in Users.filter_all(
|
||||||
Users.uu_id.in_(people_ids), *Users.valid_record_args(Users)
|
Users.uu_id.in_(people_ids)
|
||||||
).data
|
).data
|
||||||
)
|
)
|
||||||
Users.filter_attr = list_options
|
Users.filter_attr = list_options
|
||||||
records = Users.filter_all(
|
records = Users.filter_all(
|
||||||
Users.person_id.in_(people_id_list),
|
Users.person_id.in_(people_id_list),
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
)
|
)
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
|
|
@ -60,9 +59,7 @@ class UserListEventMethods(MethodToEvent):
|
||||||
result=records,
|
result=records,
|
||||||
)
|
)
|
||||||
Users.filter_attr = list_options
|
Users.filter_attr = list_options
|
||||||
records = Users.filter_all(
|
records = Users.filter_all()
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
return AlchemyJsonResponse(
|
||||||
completed=True,
|
completed=True,
|
||||||
message="Users are listed successfully",
|
message="Users are listed successfully",
|
||||||
|
|
@ -161,7 +158,6 @@ class UserPatchEventMethods(MethodToEvent):
|
||||||
def user_patch(cls, data: PatchRecord, user_uu_id: str, token_dict):
|
def user_patch(cls, data: PatchRecord, user_uu_id: str, token_dict):
|
||||||
find_one_user = Users.filter_one(
|
find_one_user = Users.filter_one(
|
||||||
Users.uu_id == user_uu_id,
|
Users.uu_id == user_uu_id,
|
||||||
*Users.valid_record_args(Users),
|
|
||||||
).data
|
).data
|
||||||
access_authorized_company = Companies.select_action(
|
access_authorized_company = Companies.select_action(
|
||||||
duty_id_list=[getattr(token_dict, "duty_id", 5)],
|
duty_id_list=[getattr(token_dict, "duty_id", 5)],
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,6 @@ def save_access_token_to_redis(
|
||||||
for living_space in living_spaces:
|
for living_space in living_spaces:
|
||||||
build_parts_selection = BuildParts.filter_all(
|
build_parts_selection = BuildParts.filter_all(
|
||||||
BuildParts.id == living_space.build_parts_id,
|
BuildParts.id == living_space.build_parts_id,
|
||||||
*BuildParts.valid_record_args(BuildParts),
|
|
||||||
)
|
)
|
||||||
if not build_parts_selection.data:
|
if not build_parts_selection.data:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -133,16 +132,15 @@ def save_access_token_to_redis(
|
||||||
|
|
||||||
list_employee = Employees.filter_all(
|
list_employee = Employees.filter_all(
|
||||||
Employees.people_id == found_user.person_id,
|
Employees.people_id == found_user.person_id,
|
||||||
*Employees.valid_record_args(Employees),
|
|
||||||
).data
|
).data
|
||||||
companies_uu_id_list, companies_id_list = [], []
|
companies_uu_id_list, companies_id_list = [], []
|
||||||
duty_uu_id_list, duty_id_list = [], []
|
duty_uu_id_list, duty_id_list = [], []
|
||||||
for employee in list_employee:
|
for employee in list_employee:
|
||||||
staff = Staff.filter_one(
|
staff = Staff.filter_one(
|
||||||
Staff.id == employee.staff_id, *Staff.valid_record_args(Staff)
|
Staff.id == employee.staff_id
|
||||||
).data
|
).data
|
||||||
if duties := Duties.filter_one(
|
if duties := Duties.filter_one(
|
||||||
Duties.id == staff.duties_id, *Duties.valid_record_args(Duties)
|
Duties.id == staff.duties_id
|
||||||
).data:
|
).data:
|
||||||
if duty_found := Duty.filter_by_one(id=duties.duties_id).data:
|
if duty_found := Duty.filter_by_one(id=duties.duties_id).data:
|
||||||
duty_uu_id_list.append(str(duty_found.uu_id))
|
duty_uu_id_list.append(str(duty_found.uu_id))
|
||||||
|
|
@ -150,11 +148,9 @@ def save_access_token_to_redis(
|
||||||
|
|
||||||
department = Departments.filter_one(
|
department = Departments.filter_one(
|
||||||
Departments.id == duties.department_id,
|
Departments.id == duties.department_id,
|
||||||
*Departments.valid_record_args(Departments),
|
|
||||||
).data
|
).data
|
||||||
if company := Companies.filter_one(
|
if company := Companies.filter_one(
|
||||||
Companies.id == department.company_id,
|
Companies.id == department.company_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
).data:
|
).data:
|
||||||
companies_uu_id_list.append(str(company.uu_id))
|
companies_uu_id_list.append(str(company.uu_id))
|
||||||
companies_id_list.append(company.id)
|
companies_id_list.append(company.id)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ def parse_token_object_to_dict(request): # from requests import Request
|
||||||
selected_event = Events.filter_one(
|
selected_event = Events.filter_one(
|
||||||
Events.endpoint_id == endpoint_active.id,
|
Events.endpoint_id == endpoint_active.id,
|
||||||
Events.id.in_(valid_token.selected_company.reachable_event_list_id),
|
Events.id.in_(valid_token.selected_company.reachable_event_list_id),
|
||||||
*Events.valid_record_args(Events),
|
|
||||||
).data
|
).data
|
||||||
if not selected_event:
|
if not selected_event:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -61,7 +60,6 @@ def parse_token_object_to_dict(request): # from requests import Request
|
||||||
selected_event = Events.filter_all(
|
selected_event = Events.filter_all(
|
||||||
Events.endpoint_id == endpoint_active.id,
|
Events.endpoint_id == endpoint_active.id,
|
||||||
Events.id.in_(valid_token.selected_occupant.reachable_event_list_id),
|
Events.id.in_(valid_token.selected_occupant.reachable_event_list_id),
|
||||||
Events.valid_record_args(Events),
|
|
||||||
)
|
)
|
||||||
if not selected_event.data:
|
if not selected_event.data:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ class InsertBuildLivingSpace(BaseModelRegular):
|
||||||
person_uu_id: str
|
person_uu_id: str
|
||||||
build_parts_uu_id: str
|
build_parts_uu_id: str
|
||||||
occupant_type_uu_id: str
|
occupant_type_uu_id: str
|
||||||
|
expiry_starts: str
|
||||||
|
expiry_ends: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class UpdateBuildLivingSpace(PydanticBaseModel):
|
class UpdateBuildLivingSpace(PydanticBaseModel):
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,6 @@ class UserLoginModule(AuthModule):
|
||||||
People,
|
People,
|
||||||
MongoQueryIdentity,
|
MongoQueryIdentity,
|
||||||
)
|
)
|
||||||
|
|
||||||
found_user = Users.check_user_exits(
|
found_user = Users.check_user_exits(
|
||||||
access_key=data.access_key, domain=data.domain
|
access_key=data.access_key, domain=data.domain
|
||||||
)
|
)
|
||||||
|
|
@ -262,7 +261,7 @@ class UserLoginModule(AuthModule):
|
||||||
record_id = uuid.uuid4().__str__()
|
record_id = uuid.uuid4().__str__()
|
||||||
notice_link = ApiStatic.blacklist_login(record_id=record_id)
|
notice_link = ApiStatic.blacklist_login(record_id=record_id)
|
||||||
found_people = People.filter_one(
|
found_people = People.filter_one(
|
||||||
People.id == found_user.person_id, *People.valid_record_args(People)
|
People.id == found_user.person_id
|
||||||
).data
|
).data
|
||||||
access_via_user = query_engine.update_access_history_via_user(
|
access_via_user = query_engine.update_access_history_via_user(
|
||||||
AccessHistoryViaUser(
|
AccessHistoryViaUser(
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ from sqlalchemy import (
|
||||||
Numeric,
|
Numeric,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from api_library.date_time_actions.date_functions import system_arrow
|
||||||
from databases.sql_models.core_mixin import CrudCollection
|
from databases.sql_models.core_mixin import CrudCollection
|
||||||
|
|
||||||
from databases.extensions.selector_classes import SelectActionWithEmployee
|
from databases.extensions.selector_classes import SelectActionWithEmployee
|
||||||
|
|
@ -240,7 +241,6 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||||
if data.address_uu_id:
|
if data.address_uu_id:
|
||||||
official_address = Addresses.filter_one(
|
official_address = Addresses.filter_one(
|
||||||
Addresses.uu_id==data.address_uu_id,
|
Addresses.uu_id==data.address_uu_id,
|
||||||
*Addresses.valid_record_args(Addresses)
|
|
||||||
).data
|
).data
|
||||||
data_dict["address_id"] = official_address.id
|
data_dict["address_id"] = official_address.id
|
||||||
data_dict["build_no"] = str(official_address.build_number)
|
data_dict["build_no"] = str(official_address.build_number)
|
||||||
|
|
@ -305,7 +305,6 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||||
def livable_part_count(self):
|
def livable_part_count(self):
|
||||||
livable_parts = BuildParts.filter_all(
|
livable_parts = BuildParts.filter_all(
|
||||||
BuildParts.build_id == self.id, BuildParts.human_livable == True,
|
BuildParts.build_id == self.id, BuildParts.human_livable == True,
|
||||||
*BuildParts.valid_record_args(BuildParts)
|
|
||||||
)
|
)
|
||||||
if not livable_parts.data:
|
if not livable_parts.data:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -422,7 +421,6 @@ class BuildParts(CrudCollection):
|
||||||
|
|
||||||
if build_types := BuildTypes.filter_one(
|
if build_types := BuildTypes.filter_one(
|
||||||
BuildTypes.uu_id == data.build_part_type_uu_id,
|
BuildTypes.uu_id == data.build_part_type_uu_id,
|
||||||
*BuildTypes.valid_record_args(BuildTypes)
|
|
||||||
).data:
|
).data:
|
||||||
part_direction = ApiEnumDropdown.get_by_uuid(
|
part_direction = ApiEnumDropdown.get_by_uuid(
|
||||||
uuid=str(data.part_direction_uu_id)
|
uuid=str(data.part_direction_uu_id)
|
||||||
|
|
@ -554,15 +552,24 @@ class BuildLivingSpace(CrudCollection):
|
||||||
from api_events.events.events.events_bind_services import (
|
from api_events.events.events.events_bind_services import (
|
||||||
ServiceBindOccupantEventMethods,
|
ServiceBindOccupantEventMethods,
|
||||||
)
|
)
|
||||||
|
if data.get('expiry_starts'):
|
||||||
|
data['expiry_starts'] = str(system_arrow.get(data['expiry_starts']))
|
||||||
|
if data.get('expiry_ends'):
|
||||||
|
data['expiry_ends'] = str(system_arrow.get(data['expiry_ends']))
|
||||||
created_living_space = BuildLivingSpace.find_or_create(**data)
|
created_living_space = BuildLivingSpace.find_or_create(**data)
|
||||||
occupant_type = OccupantTypes.find_one(
|
occupant_type = OccupantTypes.filter_by_one(
|
||||||
|
system=True,
|
||||||
uu_id=created_living_space.occupant_type_uu_id
|
uu_id=created_living_space.occupant_type_uu_id
|
||||||
)
|
).data
|
||||||
related_service = Services.find_one(
|
related_service = Services.filter_by_one(
|
||||||
active=True,
|
|
||||||
related_responsibility=occupant_type.occupant_code,
|
related_responsibility=occupant_type.occupant_code,
|
||||||
)
|
**Services.valid_record_dict
|
||||||
|
).data
|
||||||
|
|
||||||
|
created_living_space.save()
|
||||||
|
created_living_space.is_confirmed = True
|
||||||
|
created_living_space.save()
|
||||||
|
|
||||||
if not related_service:
|
if not related_service:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||||
|
|
@ -584,7 +591,6 @@ class BuildLivingSpace(CrudCollection):
|
||||||
or_(
|
or_(
|
||||||
cls.owner_person_id == customer_id,
|
cls.owner_person_id == customer_id,
|
||||||
cls.life_person_id == customer_id,
|
cls.life_person_id == customer_id,
|
||||||
*cls.valid_record_args(cls)
|
|
||||||
),
|
),
|
||||||
cls.start_date < formatted_date - timedelta(days=add_days),
|
cls.start_date < formatted_date - timedelta(days=add_days),
|
||||||
cls.stop_date > formatted_date + timedelta(days=add_days),
|
cls.stop_date > formatted_date + timedelta(days=add_days),
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,6 @@ class BuildDecisionBook(CrudCollection):
|
||||||
)
|
)
|
||||||
related_building = Build.filter_all(
|
related_building = Build.filter_all(
|
||||||
Build.company_id.in_(related_companies_ids)
|
Build.company_id.in_(related_companies_ids)
|
||||||
* Build.valid_record_args(Build),
|
|
||||||
)
|
)
|
||||||
related_building_ids = list(related_.id for related_ in related_building.data)
|
related_building_ids = list(related_.id for related_ in related_building.data)
|
||||||
return cls.filter_all(cls.build_id.in_(related_building_ids)).query
|
return cls.filter_all(cls.build_id.in_(related_building_ids)).query
|
||||||
|
|
@ -176,7 +175,6 @@ class BuildDecisionBook(CrudCollection):
|
||||||
BuildDecisionBook.build_id == building.id,
|
BuildDecisionBook.build_id == building.id,
|
||||||
BuildDecisionBook.expiry_ends > data_dict["expiry_starts"],
|
BuildDecisionBook.expiry_ends > data_dict["expiry_starts"],
|
||||||
BuildDecisionBook.decision_type == data_dict.get("decision_type"),
|
BuildDecisionBook.decision_type == data_dict.get("decision_type"),
|
||||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
|
||||||
).data: # Decision book is already exist:
|
).data: # Decision book is already exist:
|
||||||
cls.raise_http_exception(
|
cls.raise_http_exception(
|
||||||
status_code=status.HTTP_409_CONFLICT,
|
status_code=status.HTTP_409_CONFLICT,
|
||||||
|
|
@ -485,6 +483,9 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||||
expires_at = str(
|
expires_at = str(
|
||||||
system_arrow.get(decision_book.meeting_date).shift(days=15)
|
system_arrow.get(decision_book.meeting_date).shift(days=15)
|
||||||
)
|
)
|
||||||
|
related_living_space.save()
|
||||||
|
related_living_space.is_confirmed = True
|
||||||
|
related_living_space.save()
|
||||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||||
build_living_space_id=related_living_space.id,
|
build_living_space_id=related_living_space.id,
|
||||||
service_id=related_service.id,
|
service_id=related_service.id,
|
||||||
|
|
@ -496,9 +497,6 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||||
def get_occupant_types(self):
|
def get_occupant_types(self):
|
||||||
if occupants := BuildDecisionBookPersonOccupants.filter_all(
|
if occupants := BuildDecisionBookPersonOccupants.filter_all(
|
||||||
BuildDecisionBookPersonOccupants.build_decision_book_person_id == self.id,
|
BuildDecisionBookPersonOccupants.build_decision_book_person_id == self.id,
|
||||||
*BuildDecisionBookPersonOccupants.valid_record_args(
|
|
||||||
BuildDecisionBookPersonOccupants
|
|
||||||
),
|
|
||||||
).data:
|
).data:
|
||||||
return occupants
|
return occupants
|
||||||
return
|
return
|
||||||
|
|
@ -1073,12 +1071,11 @@ class BuildDecisionBookProjects(CrudCollection):
|
||||||
related_.id for related_ in related_companies.all()
|
related_.id for related_ in related_companies.all()
|
||||||
)
|
)
|
||||||
related_building = Build.filter_all(
|
related_building = Build.filter_all(
|
||||||
Build.company_id.in_(related_companies_ids), *Build.valid_record_args(Build)
|
Build.company_id.in_(related_companies_ids)
|
||||||
)
|
)
|
||||||
related_building_ids = list(related_.id for related_ in related_building.data)
|
related_building_ids = list(related_.id for related_ in related_building.data)
|
||||||
related_decision_books = BuildDecisionBook.filter_all(
|
related_decision_books = BuildDecisionBook.filter_all(
|
||||||
BuildDecisionBook.build_id.in_(related_building_ids),
|
BuildDecisionBook.build_id.in_(related_building_ids),
|
||||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
|
||||||
).data
|
).data
|
||||||
related_decision_books_ids = list(
|
related_decision_books_ids = list(
|
||||||
related_.id for related_ in related_decision_books
|
related_.id for related_ in related_decision_books
|
||||||
|
|
@ -1087,14 +1084,12 @@ class BuildDecisionBookProjects(CrudCollection):
|
||||||
BuildDecisionBookItems.build_decision_book_id.in_(
|
BuildDecisionBookItems.build_decision_book_id.in_(
|
||||||
related_decision_books_ids
|
related_decision_books_ids
|
||||||
),
|
),
|
||||||
*BuildDecisionBookItems.valid_record_args(BuildDecisionBookItems),
|
|
||||||
).data
|
).data
|
||||||
related_decision_books_items_ids = list(
|
related_decision_books_items_ids = list(
|
||||||
related_.id for related_ in related_decision_books_items
|
related_.id for related_ in related_decision_books_items
|
||||||
)
|
)
|
||||||
return cls.filter_all(
|
return cls.filter_all(
|
||||||
cls.build_decision_book_item_id.in_(related_decision_books_items_ids),
|
cls.build_decision_book_item_id.in_(related_decision_books_items_ids),
|
||||||
*cls.valid_record_args(cls),
|
|
||||||
).query
|
).query
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,10 @@ class RelationshipDutyCompany(CrudCollection):
|
||||||
list_match_company_id = []
|
list_match_company_id = []
|
||||||
send_duties = Duties.filter_one(
|
send_duties = Duties.filter_one(
|
||||||
Duties.uu_id == data.duty_uu_id,
|
Duties.uu_id == data.duty_uu_id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
)
|
)
|
||||||
send_user_duties = Duties.filter_one(
|
send_user_duties = Duties.filter_one(
|
||||||
Duties.duties_id == send_duties.id,
|
Duties.duties_id == send_duties.id,
|
||||||
Duties.company_id == token_duties_id,
|
Duties.company_id == token_duties_id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
)
|
)
|
||||||
if not send_user_duties:
|
if not send_user_duties:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
@ -85,13 +83,11 @@ class RelationshipDutyCompany(CrudCollection):
|
||||||
for company_uu_id in list(data.match_company_uu_id):
|
for company_uu_id in list(data.match_company_uu_id):
|
||||||
company = Companies.filter_one(
|
company = Companies.filter_one(
|
||||||
Companies.uu_id == company_uu_id,
|
Companies.uu_id == company_uu_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
)
|
)
|
||||||
bulk_company = RelationshipDutyCompany.filter_one(
|
bulk_company = RelationshipDutyCompany.filter_one(
|
||||||
RelationshipDutyCompany.owner_id == token_company_id,
|
RelationshipDutyCompany.owner_id == token_company_id,
|
||||||
RelationshipDutyCompany.relationship_type == "Bulk",
|
RelationshipDutyCompany.relationship_type == "Bulk",
|
||||||
RelationshipDutyCompany.member_id == company.id,
|
RelationshipDutyCompany.member_id == company.id,
|
||||||
*RelationshipDutyCompany.valid_record_args(RelationshipDutyCompany),
|
|
||||||
)
|
)
|
||||||
if not bulk_company:
|
if not bulk_company:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
@ -122,12 +118,10 @@ class RelationshipDutyCompany(CrudCollection):
|
||||||
list_match_company_id = []
|
list_match_company_id = []
|
||||||
send_duties = Duties.filter_one(
|
send_duties = Duties.filter_one(
|
||||||
Duties.uu_id == data.duty_uu_id,
|
Duties.uu_id == data.duty_uu_id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
)
|
)
|
||||||
send_user_duties = Duties.filter_one(
|
send_user_duties = Duties.filter_one(
|
||||||
Duties.duties_id == send_duties.id,
|
Duties.duties_id == send_duties.id,
|
||||||
Duties.company_id == token_duties_id,
|
Duties.company_id == token_duties_id,
|
||||||
*Duties.valid_record_args(Duties),
|
|
||||||
)
|
)
|
||||||
if not send_user_duties:
|
if not send_user_duties:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
@ -137,13 +131,11 @@ class RelationshipDutyCompany(CrudCollection):
|
||||||
for company_uu_id in list(data.match_company_uu_id):
|
for company_uu_id in list(data.match_company_uu_id):
|
||||||
company = Companies.filter_one(
|
company = Companies.filter_one(
|
||||||
Companies.uu_id == company_uu_id,
|
Companies.uu_id == company_uu_id,
|
||||||
*Companies.valid_record_args(Companies),
|
|
||||||
)
|
)
|
||||||
bulk_company = RelationshipDutyCompany.filter_one(
|
bulk_company = RelationshipDutyCompany.filter_one(
|
||||||
RelationshipDutyCompany.owner_id == token_company_id,
|
RelationshipDutyCompany.owner_id == token_company_id,
|
||||||
RelationshipDutyCompany.relationship_type == "Bulk",
|
RelationshipDutyCompany.relationship_type == "Bulk",
|
||||||
RelationshipDutyCompany.member_id == company.id,
|
RelationshipDutyCompany.member_id == company.id,
|
||||||
*RelationshipDutyCompany.valid_record_args(RelationshipDutyCompany),
|
|
||||||
)
|
)
|
||||||
if not bulk_company:
|
if not bulk_company:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
@ -254,7 +246,6 @@ class Companies(CrudCollection, SelectAction):
|
||||||
|
|
||||||
official_address = Addresses.filter_one(
|
official_address = Addresses.filter_one(
|
||||||
Addresses.uu_id == data.official_address_uu_id,
|
Addresses.uu_id == data.official_address_uu_id,
|
||||||
*Addresses.valid_record_args(Addresses),
|
|
||||||
).data
|
).data
|
||||||
# if not official_address:
|
# if not official_address:
|
||||||
# raise HTTPException(
|
# raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,10 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
|
||||||
is_found can be used to check if the record was found or created.
|
is_found can be used to check if the record was found or created.
|
||||||
"""
|
"""
|
||||||
check_kwargs = cls.extract_system_fields(kwargs)
|
check_kwargs = cls.extract_system_fields(kwargs)
|
||||||
cls.pre_query = cls.query.filter(cls.expiry_ends < system_arrow.now().date())
|
cls.pre_query = cls.query.filter(
|
||||||
|
cls.expiry_ends > str(system_arrow.now()),
|
||||||
|
cls.expiry_starts <= str(system_arrow.now()),
|
||||||
|
)
|
||||||
already_record = cls.filter_by_one(system=True, **check_kwargs).data
|
already_record = cls.filter_by_one(system=True, **check_kwargs).data
|
||||||
cls.pre_query = None
|
cls.pre_query = None
|
||||||
if already_record:
|
if already_record:
|
||||||
|
|
@ -195,8 +198,8 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
|
||||||
if getattr(cls.creds, "person_id", None) and getattr(
|
if getattr(cls.creds, "person_id", None) and getattr(
|
||||||
cls.creds, "person_name", None
|
cls.creds, "person_name", None
|
||||||
):
|
):
|
||||||
cls.created_by_id = cls.creds.get("person_id", "Unknown")
|
cls.created_by_id = cls.creds.get("person_id", None)
|
||||||
cls.created_by = cls.creds.get("person_name", "Unknown")
|
cls.created_by = cls.creds.get("person_name", None)
|
||||||
created_record.flush()
|
created_record.flush()
|
||||||
return created_record
|
return created_record
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class Modules(CrudCollection):
|
||||||
|
|
||||||
def retrieve_services(self):
|
def retrieve_services(self):
|
||||||
services = Services.filter_all(
|
services = Services.filter_all(
|
||||||
Services.module_id == self.id, *Services.valid_record_args(Services)
|
Services.module_id == self.id
|
||||||
).data
|
).data
|
||||||
if not services:
|
if not services:
|
||||||
self.raise_http_exception(
|
self.raise_http_exception(
|
||||||
|
|
@ -146,11 +146,11 @@ class Event2Employee(CrudCollection):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_event_id_by_employee_id(cls, employee_id) -> (list, list):
|
def get_event_id_by_employee_id(cls, employee_id) -> (list, list):
|
||||||
active_events = cls.filter_all(
|
active_events = cls.filter_all(
|
||||||
cls.employee_id == employee_id, *cls.valid_record_args(cls)
|
cls.employee_id == employee_id
|
||||||
)
|
)
|
||||||
active_events_id = [event.event_id for event in active_events.data]
|
active_events_id = [event.event_id for event in active_events.data]
|
||||||
active_events = Events.filter_all(
|
active_events = Events.filter_all(
|
||||||
Events.id.in_(active_events_id), *Events.valid_record_args(Events)
|
Events.id.in_(active_events_id)
|
||||||
)
|
)
|
||||||
active_events_uu_id = [str(event.uu_id) for event in active_events.data]
|
active_events_uu_id = [str(event.uu_id) for event in active_events.data]
|
||||||
return active_events_id, active_events_uu_id
|
return active_events_id, active_events_uu_id
|
||||||
|
|
@ -189,11 +189,10 @@ class Event2Occupant(CrudCollection):
|
||||||
) -> (list, list):
|
) -> (list, list):
|
||||||
active_events = cls.filter_all(
|
active_events = cls.filter_all(
|
||||||
cls.build_living_space_id == build_living_space_id,
|
cls.build_living_space_id == build_living_space_id,
|
||||||
*cls.valid_record_args(cls),
|
|
||||||
).data
|
).data
|
||||||
active_events_id = [event.event_id for event in active_events]
|
active_events_id = [event.event_id for event in active_events]
|
||||||
active_events = Events.filter_all(
|
active_events = Events.filter_all(
|
||||||
Events.id.in_(active_events_id), *Events.valid_record_args(Events)
|
Events.id.in_(active_events_id)
|
||||||
).data
|
).data
|
||||||
active_events_uu_id = [str(event.uu_id) for event in active_events]
|
active_events_uu_id = [str(event.uu_id) for event in active_events]
|
||||||
return active_events_id, active_events_uu_id
|
return active_events_id, active_events_uu_id
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,6 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
||||||
def create_action(cls, create_user: InsertUsers):
|
def create_action(cls, create_user: InsertUsers):
|
||||||
found_person = People.filter_one(
|
found_person = People.filter_one(
|
||||||
People.uu_id == create_user.people_uu_id,
|
People.uu_id == create_user.people_uu_id,
|
||||||
*People.valid_record_args(People),
|
|
||||||
).data
|
).data
|
||||||
if not found_person:
|
if not found_person:
|
||||||
raise HTTPException(status_code=400, detail="Person not found.")
|
raise HTTPException(status_code=400, detail="Person not found.")
|
||||||
|
|
@ -164,14 +163,19 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
||||||
@classmethod
|
@classmethod
|
||||||
def credentials(cls):
|
def credentials(cls):
|
||||||
person_object = People.filter_by_one(system=True, id=cls.person_id).data
|
person_object = People.filter_by_one(system=True, id=cls.person_id).data
|
||||||
if not person_object:
|
# if not person_object:
|
||||||
raise HTTPException(
|
# raise HTTPException(
|
||||||
status_code=401,
|
# status_code=401,
|
||||||
detail="Person not found. Please contact the admin.",
|
# detail="Person not found. Please contact the admin.",
|
||||||
)
|
# )
|
||||||
|
if person_object:
|
||||||
|
return {
|
||||||
|
"person_id": person_object.id,
|
||||||
|
"person_uu_id": str(person_object.uu_id),
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
"person_id": person_object.id,
|
"person_id": None,
|
||||||
"person_uu_id": str(person_object.uu_id),
|
"person_uu_id": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_employee_and_duty_details(self):
|
def get_employee_and_duty_details(self):
|
||||||
|
|
@ -179,7 +183,6 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
||||||
|
|
||||||
found_person = People.filter_one(
|
found_person = People.filter_one(
|
||||||
People.id==self.person_id,
|
People.id==self.person_id,
|
||||||
*People.valid_record_args(People),
|
|
||||||
)
|
)
|
||||||
found_employees = Employees.filter_by_active(
|
found_employees = Employees.filter_by_active(
|
||||||
people_id=found_person.id, is_confirmed=True
|
people_id=found_person.id, is_confirmed=True
|
||||||
|
|
@ -460,9 +463,6 @@ class Addresses(CrudCollection):
|
||||||
post_code_list = RelationshipEmployee2PostCode.filter_all(
|
post_code_list = RelationshipEmployee2PostCode.filter_all(
|
||||||
RelationshipEmployee2PostCode.employee_id
|
RelationshipEmployee2PostCode.employee_id
|
||||||
== token_dict.selected_company.employee_id,
|
== token_dict.selected_company.employee_id,
|
||||||
*RelationshipEmployee2PostCode.valid_record_args(
|
|
||||||
RelationshipEmployee2PostCode
|
|
||||||
),
|
|
||||||
).data
|
).data
|
||||||
post_code_id_list = [post_code.member_id for post_code in post_code_list]
|
post_code_id_list = [post_code.member_id for post_code in post_code_list]
|
||||||
if not post_code_id_list:
|
if not post_code_id_list:
|
||||||
|
|
@ -471,7 +471,7 @@ class Addresses(CrudCollection):
|
||||||
detail="User has no post code registered. User can not list addresses.",
|
detail="User has no post code registered. User can not list addresses.",
|
||||||
)
|
)
|
||||||
cls.pre_query = cls.filter_all(
|
cls.pre_query = cls.filter_all(
|
||||||
cls.post_code_id.in_(post_code_id_list), cls.valid_record_args(cls)
|
cls.post_code_id.in_(post_code_id_list)
|
||||||
).query
|
).query
|
||||||
filter_cls = cls.filter_all(*filter_expr or [])
|
filter_cls = cls.filter_all(*filter_expr or [])
|
||||||
cls.pre_query = None
|
cls.pre_query = None
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ class FilterAttributes:
|
||||||
"""Saves the updated model to the current entity db."""
|
"""Saves the updated model to the current entity db."""
|
||||||
try:
|
try:
|
||||||
cls.__session__.commit()
|
cls.__session__.commit()
|
||||||
return cls
|
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
cls.raise_http_exception(
|
cls.raise_http_exception(
|
||||||
status_code="HTTP_400_BAD_REQUEST",
|
status_code="HTTP_400_BAD_REQUEST",
|
||||||
|
|
@ -122,14 +121,26 @@ class FilterAttributes:
|
||||||
)
|
)
|
||||||
return arg
|
return arg
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_active_and_confirmed_query_arg(cls, arg):
|
||||||
|
"""Add active and confirmed to the query."""
|
||||||
|
arg = cls.add_new_arg_to_args(
|
||||||
|
arg, "is_confirmed", cls.is_confirmed == True
|
||||||
|
)
|
||||||
|
arg = cls.add_new_arg_to_args(
|
||||||
|
arg, "active", cls.active == True
|
||||||
|
)
|
||||||
|
arg = cls.add_new_arg_to_args(
|
||||||
|
arg, "deleted", cls.deleted == False
|
||||||
|
)
|
||||||
|
return arg
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def select_only(
|
def select_only(
|
||||||
cls, *args, select_args: list, order_by=None, limit=None, system=False
|
cls, *args, select_args: list, order_by=None, limit=None, system=False
|
||||||
):
|
):
|
||||||
if not system:
|
if not system:
|
||||||
args = cls.add_new_arg_to_args(
|
args = cls.get_active_and_confirmed_query_arg(args)
|
||||||
args, "is_confirmed", cls.is_confirmed == True
|
|
||||||
)
|
|
||||||
args = cls.get_not_expired_query_arg(args)
|
args = cls.get_not_expired_query_arg(args)
|
||||||
query = cls._query().filter(*args).with_entities(*select_args)
|
query = cls._query().filter(*args).with_entities(*select_args)
|
||||||
cls.total_count = query.count()
|
cls.total_count = query.count()
|
||||||
|
|
@ -175,9 +186,7 @@ class FilterAttributes:
|
||||||
"""
|
"""
|
||||||
arg_left = lambda arg_obj: getattr(getattr(arg_obj, "left", None), "key", None)
|
arg_left = lambda arg_obj: getattr(getattr(arg_obj, "left", None), "key", None)
|
||||||
if not system:
|
if not system:
|
||||||
args = cls.add_new_arg_to_args(
|
args = cls.get_active_and_confirmed_query_arg(args)
|
||||||
args, "is_confirmed", cls.is_confirmed == True
|
|
||||||
)
|
|
||||||
args = cls.get_not_expired_query_arg(args)
|
args = cls.get_not_expired_query_arg(args)
|
||||||
filter_list = cls.get_filter_attributes()
|
filter_list = cls.get_filter_attributes()
|
||||||
if filter_list.get("query", None):
|
if filter_list.get("query", None):
|
||||||
|
|
@ -199,9 +208,7 @@ class FilterAttributes:
|
||||||
Filters one record regardless of is_deleted, is_confirmed.
|
Filters one record regardless of is_deleted, is_confirmed.
|
||||||
"""
|
"""
|
||||||
if not system:
|
if not system:
|
||||||
args = cls.add_new_arg_to_args(
|
args = cls.get_active_and_confirmed_query_arg(args)
|
||||||
args, "is_confirmed", cls.is_confirmed == True
|
|
||||||
)
|
|
||||||
args = cls.get_not_expired_query_arg(args)
|
args = cls.get_not_expired_query_arg(args)
|
||||||
query = cls._query().filter(*args)
|
query = cls._query().filter(*args)
|
||||||
cls.total_count = 1
|
cls.total_count = 1
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,9 @@ def create_app(routers):
|
||||||
if route.include_in_schema:
|
if route.include_in_schema:
|
||||||
methods = [method.lower() for method in getattr(route, "methods")]
|
methods = [method.lower() for method in getattr(route, "methods")]
|
||||||
for method in methods:
|
for method in methods:
|
||||||
if path not in Config.INSECURE_PATHS:
|
insecure_paths = Config.INSECURE_PATHS.copy()
|
||||||
|
insecure_paths.remove("/authentication/select")
|
||||||
|
if path not in insecure_paths:
|
||||||
openapi_schema["paths"][path][method]["security"] = [
|
openapi_schema["paths"][path][method]["security"] = [
|
||||||
{"Bearer Auth": []}
|
{"Bearer Auth": []}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -97,15 +97,15 @@ def add_events_all_services_and_occupant_types():
|
||||||
)
|
)
|
||||||
for block in event_block_class():
|
for block in event_block_class():
|
||||||
event_id, event_uu_id = block
|
event_id, event_uu_id = block
|
||||||
Service2Events.find_or_create(
|
service_events = Service2Events.find_or_create(
|
||||||
service_id=service_selected.id,
|
service_id=service_selected.id,
|
||||||
service_uu_id=str(service_selected.uu_id),
|
service_uu_id=str(service_selected.uu_id),
|
||||||
event_id=event_id,
|
event_id=event_id,
|
||||||
event_uu_id=event_uu_id,
|
event_uu_id=event_uu_id,
|
||||||
)
|
)
|
||||||
Service2Events.save()
|
service_events.save()
|
||||||
Service2Events.is_confirmed = True
|
service_events.is_confirmed = True
|
||||||
Service2Events.save()
|
service_events.save()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,9 +140,7 @@ def create_occupant_types_defaults():
|
||||||
]
|
]
|
||||||
|
|
||||||
for list_occupant_type in list_occupant_types:
|
for list_occupant_type in list_occupant_types:
|
||||||
created_type = OccupantTypes.find_or_create(
|
created_type = OccupantTypes.find_or_create(**list_occupant_type)
|
||||||
**{"is_confirmed": True, **list_occupant_type}
|
|
||||||
)
|
|
||||||
created_type.save()
|
created_type.save()
|
||||||
created_type.is_confirmed = True
|
created_type.is_confirmed = True
|
||||||
created_type.save()
|
created_type.save()
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ def get_build_living_space_from_json():
|
||||||
read_files = read_files_json.get("build_living_space")
|
read_files = read_files_json.get("build_living_space")
|
||||||
for row in read_files:
|
for row in read_files:
|
||||||
pydantic_row = InsertBuildLivingSpace(**row)
|
pydantic_row = InsertBuildLivingSpace(**row)
|
||||||
with_pydantic.append(pydantic_row.model_dump())
|
with_pydantic.append(pydantic_row.excluded_dump())
|
||||||
if not with_pydantic:
|
if not with_pydantic:
|
||||||
raise Exception("No data found")
|
raise Exception("No data found")
|
||||||
return with_pydantic
|
return with_pydantic
|
||||||
|
|
@ -109,12 +109,6 @@ def create_address(requester: BothAPIS, post_code):
|
||||||
print("post_code_response", post_code_response.text)
|
print("post_code_response", post_code_response.text)
|
||||||
response_post_code = post_code_response.json()
|
response_post_code = post_code_response.json()
|
||||||
response_post_code_uu_id = response_post_code["data"]["uu_id"]
|
response_post_code_uu_id = response_post_code["data"]["uu_id"]
|
||||||
requester.local_api.post(
|
|
||||||
endpoint=f"/postcode/update/{response_post_code_uu_id}",
|
|
||||||
data={
|
|
||||||
"is_confirmed": True,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
return response_post_code_uu_id
|
return response_post_code_uu_id
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -212,14 +206,14 @@ def migrate_build_iban(requester: BothAPIS, build_uu_id: str):
|
||||||
def migrate_build_living_space(requester: BothAPIS):
|
def migrate_build_living_space(requester: BothAPIS):
|
||||||
response_datas = get_build_living_space_from_json()
|
response_datas = get_build_living_space_from_json()
|
||||||
for response_data in response_datas:
|
for response_data in response_datas:
|
||||||
|
print("b response_data[person_uu_id]", response_data["person_uu_id"])
|
||||||
response = requester.local_api.post(
|
response = requester.local_api.post(
|
||||||
endpoint="/people/list",
|
endpoint="/people/list",
|
||||||
data={"page": 1, "size": 1, "query": {"ref_id": response_data.get("person_uu_id")}},
|
data={"page": 1, "size": 1, "query": {"ref_id": response_data["person_uu_id"]}},
|
||||||
)
|
)
|
||||||
print("/people/list response", response.text)
|
print("/people/list response", response.text)
|
||||||
|
|
||||||
response_data["person_uu_id"] = response.json()["data"][0]["uu_id"]
|
response_data["person_uu_id"] = response.json()["data"][0]["uu_id"]
|
||||||
|
print("a response_data[person_uu_id]", response_data["person_uu_id"])
|
||||||
response = requester.local_api.post(
|
response = requester.local_api.post(
|
||||||
endpoint="/building/parts/list",
|
endpoint="/building/parts/list",
|
||||||
data={"page": 1, "size": 30, "query": {"ref_id": response_data.get("build_parts_uu_id")}},
|
data={"page": 1, "size": 30, "query": {"ref_id": response_data.get("build_parts_uu_id")}},
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 17,
|
"id" : 17,
|
||||||
"uu_id" : "cb687f38-91e5-461b-a5b7-53cfe98d5ea1",
|
"uu_id" : "cb687f38-91e5-461b-a5b7-53cfe98d5ea1",
|
||||||
|
"emails" : "caglarcelik8822@gmail.com",
|
||||||
"ref_id" : "71c00e1f-2a3f-4c9d-922d-376647a1ca7f",
|
"ref_id" : "71c00e1f-2a3f-4c9d-922d-376647a1ca7f",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -121,6 +122,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 18,
|
"id" : 18,
|
||||||
"uu_id" : "2fa2d08e-69e3-4f3a-9104-d32e77411729",
|
"uu_id" : "2fa2d08e-69e3-4f3a-9104-d32e77411729",
|
||||||
|
"emails" : "Osmankilinc67@gmail.com",
|
||||||
"ref_id" : "9aa3064e-6db1-4f50-82c9-6130e7312a0c",
|
"ref_id" : "9aa3064e-6db1-4f50-82c9-6130e7312a0c",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -366,6 +368,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 28,
|
"id" : 28,
|
||||||
"uu_id" : "0d82e964-80fd-4c80-9f8d-5cac1d7a2f68",
|
"uu_id" : "0d82e964-80fd-4c80-9f8d-5cac1d7a2f68",
|
||||||
|
"emails" : "sozdirim@gmail.com",
|
||||||
"ref_id" : "eed3b880-fafa-4546-be39-4d3002c089ab",
|
"ref_id" : "eed3b880-fafa-4546-be39-4d3002c089ab",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -395,6 +398,7 @@
|
||||||
"father_name" : "",
|
"father_name" : "",
|
||||||
"mother_name" : "",
|
"mother_name" : "",
|
||||||
"country_code" : "TR",
|
"country_code" : "TR",
|
||||||
|
"emails" : "songulvar@gmail.com",
|
||||||
"national_identity_id" : "481b626f-b566-4c9e-9c2e-9fee5db440aa",
|
"national_identity_id" : "481b626f-b566-4c9e-9c2e-9fee5db440aa",
|
||||||
"birth_place" : "",
|
"birth_place" : "",
|
||||||
"birth_date" : "1899-12-31T21:00:00.000Z",
|
"birth_date" : "1899-12-31T21:00:00.000Z",
|
||||||
|
|
@ -436,6 +440,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 21,
|
"id" : 21,
|
||||||
"uu_id" : "36620cc9-eeaa-40e3-885d-e1ab0e8cc7d1",
|
"uu_id" : "36620cc9-eeaa-40e3-885d-e1ab0e8cc7d1",
|
||||||
|
"emails" : "berat.varnali@turktelekom.com.tr",
|
||||||
"ref_id" : "da53214e-49be-4b07-bc1a-c39c3fe44df1",
|
"ref_id" : "da53214e-49be-4b07-bc1a-c39c3fe44df1",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -471,6 +476,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 22,
|
"id" : 22,
|
||||||
"uu_id" : "ba23bb68-bd82-4022-855a-2c29c23e75a0",
|
"uu_id" : "ba23bb68-bd82-4022-855a-2c29c23e75a0",
|
||||||
|
"emails" : "iremyuksekol@gmail.com",
|
||||||
"ref_id" : "e1b9aea6-6787-4304-8a1f-dd712bcbea33",
|
"ref_id" : "e1b9aea6-6787-4304-8a1f-dd712bcbea33",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -540,6 +546,7 @@
|
||||||
"birth_date" : "1899-12-31T21:00:00.000Z",
|
"birth_date" : "1899-12-31T21:00:00.000Z",
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 31,
|
"id" : 31,
|
||||||
|
"emails" : "muberrabaltaci@hotmail.com",
|
||||||
"uu_id" : "312fe4ca-c6ba-47d5-b123-96c6e718e176",
|
"uu_id" : "312fe4ca-c6ba-47d5-b123-96c6e718e176",
|
||||||
"ref_id" : "a0d3a4e3-3081-43e8-ae71-063f216126e9",
|
"ref_id" : "a0d3a4e3-3081-43e8-ae71-063f216126e9",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -611,6 +618,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 33,
|
"id" : 33,
|
||||||
"uu_id" : "1ffc8ec9-6cd2-4bd5-bd33-fe29ff13b82f",
|
"uu_id" : "1ffc8ec9-6cd2-4bd5-bd33-fe29ff13b82f",
|
||||||
|
"emails" : "fatih707@hotmail.com",
|
||||||
"ref_id" : "41823bea-1b4c-4eb2-ae98-ca50f6af8b2e",
|
"ref_id" : "41823bea-1b4c-4eb2-ae98-ca50f6af8b2e",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -646,6 +654,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 34,
|
"id" : 34,
|
||||||
"uu_id" : "3f700961-30fc-441b-991e-4bba1b360496",
|
"uu_id" : "3f700961-30fc-441b-991e-4bba1b360496",
|
||||||
|
"emails" : "gulsermay@gmail.com",
|
||||||
"ref_id" : "122e627b-c6fe-46ac-b419-c26f5f418630",
|
"ref_id" : "122e627b-c6fe-46ac-b419-c26f5f418630",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -681,6 +690,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 12,
|
"id" : 12,
|
||||||
"uu_id" : "92dd0069-4627-44cb-9fa9-7e594ea81be6",
|
"uu_id" : "92dd0069-4627-44cb-9fa9-7e594ea81be6",
|
||||||
|
"emails" : "hcihans@gmail.com",
|
||||||
"ref_id" : "1940fb33-1eb6-4163-811b-89940302340a",
|
"ref_id" : "1940fb33-1eb6-4163-811b-89940302340a",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -716,6 +726,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 35,
|
"id" : 35,
|
||||||
"uu_id" : "b79aa7d7-4b3c-47a4-b71a-8ca9be9c168c",
|
"uu_id" : "b79aa7d7-4b3c-47a4-b71a-8ca9be9c168c",
|
||||||
|
"emails" : "mustafa_edepli@hotmail.com",
|
||||||
"ref_id" : "280d5b24-33e5-40bb-a278-1a4783f45205",
|
"ref_id" : "280d5b24-33e5-40bb-a278-1a4783f45205",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -751,6 +762,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 36,
|
"id" : 36,
|
||||||
"uu_id" : "1a81b4b3-fcc4-4c01-b7d0-f54dc3f7c9a6",
|
"uu_id" : "1a81b4b3-fcc4-4c01-b7d0-f54dc3f7c9a6",
|
||||||
|
"emails" : "selma.karatay@hotmail.com",
|
||||||
"ref_id" : "2c10f55d-4560-40c3-86f5-aedf38f084b5",
|
"ref_id" : "2c10f55d-4560-40c3-86f5-aedf38f084b5",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -891,6 +903,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 3,
|
"id" : 3,
|
||||||
"uu_id" : "691f73a4-02e4-49c0-a7e5-452232499479",
|
"uu_id" : "691f73a4-02e4-49c0-a7e5-452232499479",
|
||||||
|
"emails" : "mehmet.karatay@hotmail.com",
|
||||||
"ref_id" : "d2ae4c73-bcb9-4afe-9473-621f70f649cf",
|
"ref_id" : "d2ae4c73-bcb9-4afe-9473-621f70f649cf",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -921,6 +934,7 @@
|
||||||
"mother_name" : "",
|
"mother_name" : "",
|
||||||
"country_code" : "TR",
|
"country_code" : "TR",
|
||||||
"national_identity_id" : "d153bb50-4ce2-4da2-86bd-e5d00fe18d2f",
|
"national_identity_id" : "d153bb50-4ce2-4da2-86bd-e5d00fe18d2f",
|
||||||
|
"emails" : "erinckaratas@gmail.com",
|
||||||
"birth_place" : "",
|
"birth_place" : "",
|
||||||
"birth_date" : "1899-12-31T21:00:00.000Z",
|
"birth_date" : "1899-12-31T21:00:00.000Z",
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
|
|
@ -961,6 +975,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 13,
|
"id" : 13,
|
||||||
"uu_id" : "1ee7244f-6a99-4680-b8d9-880c61270261",
|
"uu_id" : "1ee7244f-6a99-4680-b8d9-880c61270261",
|
||||||
|
"emails" : "barisgkce@gmail.com",
|
||||||
"ref_id" : "25e89088-ef5d-443f-a151-898e961b68a0",
|
"ref_id" : "25e89088-ef5d-443f-a151-898e961b68a0",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -1031,6 +1046,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 62,
|
"id" : 62,
|
||||||
"uu_id" : "b1dcdb0d-d6a2-41a3-82e9-8ae29749c0d6",
|
"uu_id" : "b1dcdb0d-d6a2-41a3-82e9-8ae29749c0d6",
|
||||||
|
"emails" : "damlaayiker@gmail.com",
|
||||||
"ref_id" : "100940000000015",
|
"ref_id" : "100940000000015",
|
||||||
"created_at" : "2024-11-06T08:50:09.757Z",
|
"created_at" : "2024-11-06T08:50:09.757Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.757Z",
|
"updated_at" : "2024-11-06T08:50:09.757Z",
|
||||||
|
|
@ -1101,6 +1117,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 37,
|
"id" : 37,
|
||||||
"uu_id" : "48c2317d-17a6-4bf3-8798-db97d01f14db",
|
"uu_id" : "48c2317d-17a6-4bf3-8798-db97d01f14db",
|
||||||
|
"emails" : "arisoy2012@gmail.com",
|
||||||
"ref_id" : "1a5d7bdf-f24e-4b9c-91bb-955a09b965f3",
|
"ref_id" : "1a5d7bdf-f24e-4b9c-91bb-955a09b965f3",
|
||||||
"created_at" : "2024-11-06T08:50:09.747Z",
|
"created_at" : "2024-11-06T08:50:09.747Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.747Z",
|
"updated_at" : "2024-11-06T08:50:09.747Z",
|
||||||
|
|
@ -1276,6 +1293,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 72,
|
"id" : 72,
|
||||||
"uu_id" : "4087d0ad-24b7-4e9f-b4fd-065d8c2eb9c4",
|
"uu_id" : "4087d0ad-24b7-4e9f-b4fd-065d8c2eb9c4",
|
||||||
|
"emails" : "sinem@valor.com.tr",
|
||||||
"ref_id" : "100940000000025",
|
"ref_id" : "100940000000025",
|
||||||
"created_at" : "2024-11-06T08:50:09.757Z",
|
"created_at" : "2024-11-06T08:50:09.757Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.757Z",
|
"updated_at" : "2024-11-06T08:50:09.757Z",
|
||||||
|
|
@ -1346,6 +1364,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 75,
|
"id" : 75,
|
||||||
"uu_id" : "ad535cf7-c729-4db3-8051-0ff59ebdbca9",
|
"uu_id" : "ad535cf7-c729-4db3-8051-0ff59ebdbca9",
|
||||||
|
"emails" : "iletisim@smmmsimsek.com",
|
||||||
"ref_id" : "100940000000028",
|
"ref_id" : "100940000000028",
|
||||||
"created_at" : "2024-11-06T08:50:09.757Z",
|
"created_at" : "2024-11-06T08:50:09.757Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.757Z",
|
"updated_at" : "2024-11-06T08:50:09.757Z",
|
||||||
|
|
@ -1626,6 +1645,7 @@
|
||||||
"tax_no" : "",
|
"tax_no" : "",
|
||||||
"id" : 84,
|
"id" : 84,
|
||||||
"uu_id" : "56618f23-51af-444c-a6f7-87586833a5b4",
|
"uu_id" : "56618f23-51af-444c-a6f7-87586833a5b4",
|
||||||
|
"emails" : "fatihedepli@gmail.com",
|
||||||
"ref_id" : "100940000000037",
|
"ref_id" : "100940000000037",
|
||||||
"created_at" : "2024-11-06T08:50:09.757Z",
|
"created_at" : "2024-11-06T08:50:09.757Z",
|
||||||
"updated_at" : "2024-11-06T08:50:09.757Z",
|
"updated_at" : "2024-11-06T08:50:09.757Z",
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ def get_people_from_json():
|
||||||
read_files_json, with_pydantic = read_json_file(json_file="people"), []
|
read_files_json, with_pydantic = read_json_file(json_file="people"), []
|
||||||
read_files = read_files_json.get("people")
|
read_files = read_files_json.get("people")
|
||||||
for row in read_files:
|
for row in read_files:
|
||||||
|
row["ref_id"] = row["uu_id"]
|
||||||
pydantic_row = InsertPerson(**row)
|
pydantic_row = InsertPerson(**row)
|
||||||
with_pydantic.append(pydantic_row.model_dump())
|
with_pydantic.append(pydantic_row.model_dump())
|
||||||
if not with_pydantic:
|
if not with_pydantic:
|
||||||
|
|
@ -22,6 +23,7 @@ def get_people_from_json():
|
||||||
|
|
||||||
generate_random_national_identity_id = lambda n: str(random.randint(10 ** (n - 1), 10**n))
|
generate_random_national_identity_id = lambda n: str(random.randint(10 ** (n - 1), 10**n))
|
||||||
|
|
||||||
|
|
||||||
def migrate_people(requester: BothAPIS):
|
def migrate_people(requester: BothAPIS):
|
||||||
for response_data in get_people_from_json():
|
for response_data in get_people_from_json():
|
||||||
response_data["national_identity_id"] = generate_random_national_identity_id(11)
|
response_data["national_identity_id"] = generate_random_national_identity_id(11)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
|
import arrow
|
||||||
|
|
||||||
from service_app_test.bases import RequestToApi
|
from service_app_test.bases import RequestToApi
|
||||||
from service_app_test.api_configs import WagAPI, LocalAPI, BothAPIS
|
from service_app_test.api_configs import WagAPI, LocalAPI, BothAPIS
|
||||||
|
from service_app_test.test_application.evyos.decision_book import run_decision_book_depends
|
||||||
|
from service_app_test.test_application.evyos.decision_book_items import (
|
||||||
|
send_invitation_to_building_residents,
|
||||||
|
collect_invitation_to_building_residents,
|
||||||
|
assign_people_to_pre_or_wrt
|
||||||
|
)
|
||||||
from service_app_test.test_application.migrate_old_data.people import migrate_people
|
from service_app_test.test_application.migrate_old_data.people import migrate_people
|
||||||
from service_app_test.test_application.migrate_old_data.building import (
|
from service_app_test.test_application.migrate_old_data.building import (
|
||||||
migrate_build, migrate_build_living_space,
|
migrate_build, migrate_build_living_space,
|
||||||
|
|
@ -9,7 +16,7 @@ from service_app_test.test_application.migrate_old_data.company import migrate_c
|
||||||
from service_app_test.test_application.migrate_old_data.accounts import migrate_account_records
|
from service_app_test.test_application.migrate_old_data.accounts import migrate_account_records
|
||||||
|
|
||||||
|
|
||||||
password_token = ""
|
password_token = "CDWs5ASBD4LVbmhNeilKSqBLKjKKt0odOL9h6NY082xqwln7Bo1opvC12j07iP8Gx-vpJSpF5nqUWs-Q9klQUJ6uLc8vuPmVKYVCXE0nz2yU_xyFGOrlqrVro1FSZG1EXwWopuLA_gKH5qkiiQwI1tM3UDFLJjbnR4xjwnH4m6RHe0gYKOZbpkd-uxFxzYbw"
|
||||||
login_data = {
|
login_data = {
|
||||||
"domain": "evyos.com.tr",
|
"domain": "evyos.com.tr",
|
||||||
"access_key": "karatay.berkay.sup@evyos.com.tr",
|
"access_key": "karatay.berkay.sup@evyos.com.tr",
|
||||||
|
|
@ -25,6 +32,29 @@ login_data_wag = {
|
||||||
"password_token": "",
|
"password_token": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
login_creds_employee = {
|
||||||
|
"domain": "evyos.com.tr",
|
||||||
|
"access_key": "karatay.berkay.sup@evyos.com.tr",
|
||||||
|
"password": "string",
|
||||||
|
"remember_me": False,
|
||||||
|
"password_token": "z5nPguDu6PrY_94KlTGxGBCMcK6rZcDl5AGqO5aHWY7TcQF8LJGYikMQs9labvqdz5yM7vE_f8Zq_vqp00o3EnWwWCWhel-EsMcAujBKNRjV3jC_4xk0_1r_unIYogWAjz_spZipX6pncsch2ngvv0dpx4lHSiZ5QrDTA1RefQ",
|
||||||
|
}
|
||||||
|
access_key_president = "bmanco@example.net"
|
||||||
|
login_creds_occupant = {
|
||||||
|
"domain": "evyos.com.tr",
|
||||||
|
"access_key": access_key_president,
|
||||||
|
"password": "string",
|
||||||
|
"remember_me": False,
|
||||||
|
"password_token": "o_2Y_yXS-cl6MxLbzLrXQetXTlDLD3UBDTQNa_mBMyzSOVIgx3LGbnufLRJjd4g6BWFbwVgJIUxbK-Pi0R5dwxfVJKyoEeDdej40uRHSsElKR16nvnqgFB_BJ4nmyN0KSunZHra5NqHJor17EGExOSmlttZV5dC7vFsrc-GUkg",
|
||||||
|
}
|
||||||
|
wrt_creds_occupant = {
|
||||||
|
"domain": "evyos.com.tr",
|
||||||
|
"access_key": access_key_president,
|
||||||
|
"password": "string",
|
||||||
|
"remember_me": False,
|
||||||
|
"password_token": "",
|
||||||
|
}
|
||||||
|
|
||||||
wag_api = RequestToApi()
|
wag_api = RequestToApi()
|
||||||
wag_api.overwrite_base_url(base_url=WagAPI.base_url)
|
wag_api.overwrite_base_url(base_url=WagAPI.base_url)
|
||||||
wag_api.selected_object = wag_api.login_via_email_and_password(
|
wag_api.selected_object = wag_api.login_via_email_and_password(
|
||||||
|
|
@ -34,16 +64,81 @@ wag_api.selected_object = wag_api.login_via_email_and_password(
|
||||||
local_api = RequestToApi()
|
local_api = RequestToApi()
|
||||||
local_api.overwrite_base_url(base_url=LocalAPI.base_url)
|
local_api.overwrite_base_url(base_url=LocalAPI.base_url)
|
||||||
local_api.selected_object = local_api.login_via_email_and_password(
|
local_api.selected_object = local_api.login_via_email_and_password(
|
||||||
login_data=login_data, is_password_valid=True
|
login_data=login_data, is_password_valid=False
|
||||||
)
|
)
|
||||||
|
|
||||||
both_apis = BothAPIS()
|
both_apis = BothAPIS()
|
||||||
both_apis.wag_api = wag_api
|
both_apis.wag_api = wag_api
|
||||||
both_apis.local_api = local_api
|
both_apis.local_api = local_api
|
||||||
|
|
||||||
# migrate_company(requester=both_apis)
|
do_migrates = False
|
||||||
# migrate_people(requester=both_apis)
|
assign_people_to_create_item = -1
|
||||||
# migrate_build(requester=both_apis)
|
|
||||||
migrate_build_living_space(requester=both_apis)
|
|
||||||
|
|
||||||
# migrate_account_records(requester=both_apis)
|
# selection_list = None
|
||||||
|
selection_list = []
|
||||||
|
# selection_list = None
|
||||||
|
manager_token = ""
|
||||||
|
writers_token = manager_token
|
||||||
|
people_uu_id_list = []
|
||||||
|
list_of_attendees = []
|
||||||
|
|
||||||
|
|
||||||
|
if do_migrates:
|
||||||
|
migrate_company(requester=both_apis)
|
||||||
|
migrate_people(requester=both_apis)
|
||||||
|
migrate_build(requester=both_apis)
|
||||||
|
migrate_build_living_space(requester=both_apis)
|
||||||
|
migrate_account_records(requester=both_apis)
|
||||||
|
|
||||||
|
|
||||||
|
if assign_people_to_create_item == 0:
|
||||||
|
# local_api.post(
|
||||||
|
# endpoint="/building/living_space/create",
|
||||||
|
# data=dict(
|
||||||
|
# build_parts_uu_id="b23d32d2-e80c-4ca4-8d4a-bae6f710608c",
|
||||||
|
# person_uu_id="cf47be44-ec58-4585-be41-178160be5b7e",
|
||||||
|
# occupant_type_uu_id="30512a47-1b3e-4602-ac1a-75fcabb076b4",
|
||||||
|
# expiry_starts=arrow.now().date().__str__(),
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
|
||||||
|
local_api.selected_object = local_api.login_via_email_and_password(
|
||||||
|
login_data=login_creds_occupant,
|
||||||
|
is_password_valid=False,
|
||||||
|
selection_list=selection_list,
|
||||||
|
)
|
||||||
|
selected_decision_book_uu_id = run_decision_book_depends(requester=both_apis.local_api)
|
||||||
|
send_invitation = {
|
||||||
|
"build_decision_book_uu_id": selected_decision_book_uu_id,
|
||||||
|
"message": "Request for a Regular Building Meeting",
|
||||||
|
"planned_date": arrow.now().shift(days=2).date().__str__(),
|
||||||
|
}
|
||||||
|
send_invitation_to_building_residents(
|
||||||
|
send_invitation_dict=send_invitation, requester=both_apis.local_api
|
||||||
|
)
|
||||||
|
if assign_people_to_create_item == 1:
|
||||||
|
count = 17
|
||||||
|
list_of_attendees.insert(0, manager_token)
|
||||||
|
collect_invitation_to_building_residents(
|
||||||
|
attended_dict_list=list_of_attendees, attend_count=count + 1,
|
||||||
|
requester=both_apis.local_api
|
||||||
|
)
|
||||||
|
elif assign_people_to_create_item == 2:
|
||||||
|
assign_people_to_pre_or_wrt(
|
||||||
|
person_uu_id=people_uu_id_list[0],
|
||||||
|
manager_token=manager_token,
|
||||||
|
occupant_code="MT-VPR",
|
||||||
|
requester=both_apis.local_api
|
||||||
|
)
|
||||||
|
assign_people_to_pre_or_wrt(
|
||||||
|
person_uu_id=people_uu_id_list[1],
|
||||||
|
manager_token=manager_token,
|
||||||
|
occupant_code="MT-WRT",
|
||||||
|
requester=both_apis.local_api
|
||||||
|
)
|
||||||
|
assign_people_to_pre_or_wrt(
|
||||||
|
person_uu_id=people_uu_id_list[2],
|
||||||
|
manager_token=manager_token,
|
||||||
|
occupant_code="MT-PRS",
|
||||||
|
requester=both_apis.local_api
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue