validations updated

This commit is contained in:
2025-01-19 21:06:00 +03:00
parent d6785ed36f
commit 8e34497c80
49 changed files with 2642 additions and 142 deletions

View File

@@ -250,26 +250,33 @@ class Event2Employee(CrudCollection):
)
@classmethod
def get_event_id_by_employee_id(cls, employee_id) -> list:
def get_event_codes(cls, employee_id: int) -> list:
db = cls.new_session()
occupant_events = cls.filter_all(
employee_events = cls.filter_all(
cls.employee_id == employee_id,
db=db,
).data
active_events = Service2Events.filter_all(
active_event_ids = Service2Events.filter_all(
Service2Events.service_id.in_(
[event.event_service_id for event in occupant_events]
[event.event_service_id for event in employee_events]
),
db=db,
system=True,
).data
active_events_id = [event.event_id for event in active_events]
active_events = Events.filter_all(
Events.id.in_([event.event_id for event in active_event_ids]),
db=db,
).data
if extra_events := Event2EmployeeExtra.filter_all(
Event2EmployeeExtra.employee_id == employee_id,
db=db,
).data:
active_events_id.extend([event.event_id for event in extra_events])
return active_events_id
events_extra = Events.filter_all(
Events.id.in_([event.event_id for event in extra_events]),
db=db,
).data
active_events.extend(events_extra)
return [event.function_code for event in active_events]
class Event2Occupant(CrudCollection):
@@ -307,22 +314,33 @@ class Event2Occupant(CrudCollection):
)
@classmethod
def get_event_id_by_build_living_space_id(cls, build_living_space_id) -> list:
def get_event_codes(cls, build_living_space_id) -> list:
db = cls.new_session()
occupant_events = cls.filter_all(
cls.build_living_space_id == build_living_space_id,
db=db,
).data
active_events = Service2Events.filter_all(
active_event_ids = Service2Events.filter_all(
Service2Events.service_id.in_(
[event.event_service_id for event in occupant_events]
),
db=db,
system=True,
).data
active_events_id = [event.event_id for event in active_events]
active_events = Events.filter_all(
Events.id.in_([event.event_id for event in active_event_ids]),
db=db,
).data
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,
).data:
active_events_id.extend([event.event_id for event in extra_events])
return active_events_id
events_extra = Events.filter_all(
Events.id.in_([event.event_id for event in extra_events]),
db=db,
).data
active_events.extend(events_extra)
return [event.function_code for event in active_events]
class ModulePrice(CrudCollection):