alchemy functions updated

This commit is contained in:
2024-11-10 13:36:52 +03:00
parent eb947ecb3d
commit be100a6615
18 changed files with 83 additions and 61 deletions

View File

@@ -66,7 +66,7 @@ class EventBindOccupantEventMethods(MethodToEvent):
events_to_add_to_occupant = Events.filter_all(
Events.uu_id.in_(list(data.event_uu_id_list)),
Events.active == True,
*Events.valid_record_args(Events)
)
if not events_to_add_to_occupant.data:
return JSONResponse(

View File

@@ -38,15 +38,15 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
living_space = BuildLivingSpace.filter_one(
BuildLivingSpace.id == build_living_space_id,
BuildLivingSpace.active == True,
*BuildLivingSpace.valid_record_args(BuildLivingSpace)
).data
service = Services.filter_one(
Services.id == service_id,
Services.active == True,
*Services.valid_record_args(Services)
).data
add_events_list = Service2Events.filter_all(
Service2Events.service_id == service.id,
Service2Events.active == True,
*Service2Events.valid_record_args(Service2Events)
).data
if not add_events_list:
raise Exception(
@@ -106,7 +106,7 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
status_code=status.HTTP_404_NOT_FOUND,
)
occupant_occupant_type = OccupantTypes.filter_by_one(uu_id=data.occupant_uu_id)
occupant_occupant_type = OccupantTypes.filter_by_one(uu_id=data.occupant_uu_id).data
if not occupant_occupant_type:
return JSONResponse(
content={
@@ -130,7 +130,7 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
service_events = Service2Events.filter_all(
Service2Events.service_id == service.id,
Service2Events.active == True,
Service2Events.valid_record_args(Service2Events),
).data
if not service_events:
raise HTTPException(
@@ -142,7 +142,7 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
BuildLivingSpace.build_parts_id == occupants_build_part.id,
BuildLivingSpace.occupant_types_id == occupant_occupant_type.id,
BuildLivingSpace.person_id == token_dict.person_id,
BuildLivingSpace.active == True,
*BuildLivingSpace.valid_record_args(BuildLivingSpace)
).data
if not living_space:
return JSONResponse(
@@ -188,11 +188,11 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
def bind_services_employee(cls, service_id: int, employee_id: int):
from sqlalchemy.dialects.postgresql import insert
employee = Employees.filter_by_one(id=employee_id, *Employees.valid_record_dict)
service = Services.filter_by_one(id=service_id, *Services.valid_record_dict)
employee = Employees.filter_by_one(id=employee_id, *Employees.valid_record_dict).data
service = Services.filter_by_one(id=service_id, *Services.valid_record_dict).data
service_events = Service2Events.filter_all(
Service2Events.service_id == service.id,
Service2Events.active == True,
*Service2Events.valid_record_args(Service2Events),
).data
if not service_events:
raise Exception(
@@ -263,7 +263,7 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
service_events = Service2Events.filter_all(
Service2Events.service_id == service.id,
Service2Events.active == True,
*Service2Events.valid_record_args(Service2Events)
).data
if not service_events:
raise HTTPException(

View File

@@ -83,7 +83,7 @@ class EventsUpdateEventMethods(MethodToEvent):
@classmethod
def events_update(cls, data: CreateEvents, token_dict):
event = Events.filter_by_one(uu_id=data.uu_id, *Events.valid_record_dict)
event = Events.filter_by_one(uu_id=data.uu_id, *Events.valid_record_dict).data
if not event:
raise HTTPException(
status_code=404,
@@ -113,7 +113,7 @@ class EventsPatchEventMethods(MethodToEvent):
@classmethod
def events_patch(cls, data: CreateEvents, token_dict):
event = Events.filter_by_one(uu_id=data.uu_id, *Events.valid_record_dict)
event = Events.filter_by_one(uu_id=data.uu_id, *Events.valid_record_dict).data
if not event:
raise HTTPException(
status_code=404,