test application updated@build living space
This commit is contained in:
@@ -66,7 +66,6 @@ class EventBindOccupantEventMethods(MethodToEvent):
|
||||
|
||||
events_to_add_to_occupant = Events.filter_all(
|
||||
Events.uu_id.in_(list(data.event_uu_id_list)),
|
||||
*Events.valid_record_args(Events),
|
||||
)
|
||||
if not events_to_add_to_occupant.data:
|
||||
return JSONResponse(
|
||||
|
||||
@@ -30,19 +30,20 @@ class ModulesBindOccupantEventMethods(MethodToEvent):
|
||||
):
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(
|
||||
Modules.id == build_living_space_id,
|
||||
Modules.active == True,
|
||||
BuildLivingSpace.id == build_living_space_id,
|
||||
).data
|
||||
modules = Modules.filter_one(
|
||||
Modules.id == modules_id, Modules.active == True
|
||||
Modules.id == modules_id
|
||||
).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["expires_at"] = str(
|
||||
system_arrow.get(living_space.expiry_ends)
|
||||
)
|
||||
if not expires_at:
|
||||
if 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():
|
||||
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
|
||||
):
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(
|
||||
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
|
||||
service = Services.filter_one(Services.id == service_id).data
|
||||
add_events_list = Service2Events.filter_all(
|
||||
Service2Events.service_id == service.id,
|
||||
*Service2Events.valid_record_args(Service2Events),
|
||||
).data
|
||||
if not living_space:
|
||||
print("Living Space is not valid. Service is not binded")
|
||||
return
|
||||
if not add_events_list:
|
||||
raise Exception(
|
||||
"Service has no events registered. Please contact with your manager"
|
||||
)
|
||||
print(f"Service has no events registered. Please contact with your manager")
|
||||
return
|
||||
|
||||
event_ids_list = [
|
||||
{
|
||||
@@ -131,7 +128,6 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
||||
|
||||
service_events = Service2Events.filter_all(
|
||||
Service2Events.service_id == service.id,
|
||||
Service2Events.valid_record_args(Service2Events),
|
||||
).data
|
||||
if not service_events:
|
||||
raise HTTPException(
|
||||
@@ -143,7 +139,6 @@ 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.valid_record_args(BuildLivingSpace),
|
||||
).data
|
||||
if not living_space:
|
||||
return JSONResponse(
|
||||
@@ -197,7 +192,6 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
|
||||
).data
|
||||
service_events = Service2Events.filter_all(
|
||||
Service2Events.service_id == service.id,
|
||||
*Service2Events.valid_record_args(Service2Events),
|
||||
).data
|
||||
if not service_events:
|
||||
raise Exception(
|
||||
@@ -271,7 +265,6 @@ class ServiceBindEmployeeEventMethods(MethodToEvent):
|
||||
|
||||
service_events = Service2Events.filter_all(
|
||||
Service2Events.service_id == service.id,
|
||||
*Service2Events.valid_record_args(Service2Events),
|
||||
).data
|
||||
if not service_events:
|
||||
raise HTTPException(
|
||||
|
||||
@@ -37,9 +37,7 @@ class EventsListEventMethods(MethodToEvent):
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
Events.filter_attr = list_options
|
||||
records = Events.filter_all(
|
||||
*Events.valid_record_args(Events)
|
||||
)
|
||||
records = Events.filter_all()
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="DecisionBook are listed successfully",
|
||||
@@ -143,7 +141,6 @@ class EventsBindEventToOccupantMethods(MethodToEvent):
|
||||
def bind_events_employee(cls, data: RegisterEvents2Employee, token_dict):
|
||||
events = Events.filter_all(
|
||||
Events.uu_id.in_(data.event_id),
|
||||
*Events.valid_record_args(Events),
|
||||
).data
|
||||
if not events:
|
||||
raise HTTPException(
|
||||
@@ -153,16 +150,13 @@ class EventsBindEventToOccupantMethods(MethodToEvent):
|
||||
employee_is_not_valid = False
|
||||
employee = Employees.filter_one(
|
||||
Employees.employee_uu_id == data.employee_uu_id,
|
||||
*Employees.valid_record_args(Employees),
|
||||
).data
|
||||
if employee:
|
||||
staff = Staff.filter_one(
|
||||
Staff.id == employee.staff_id,
|
||||
*Staff.valid_record_args(Staff),
|
||||
).data
|
||||
duties = Duties.filter_one(
|
||||
Duties.id == staff.duties_id,
|
||||
*Duties.valid_record_args(Duties),
|
||||
).data
|
||||
if duties.company_id not in token_dict.companies_id_list:
|
||||
employee_is_not_valid = True
|
||||
@@ -196,7 +190,6 @@ class EventsBindEventToEmployeeMethods(MethodToEvent):
|
||||
def bind_events_occupant(cls, data: RegisterEvents2Occupant, token_dict):
|
||||
events = Events.filter_all(
|
||||
Events.uu_id.in_(data.event_id),
|
||||
*Events.valid_record_args(Events),
|
||||
).data
|
||||
if not events:
|
||||
raise HTTPException(
|
||||
@@ -205,7 +198,6 @@ class EventsBindEventToEmployeeMethods(MethodToEvent):
|
||||
)
|
||||
occupant = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.uu_id == data.build_living_space_uu_id,
|
||||
*BuildLivingSpace.valid_record_args(BuildLivingSpace),
|
||||
).data
|
||||
if not occupant:
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user