alchemy functions updated
This commit is contained in:
@@ -417,7 +417,7 @@ class BuildDecisionBookPerson(CrudCollection):
|
||||
if build_living_space_id:
|
||||
related_service = Services.filter_by_one(
|
||||
related_responsibility=str(occupant_type.occupant_code),
|
||||
*Services.valid_record_dict
|
||||
*Services.valid_record_dict,
|
||||
)
|
||||
if not related_service:
|
||||
raise HTTPException(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
from typing import Union
|
||||
|
||||
from sqlalchemy import (
|
||||
TIMESTAMP,
|
||||
@@ -23,6 +24,7 @@ from sqlalchemy_mixins.repr import ReprMixin
|
||||
from sqlalchemy_mixins.smartquery import SmartQueryMixin
|
||||
|
||||
from api_library.date_time_actions.date_functions import DateTimeLocal, client_arrow
|
||||
from api_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_objects.auth.token_objects import Credentials
|
||||
|
||||
from databases.sql_models.sql_operations import FilterAttributes
|
||||
@@ -90,6 +92,13 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
|
||||
TIMESTAMP, default="2099-12-31", server_default="2099-12-31"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def set_user_define_properties(
|
||||
cls, token: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
cls.creds = token.credentials
|
||||
cls.client_arrow = DateTimeLocal(is_client=True, timezone=token.timezone)
|
||||
|
||||
@classmethod
|
||||
def remove_non_related_inputs(cls, kwargs):
|
||||
"""
|
||||
|
||||
@@ -182,13 +182,12 @@ class Event2Occupant(CrudCollection):
|
||||
cls, build_living_space_id
|
||||
) -> (list, list):
|
||||
active_events = cls.filter_all(
|
||||
cls.build_living_space_id==build_living_space_id,
|
||||
*cls.valid_record_args(cls)
|
||||
cls.build_living_space_id == build_living_space_id,
|
||||
*cls.valid_record_args(cls),
|
||||
).data
|
||||
active_events_id = [event.event_id for event in active_events]
|
||||
active_events = Events.filter_all(
|
||||
Events.id.in_(active_events_id),
|
||||
*Events.valid_record_args(Events)
|
||||
Events.id.in_(active_events_id), *Events.valid_record_args(Events)
|
||||
).data
|
||||
active_events_uu_id = [str(event.uu_id) for event in active_events]
|
||||
return active_events_id, active_events_uu_id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from api_library.date_time_actions.date_functions import DateTimeLocal
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_configs import Auth, ApiStatic, RelationAccess
|
||||
|
||||
from datetime import timedelta
|
||||
@@ -37,7 +37,7 @@ class UsersTokens(CrudCollection):
|
||||
token_type: Mapped[str] = mapped_column(String(16), server_default="RememberMe")
|
||||
token: Mapped[str] = mapped_column(String, server_default="")
|
||||
domain: Mapped[str] = mapped_column(String, server_default="")
|
||||
expires_at = mapped_column(TIMESTAMP, default=str(DateTimeLocal.shift(days=3)))
|
||||
expires_at = mapped_column(TIMESTAMP, default=str(system_arrow.shift(days=3)))
|
||||
|
||||
# users = relationship("Users", back_populates="tokens", foreign_keys=[user_id])
|
||||
|
||||
@@ -137,7 +137,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
||||
@classmethod
|
||||
def create_action(cls, create_user: InsertUsers):
|
||||
found_person = People.filter_one(
|
||||
People.uu_id==create_user.people_uu_id,
|
||||
People.uu_id == create_user.people_uu_id,
|
||||
*People.valid_record_args(People),
|
||||
).data
|
||||
if not found_person:
|
||||
|
||||
Reference in New Issue
Block a user