services are checked
This commit is contained in:
@@ -26,7 +26,9 @@ class EventBindOccupantEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def bind_events_occupant_super_user(
|
||||
cls, data: RegisterEvents2Occupant, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: RegisterEvents2Occupant,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
|
||||
if not str(token_dict.user_type) == "1":
|
||||
@@ -138,7 +140,9 @@ class EventBindEmployeeEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def bind_events_employee(
|
||||
cls, data: RegisterEvents2Occupant, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
cls,
|
||||
data: RegisterEvents2Occupant,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
return token_dict.available_event(data=data, token_dict=token_dict)
|
||||
|
||||
|
||||
@@ -4,10 +4,15 @@ from databases import (
|
||||
Modules,
|
||||
BuildLivingSpace,
|
||||
)
|
||||
from api_validations.validations_request import RegisterModules2Occupant, RegisterModules2Employee
|
||||
from api_validations.validations_request import (
|
||||
RegisterModules2Occupant,
|
||||
RegisterModules2Employee,
|
||||
)
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_events.events.events.events_bind_services import ServiceBindOccupantEventMethods
|
||||
from api_events.events.events.events_bind_services import (
|
||||
ServiceBindOccupantEventMethods,
|
||||
)
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
|
||||
@@ -24,11 +29,15 @@ class ModulesBindOccupantEventMethods(MethodToEvent):
|
||||
cls, build_living_space_id: int, modules_id: int, expires_at: str = None
|
||||
):
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(Modules.id==build_living_space_id).data
|
||||
modules = Modules.filter_one(Modules.id==modules_id).data
|
||||
living_space = BuildLivingSpace.filter_one(
|
||||
Modules.id == build_living_space_id
|
||||
).data
|
||||
modules = Modules.filter_one(Modules.id == modules_id).data
|
||||
|
||||
service_build_dict = dict(build_living_space_id=living_space.id)
|
||||
service_build_dict["expires_at"] = str(system_arrow.get(living_space.expiry_ends))
|
||||
service_build_dict["expires_at"] = str(
|
||||
system_arrow.get(living_space.expiry_ends)
|
||||
)
|
||||
if not expires_at:
|
||||
service_build_dict["expires_at"] = str(system_arrow.get(expires_at))
|
||||
|
||||
@@ -71,4 +80,4 @@ ModulesBindOccupantEventMethod = ModulesBindOccupantEventMethods(
|
||||
)
|
||||
ModulesBindEmployeeEventMethod = ModulesBindEmployeeEventMethods(
|
||||
action=ActionsSchema(endpoint="/bind/modules/employee")
|
||||
)
|
||||
)
|
||||
|
||||
@@ -15,7 +15,10 @@ from databases import (
|
||||
Event2Employee,
|
||||
Event2Occupant,
|
||||
)
|
||||
from api_validations.validations_request import RegisterServices2Occupant, RegisterServices2Employee
|
||||
from api_validations.validations_request import (
|
||||
RegisterServices2Occupant,
|
||||
RegisterServices2Employee,
|
||||
)
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import return_json_response_from_alchemy
|
||||
@@ -33,9 +36,13 @@ class ServiceBindOccupantEventMethods(MethodToEvent):
|
||||
):
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
|
||||
living_space = BuildLivingSpace.filter_one(BuildLivingSpace.id==build_living_space_id)
|
||||
service = Services.filter_one(Services.id==service_id)
|
||||
add_events_list = Service2Events.filter_all(Service2Events.service_id == service.id).data
|
||||
living_space = BuildLivingSpace.filter_one(
|
||||
BuildLivingSpace.id == build_living_space_id
|
||||
)
|
||||
service = Services.filter_one(Services.id == service_id)
|
||||
add_events_list = Service2Events.filter_all(
|
||||
Service2Events.service_id == service.id
|
||||
).data
|
||||
if not add_events_list:
|
||||
raise Exception(
|
||||
"Service has no events registered. Please contact with your manager"
|
||||
|
||||
@@ -31,7 +31,11 @@ class EventsListEventMethods(MethodToEvent):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def events_list(cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]):
|
||||
def events_list(
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
records = Events.filter_active(
|
||||
*Events.get_smart_query(list_options.query),
|
||||
)
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
from api_validations.validations_request import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
from api_validations.validations_request import DepartmentsPydantic, PatchRecord, ListOptions
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
Reference in New Issue
Block a user