services are checked

This commit is contained in:
2024-11-08 17:14:02 +03:00
parent a5b1e0b2f4
commit c5b771e5cb
82 changed files with 1720 additions and 869 deletions

View File

@@ -67,8 +67,12 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
creds: Credentials = None # The credentials to use in the model.
client_arrow: DateTimeLocal = None # The arrow to use in the model.
expiry_starts: Mapped[TIMESTAMP] = mapped_column(TIMESTAMP, server_default=func.now(), nullable=False)
expiry_ends: Mapped[TIMESTAMP] = mapped_column(TIMESTAMP, default="2099-12-31", server_default="2099-12-31")
expiry_starts: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default=func.now(), nullable=False
)
expiry_ends: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, default="2099-12-31", server_default="2099-12-31"
)
@classmethod
def extract_system_fields(cls, filter_kwargs: dict, create: bool = True):
@@ -76,7 +80,9 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
Extracts the system fields from the given attributes.
"""
system_fields = filter_kwargs.copy()
extract_fields = cls.__system__fields__create__ if create else cls.__system__fields__update__
extract_fields = (
cls.__system__fields__create__ if create else cls.__system__fields__update__
)
for field in extract_fields:
system_fields.pop(field, None)
return system_fields
@@ -84,6 +90,7 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
@classmethod
def find_or_create(cls, **kwargs):
from api_library.date_time_actions.date_functions import system_arrow
"""
Finds a record with the given attributes or creates it if it doesn't exist.
If found, sets is_found to True, otherwise False.
@@ -163,7 +170,9 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
self.flush()
return self
def get_dict(self, exclude: list = None, include: list = None, include_joins: list = None):
def get_dict(
self, exclude: list = None, include: list = None, include_joins: list = None
):
return_dict = {}
if exclude:
exclude.extend(list(set(self.__exclude__fields__).difference(exclude)))
@@ -263,4 +272,4 @@ class CrudCollection(CrudMixin, BaseMixin, SmartQueryMixin):
deleted: Mapped[bool] = mapped_column(Boolean, server_default="0")
active: Mapped[bool] = mapped_column(Boolean, server_default="1")
is_notification_send: Mapped[bool] = mapped_column(Boolean, server_default="0")
is_email_send: Mapped[bool] = mapped_column(Boolean, server_default="0")
is_email_send: Mapped[bool] = mapped_column(Boolean, server_default="0")