updated
This commit is contained in:
parent
637edfadd4
commit
b4b9f97690
|
|
@ -348,29 +348,28 @@ class Event2Occupant(CrudCollection):
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_event_codes(cls, build_living_space_id) -> list:
|
def get_event_codes(cls, build_living_space_id, db_session) -> list:
|
||||||
db = cls.new_session()
|
|
||||||
occupant_events = cls.filter_all(
|
occupant_events = cls.filter_all(
|
||||||
cls.build_living_space_id == build_living_space_id,
|
cls.build_living_space_id == build_living_space_id,
|
||||||
db=db,
|
db=db_session,
|
||||||
).data
|
).data
|
||||||
active_event_ids = Service2Events.filter_all_system(
|
active_event_ids = Service2Events.filter_all_system(
|
||||||
Service2Events.service_id.in_(
|
Service2Events.service_id.in_(
|
||||||
[event.event_service_id for event in occupant_events]
|
[event.event_service_id for event in occupant_events]
|
||||||
),
|
),
|
||||||
db=db,
|
db=db_session,
|
||||||
).data
|
).data
|
||||||
active_events = Events.filter_all(
|
active_events = Events.filter_all(
|
||||||
Events.id.in_([event.event_id for event in active_event_ids]),
|
Events.id.in_([event.event_id for event in active_event_ids]),
|
||||||
db=db,
|
db=db_session,
|
||||||
).data
|
).data
|
||||||
if extra_events := Event2OccupantExtra.filter_all(
|
if extra_events := Event2OccupantExtra.filter_all(
|
||||||
Event2OccupantExtra.build_living_space_id == build_living_space_id,
|
Event2OccupantExtra.build_living_space_id == build_living_space_id,
|
||||||
db=db,
|
db=db_session,
|
||||||
).data:
|
).data:
|
||||||
events_extra = Events.filter_all(
|
events_extra = Events.filter_all(
|
||||||
Events.id.in_([event.event_id for event in extra_events]),
|
Events.id.in_([event.event_id for event in extra_events]),
|
||||||
db=db,
|
db=db_session,
|
||||||
).data
|
).data
|
||||||
active_events.extend(events_extra)
|
active_events.extend(events_extra)
|
||||||
return [event.function_code for event in active_events]
|
return [event.function_code for event in active_events]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
|
|
||||||
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
|
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
|
||||||
|
|
@ -12,6 +12,7 @@ from ApiLayers.ApiValidations.Response.default_response import (
|
||||||
EndpointNotAcceptableResponse,
|
EndpointNotAcceptableResponse,
|
||||||
EndpointBadRequestResponse,
|
EndpointBadRequestResponse,
|
||||||
)
|
)
|
||||||
|
from ApiLayers.AllConfigs.Redis.configs import RedisAuthKeys
|
||||||
from ApiLayers.ErrorHandlers import HTTPExceptionApi
|
from ApiLayers.ErrorHandlers import HTTPExceptionApi
|
||||||
from ApiLayers.Schemas import (
|
from ApiLayers.Schemas import (
|
||||||
BuildLivingSpace,
|
BuildLivingSpace,
|
||||||
|
|
@ -29,9 +30,9 @@ from ApiLayers.Schemas import (
|
||||||
Users,
|
Users,
|
||||||
UsersTokens,
|
UsersTokens,
|
||||||
)
|
)
|
||||||
|
|
||||||
from Events.base_request_model import TokenDictType, BaseRouteModel
|
from Events.base_request_model import TokenDictType, BaseRouteModel
|
||||||
from Services.RedisService.Actions.actions import RedisActions
|
from Services.RedisService.Actions.actions import RedisActions
|
||||||
from ApiLayers.AllConfigs.Redis.configs import RedisAuthKeys
|
|
||||||
|
|
||||||
|
|
||||||
class Handlers:
|
class Handlers:
|
||||||
|
|
@ -158,7 +159,7 @@ class Handlers:
|
||||||
|
|
||||||
# Get reachable events
|
# Get reachable events
|
||||||
reachable_event_codes = Event2Occupant.get_event_codes(
|
reachable_event_codes = Event2Occupant.get_event_codes(
|
||||||
build_living_space_id=selected_build_living_space.id
|
build_living_space_id=selected_build_living_space.id, db_session=db
|
||||||
)
|
)
|
||||||
occupant_type = OccupantTypes.filter_one_system(
|
occupant_type = OccupantTypes.filter_one_system(
|
||||||
OccupantTypes.id == selected_build_living_space.occupant_type_id,
|
OccupantTypes.id == selected_build_living_space.occupant_type_id,
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,17 @@ Validation function handlers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Dict, Any, Optional
|
from typing import Dict, Any, Optional
|
||||||
from fastapi import Request
|
|
||||||
|
|
||||||
from ApiLayers.AllConfigs.Redis.configs import (
|
from ApiLayers.AllConfigs.Redis.configs import (
|
||||||
RedisCategoryKeys,
|
RedisCategoryKeys,
|
||||||
RedisValidationKeysAction,
|
RedisValidationKeysAction,
|
||||||
RedisCategoryPageInfoKeysAction,
|
RedisCategoryPageInfoKeysAction,
|
||||||
)
|
)
|
||||||
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
|
|
||||||
from ApiLayers.ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi
|
|
||||||
from Services.RedisService.Actions.actions import RedisActions
|
from Services.RedisService.Actions.actions import RedisActions
|
||||||
from Events.base_request_model import BaseRouteModel
|
from Events.base_request_model import BaseRouteModel
|
||||||
|
|
||||||
from config import ValidationsConfig
|
from ApiLayers.AllConfigs.Api.config import ValidationsConfig
|
||||||
|
|
||||||
|
|
||||||
class ValidateBase:
|
class ValidateBase:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue