auth updated availaible event

This commit is contained in:
2024-12-06 16:35:25 +03:00
parent 88309eb49d
commit 9e955841c3
9 changed files with 51 additions and 34 deletions

View File

@@ -44,23 +44,18 @@ def endpoint_restriction_update(request: Request, data: UpdateEndpointAccessList
def endpoint_restriction_list(request: Request):
token_dict, records = parse_token_object_to_dict(request=request), []
if isinstance(token_dict, OccupantTokenObject):
occupant_events = Event2Occupant.filter_all(
Event2Occupant.build_living_space_id
== token_dict.selected_occupant.living_space_id
).data
events_list = Events.filter_all(
Events.id.in_([event.event_id for event in occupant_events])
).data
occupant_events = Event2Occupant.get_event_id_by_build_living_space_id(
build_living_space_id=token_dict.selected_occupant.living_space_id
)
events_list = Events.filter_all(Events.id.in_(occupant_events)).data
records = EndpointRestriction.filter_all(
EndpointRestriction.id.in_([event.endpoint_id for event in events_list])
).data
elif isinstance(token_dict, EmployeeTokenObject):
employee_events = Event2Employee.filter_all(
Event2Employee.employee_id == token_dict.selected_company.employee_id
).data
events_list = Events.filter_all(
Events.id.in_([event.event_id for event in employee_events])
).data
employee_events = Event2Employee.get_event_id_by_employee_id(
employee_id=token_dict.selected_company.employee_id
)
events_list = Events.filter_all(Events.id.in_(employee_events)).data
records = EndpointRestriction.filter_all(
EndpointRestriction.id.in_([event.endpoint_id for event in events_list])
).data