updated login/select

This commit is contained in:
2025-01-27 21:43:36 +03:00
parent b88f910a43
commit c0bd9c1685
18 changed files with 257 additions and 275 deletions

View File

@@ -256,12 +256,11 @@ class Event2Employee(CrudCollection):
cls.employee_id == employee_id,
db=db,
).data
active_event_ids = Service2Events.filter_all(
active_event_ids = Service2Events.filter_all_system(
Service2Events.service_id.in_(
[event.event_service_id for event in employee_events]
),
db=db,
system=True,
).data
active_events = Events.filter_all(
Events.id.in_([event.event_id for event in active_event_ids]),
@@ -278,41 +277,41 @@ class Event2Employee(CrudCollection):
active_events.extend(events_extra)
return [event.function_code for event in active_events]
@classmethod
def get_event_endpoints(cls, employee_id: int) -> list:
from Schemas import EndpointRestriction
db = cls.new_session()
employee_events = cls.filter_all(
cls.employee_id == employee_id,
db=db,
).data
active_event_ids = Service2Events.filter_all(
Service2Events.service_id.in_(
[event.event_service_id for event in employee_events]
),
db=db,
system=True,
).data
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:
events_extra = Events.filter_all(
Events.id.in_([event.event_id for event in extra_events]),
db=db,
).data
active_events.extend(events_extra)
endpoint_restrictions = EndpointRestriction.filter_all(
EndpointRestriction.id.in_([event.endpoint_id for event in active_events]),
db=db,
).data
return [event.endpoint_name for event in endpoint_restrictions]
# @classmethod
# def get_event_endpoints(cls, employee_id: int) -> list:
# from Schemas import EndpointRestriction
#
# db = cls.new_session()
# employee_events = cls.filter_all(
# cls.employee_id == employee_id,
# db=db,
# ).data
# active_event_ids = Service2Events.filter_all(
# Service2Events.service_id.in_(
# [event.event_service_id for event in employee_events]
# ),
# db=db,
# system=True,
# ).data
# 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:
# events_extra = Events.filter_all(
# Events.id.in_([event.event_id for event in extra_events]),
# db=db,
# ).data
# active_events.extend(events_extra)
# endpoint_restrictions = EndpointRestriction.filter_all(
# EndpointRestriction.id.in_([event.endpoint_id for event in active_events]),
# db=db,
# ).data
# return [event.endpoint_name for event in endpoint_restrictions]
#
class Event2Occupant(CrudCollection):
"""
@@ -355,12 +354,11 @@ class Event2Occupant(CrudCollection):
cls.build_living_space_id == build_living_space_id,
db=db,
).data
active_event_ids = Service2Events.filter_all(
active_event_ids = Service2Events.filter_all_system(
Service2Events.service_id.in_(
[event.event_service_id for event in occupant_events]
),
db=db,
system=True,
).data
active_events = Events.filter_all(
Events.id.in_([event.event_id for event in active_event_ids]),
@@ -377,40 +375,40 @@ class Event2Occupant(CrudCollection):
active_events.extend(events_extra)
return [event.function_code for event in active_events]
@classmethod
def get_event_endpoints(cls, build_living_space_id) -> list:
from Schemas import EndpointRestriction
db = cls.new_session()
occupant_events = cls.filter_all(
cls.build_living_space_id == build_living_space_id,
db=db,
).data
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 = 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,
db=db,
).data:
events_extra = Events.filter_all(
Events.id.in_([event.event_id for event in extra_events]),
db=db,
).data
active_events.extend(events_extra)
endpoint_restrictions = EndpointRestriction.filter_all(
EndpointRestriction.id.in_([event.endpoint_id for event in active_events]),
db=db,
).data
return [event.endpoint_name for event in endpoint_restrictions]
# @classmethod
# def get_event_endpoints(cls, build_living_space_id) -> list:
# from Schemas import EndpointRestriction
#
# db = cls.new_session()
# occupant_events = cls.filter_all(
# cls.build_living_space_id == build_living_space_id,
# db=db,
# ).data
# 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 = 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,
# db=db,
# ).data:
# events_extra = Events.filter_all(
# Events.id.in_([event.event_id for event in extra_events]),
# db=db,
# ).data
# active_events.extend(events_extra)
# endpoint_restrictions = EndpointRestriction.filter_all(
# EndpointRestriction.id.in_([event.endpoint_id for event in active_events]),
# db=db,
# ).data
# return [event.endpoint_name for event in endpoint_restrictions]
class ModulePrice(CrudCollection):