arpakitlib 1.8.63__py3-none-any.whl → 1.8.66__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/check_sqlalchemy_db.py +4 -12
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/clear_log_file.py +3 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/create_operation.py +5 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_arpakitlib_project_template_info.py +4 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_auth_data.py +4 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation.py +2 -8
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_statuses.py +2 -10
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_types.py +2 -10
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_settings.py +4 -11
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_sqlalchemy_db_table_name_to_amount.py +4 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_story_log.py +2 -8
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_user.py +2 -8
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/init_sqlalchemy_db.py +3 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/make_test_data_1.py +3 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/reinit_sqlalchemy_db.py +3 -9
- arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user.py +2 -8
- arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user_token.py +16 -5
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/check_authorization.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/get_current_api_key.py +2 -8
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/get_errors_info.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/healthcheck.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/now_utc_datetime.py +2 -8
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/common.py +0 -11
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/common.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/operation.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/story_log.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/user.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/common.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/user.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/user_token.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/common/ok.py +5 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/api_key.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/common.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/user.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/user_token.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/user_token.py +0 -4
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/blank/admin.py +3 -7
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/kb/inline_/client/hello_world.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/kb/static_/client/hello_world.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/about.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/author.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/error_handler.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/healthcheck.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/hello_world.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/raw_callback_query.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/raw_message.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/start.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/support.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/util/set_tg_bot_commands.py +1 -1
- arpakitlib/ar_sqlalchemy_util.py +31 -80
- {arpakitlib-1.8.63.dist-info → arpakitlib-1.8.66.dist-info}/METADATA +1 -1
- {arpakitlib-1.8.63.dist-info → arpakitlib-1.8.66.dist-info}/RECORD +56 -55
- /arpakitlib/_arpakit_project_template_v_5/project/tg_bot/blank/{general.py → client.py} +0 -0
- {arpakitlib-1.8.63.dist-info → arpakitlib-1.8.66.dist-info}/LICENSE +0 -0
- {arpakitlib-1.8.63.dist-info → arpakitlib-1.8.66.dist-info}/WHEEL +0 -0
- {arpakitlib-1.8.63.dist-info → arpakitlib-1.8.66.dist-info}/entry_points.txt +0 -0
@@ -3,16 +3,10 @@ from fastapi import APIRouter
|
|
3
3
|
|
4
4
|
from project.api.authorize import APIAuthorizeData, api_authorize, require_user_token_dbm_api_authorize_middleware, \
|
5
5
|
require_api_key_dbm_api_authorize_middleware
|
6
|
-
from project.api.schema.common import BaseRouteSO
|
7
6
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
7
|
from project.api.schema.out.general.api_key import ApiKey1GeneralSO
|
9
8
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
10
9
|
|
11
|
-
|
12
|
-
class GetCurrentApiKeyGeneralRouteSO(BaseRouteSO, ApiKey1GeneralSO):
|
13
|
-
pass
|
14
|
-
|
15
|
-
|
16
10
|
api_router = APIRouter()
|
17
11
|
|
18
12
|
|
@@ -20,7 +14,7 @@ api_router = APIRouter()
|
|
20
14
|
"",
|
21
15
|
name="Get current api key",
|
22
16
|
status_code=fastapi.status.HTTP_200_OK,
|
23
|
-
response_model=
|
17
|
+
response_model=ApiKey1GeneralSO | str | ErrorCommonSO,
|
24
18
|
)
|
25
19
|
async def _(
|
26
20
|
*,
|
@@ -36,6 +30,6 @@ async def _(
|
|
36
30
|
)
|
37
31
|
]))
|
38
32
|
):
|
39
|
-
return
|
33
|
+
return ApiKey1GeneralSO.from_dbm(
|
40
34
|
simple_dbm=api_auth_data.api_key_dbm
|
41
35
|
)
|
@@ -3,11 +3,11 @@ from fastapi import APIRouter
|
|
3
3
|
|
4
4
|
from project.api.authorize import APIAuthorizeData, api_authorize, require_api_key_dbm_api_authorize_middleware
|
5
5
|
from project.api.const import APIErrorCodes, APIErrorSpecificationCodes
|
6
|
-
from project.api.schema.common import
|
6
|
+
from project.api.schema.common import BaseSO
|
7
7
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
8
|
|
9
9
|
|
10
|
-
class
|
10
|
+
class _GetErrorsInfoGeneralSO(BaseSO):
|
11
11
|
api_error_codes: list[str] = []
|
12
12
|
api_error_specification_codes: list[str] = []
|
13
13
|
|
@@ -19,7 +19,7 @@ api_router = APIRouter()
|
|
19
19
|
"",
|
20
20
|
name="Get errors info",
|
21
21
|
status_code=fastapi.status.HTTP_200_OK,
|
22
|
-
response_model=
|
22
|
+
response_model=_GetErrorsInfoGeneralSO | ErrorCommonSO,
|
23
23
|
)
|
24
24
|
async def _(
|
25
25
|
*,
|
@@ -31,7 +31,7 @@ async def _(
|
|
31
31
|
)
|
32
32
|
]))
|
33
33
|
):
|
34
|
-
return
|
34
|
+
return _GetErrorsInfoGeneralSO(
|
35
35
|
api_error_codes=APIErrorCodes.values_list(),
|
36
36
|
api_error_specification_codes=APIErrorSpecificationCodes.values_list()
|
37
37
|
)
|
@@ -3,12 +3,12 @@ import datetime as dt
|
|
3
3
|
import fastapi
|
4
4
|
from fastapi import APIRouter
|
5
5
|
|
6
|
-
from project.api.schema.common import
|
6
|
+
from project.api.schema.common import BaseSO
|
7
7
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
8
|
from project.core.util import now_local_dt
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class _HealthcheckGeneralRouteSO(BaseSO):
|
12
12
|
is_ok: bool = True
|
13
13
|
datetime: dt.datetime
|
14
14
|
|
@@ -20,11 +20,11 @@ api_router = APIRouter()
|
|
20
20
|
"",
|
21
21
|
name="Healthcheck",
|
22
22
|
status_code=fastapi.status.HTTP_200_OK,
|
23
|
-
response_model=
|
23
|
+
response_model=_HealthcheckGeneralRouteSO | ErrorCommonSO,
|
24
24
|
)
|
25
25
|
async def _(
|
26
26
|
*,
|
27
27
|
request: fastapi.requests.Request,
|
28
28
|
response: fastapi.responses.Response
|
29
29
|
):
|
30
|
-
return
|
30
|
+
return _HealthcheckGeneralRouteSO(is_ok=True, datetime=now_local_dt())
|
@@ -3,15 +3,9 @@ from fastapi import APIRouter
|
|
3
3
|
|
4
4
|
from arpakitlib.ar_datetime_util import now_utc_dt
|
5
5
|
from project.api.authorize import require_api_key_dbm_api_authorize_middleware, APIAuthorizeData, api_authorize
|
6
|
-
from project.api.schema.common import BaseRouteSO
|
7
6
|
from project.api.schema.out.common.datetime_ import DatetimeCommonSO
|
8
7
|
from project.api.schema.out.common.error import ErrorCommonSO
|
9
8
|
|
10
|
-
|
11
|
-
class NowUTCDatetimeGeneralRouteSO(BaseRouteSO, DatetimeCommonSO):
|
12
|
-
pass
|
13
|
-
|
14
|
-
|
15
9
|
api_router = APIRouter()
|
16
10
|
|
17
11
|
|
@@ -19,7 +13,7 @@ api_router = APIRouter()
|
|
19
13
|
"",
|
20
14
|
name="Now UTC datetime",
|
21
15
|
status_code=fastapi.status.HTTP_200_OK,
|
22
|
-
response_model=
|
16
|
+
response_model=DatetimeCommonSO | ErrorCommonSO,
|
23
17
|
)
|
24
18
|
async def _(
|
25
19
|
*,
|
@@ -31,4 +25,4 @@ async def _(
|
|
31
25
|
)
|
32
26
|
]))
|
33
27
|
):
|
34
|
-
return
|
28
|
+
return DatetimeCommonSO.from_datetime(datetime_=now_utc_dt())
|
@@ -24,14 +24,3 @@ class BaseSI(BaseSchema):
|
|
24
24
|
|
25
25
|
class BaseSO(BaseSchema):
|
26
26
|
pass
|
27
|
-
|
28
|
-
|
29
|
-
class BaseRouteSO(BaseSchema):
|
30
|
-
@classmethod
|
31
|
-
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
|
32
|
-
if not (
|
33
|
-
cls.__name__.endswith("RouteSO")
|
34
|
-
or cls.__name__.endswith("RouteSchemaOut")
|
35
|
-
):
|
36
|
-
raise ValueError("Route APISchema class should ends with RouteSO | RouteSchemaOut")
|
37
|
-
super().__init_subclass__(**kwargs)
|
@@ -18,6 +18,6 @@ class SimpleDBMAdminSO(BaseSO):
|
|
18
18
|
|
19
19
|
@classmethod
|
20
20
|
def from_dbm(cls, *, simple_dbm: SimpleDBM) -> SimpleDBMAdminSO:
|
21
|
-
return cls.model_validate(simple_dbm.
|
22
|
-
|
21
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
22
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
23
23
|
))
|
@@ -23,6 +23,6 @@ class Operation1AdminSO(SimpleDBMAdminSO):
|
|
23
23
|
|
24
24
|
@classmethod
|
25
25
|
def from_dbm(cls, *, simple_dbm: OperationDBM) -> Operation1AdminSO:
|
26
|
-
return cls.model_validate(simple_dbm.
|
27
|
-
|
26
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
27
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
28
28
|
))
|
@@ -14,6 +14,6 @@ class StoryLog1AdminSO(SimpleDBMAdminSO):
|
|
14
14
|
|
15
15
|
@classmethod
|
16
16
|
def from_dbm(cls, *, simple_dbm: StoryLogDBM) -> StoryLog1AdminSO:
|
17
|
-
return cls.model_validate(simple_dbm.
|
18
|
-
|
17
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
18
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
19
19
|
))
|
@@ -30,6 +30,6 @@ class User1AdminSO(SimpleDBMAdminSO):
|
|
30
30
|
|
31
31
|
@classmethod
|
32
32
|
def from_dbm(cls, *, simple_dbm: UserDBM) -> User1AdminSO:
|
33
|
-
return cls.model_validate(simple_dbm.
|
34
|
-
|
33
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
34
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
35
35
|
))
|
@@ -16,6 +16,6 @@ class SimpleDBMClientSO(BaseSO):
|
|
16
16
|
|
17
17
|
@classmethod
|
18
18
|
def from_dbm(cls, *, simple_dbm: SimpleDBM) -> SimpleDBMClientSO:
|
19
|
-
return cls.model_validate(simple_dbm.
|
20
|
-
|
19
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
20
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
21
21
|
))
|
@@ -29,6 +29,6 @@ class User1ClientSO(SimpleDBMClientSO):
|
|
29
29
|
|
30
30
|
@classmethod
|
31
31
|
def from_dbm(cls, *, simple_dbm: UserDBM) -> User1ClientSO:
|
32
|
-
return cls.model_validate(simple_dbm.
|
33
|
-
|
32
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
33
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
34
34
|
))
|
@@ -11,6 +11,6 @@ class UserToken1ClientSO(SimpleDBMClientSO):
|
|
11
11
|
|
12
12
|
@classmethod
|
13
13
|
def from_dbm(cls, *, simple_dbm: UserTokenDBM) -> UserToken1ClientSO:
|
14
|
-
return cls.model_validate(simple_dbm.
|
15
|
-
|
14
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
15
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
16
16
|
))
|
@@ -1,16 +1,16 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from project.api.schema.out.
|
3
|
+
from project.api.schema.out.general.common import SimpleDBMGeneralSO
|
4
4
|
from project.sqlalchemy_db_.sqlalchemy_model import ApiKeyDBM
|
5
5
|
|
6
6
|
|
7
|
-
class ApiKey1GeneralSO(
|
7
|
+
class ApiKey1GeneralSO(SimpleDBMGeneralSO):
|
8
8
|
title: str | None
|
9
9
|
value: str
|
10
10
|
is_active: bool
|
11
11
|
|
12
12
|
@classmethod
|
13
13
|
def from_dbm(cls, *, simple_dbm: ApiKeyDBM) -> ApiKey1GeneralSO:
|
14
|
-
return cls.model_validate(simple_dbm.
|
15
|
-
|
14
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
15
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
16
16
|
))
|
@@ -16,6 +16,6 @@ class SimpleDBMGeneralSO(BaseSO):
|
|
16
16
|
|
17
17
|
@classmethod
|
18
18
|
def from_dbm(cls, *, simple_dbm: SimpleDBM) -> SimpleDBMGeneralSO:
|
19
|
-
return cls.model_validate(simple_dbm.
|
20
|
-
|
19
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
20
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
21
21
|
))
|
@@ -3,11 +3,11 @@ from __future__ import annotations
|
|
3
3
|
import datetime as dt
|
4
4
|
from typing import Any
|
5
5
|
|
6
|
-
from project.api.schema.out.
|
6
|
+
from project.api.schema.out.general.common import SimpleDBMGeneralSO
|
7
7
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
8
8
|
|
9
9
|
|
10
|
-
class User1GeneralSO(
|
10
|
+
class User1GeneralSO(SimpleDBMGeneralSO):
|
11
11
|
email: str | None
|
12
12
|
username: str | None
|
13
13
|
roles: list[str]
|
@@ -29,6 +29,6 @@ class User1GeneralSO(SimpleDBMClientSO):
|
|
29
29
|
|
30
30
|
@classmethod
|
31
31
|
def from_dbm(cls, *, simple_dbm: UserDBM) -> User1GeneralSO:
|
32
|
-
return cls.model_validate(simple_dbm.
|
33
|
-
|
32
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
33
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
34
34
|
))
|
@@ -1,16 +1,16 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from project.api.schema.out.
|
3
|
+
from project.api.schema.out.general.common import SimpleDBMGeneralSO
|
4
4
|
from project.sqlalchemy_db_.sqlalchemy_model import UserTokenDBM
|
5
5
|
|
6
6
|
|
7
|
-
class UserToken1GeneralSO(
|
7
|
+
class UserToken1GeneralSO(SimpleDBMGeneralSO):
|
8
8
|
value: str
|
9
9
|
user_id: int
|
10
10
|
is_active: bool
|
11
11
|
|
12
12
|
@classmethod
|
13
13
|
def from_dbm(cls, *, simple_dbm: UserTokenDBM) -> UserToken1GeneralSO:
|
14
|
-
return cls.model_validate(simple_dbm.
|
15
|
-
|
14
|
+
return cls.model_validate(simple_dbm.simple_dict(
|
15
|
+
include_columns_and_sd_properties=cls.model_fields.keys()
|
16
16
|
))
|
@@ -2,9 +2,9 @@ from functools import lru_cache
|
|
2
2
|
|
3
3
|
from emoji import emojize
|
4
4
|
|
5
|
+
from arpakitlib.ar_json_util import transfer_data_to_json_str
|
5
6
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
6
7
|
from project.tg_bot.blank.common import SimpleBlankTgBot
|
7
|
-
from project.util.arpakitlib_project_template import get_arpakitlib_project_template_info
|
8
8
|
|
9
9
|
|
10
10
|
class AdminTgBotBlank(SimpleBlankTgBot):
|
@@ -15,7 +15,7 @@ class AdminTgBotBlank(SimpleBlankTgBot):
|
|
15
15
|
def user_dbm(self, *, user_dbm: UserDBM | None) -> str:
|
16
16
|
if user_dbm is None:
|
17
17
|
return "None"
|
18
|
-
return user_dbm.
|
18
|
+
return transfer_data_to_json_str(user_dbm.simple_dict(), beautify=True)
|
19
19
|
|
20
20
|
|
21
21
|
def create_admin_tg_bot_blank() -> AdminTgBotBlank:
|
@@ -28,11 +28,7 @@ def get_cached_admin_tg_bot_blank() -> AdminTgBotBlank:
|
|
28
28
|
|
29
29
|
|
30
30
|
def __example():
|
31
|
-
|
32
|
-
get_cached_admin_tg_bot_blank().arpakit_project_template_info(
|
33
|
-
arpakitlib_project_template_info=get_arpakitlib_project_template_info()
|
34
|
-
)
|
35
|
-
)
|
31
|
+
pass
|
36
32
|
|
37
33
|
|
38
34
|
if __name__ == '__main__':
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
2
2
|
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
3
3
|
|
4
|
-
from project.tg_bot.blank.
|
4
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
5
5
|
from project.tg_bot.callback.client import HelloWorldClientCD
|
6
6
|
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton
|
2
2
|
from aiogram.utils.keyboard import ReplyKeyboardBuilder
|
3
3
|
|
4
|
-
from project.tg_bot.blank.
|
4
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
5
5
|
|
6
6
|
|
7
7
|
def hello_world_client_static_kb_tg_bot() -> ReplyKeyboardMarkup:
|
@@ -4,7 +4,7 @@ import aiogram
|
|
4
4
|
from aiogram import Router
|
5
5
|
from aiogram.filters import Command, or_f
|
6
6
|
|
7
|
-
from project.tg_bot.blank.
|
7
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
8
8
|
from project.tg_bot.const import GeneralTgBotCommands
|
9
9
|
from project.tg_bot.filter_.message_text import MessageTextTgBotFilter
|
10
10
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
@@ -4,7 +4,7 @@ import aiogram
|
|
4
4
|
from aiogram import Router
|
5
5
|
from aiogram.filters import Command, or_f
|
6
6
|
|
7
|
-
from project.tg_bot.blank.
|
7
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
8
8
|
from project.tg_bot.const import GeneralTgBotCommands
|
9
9
|
from project.tg_bot.filter_.message_text import MessageTextTgBotFilter
|
10
10
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
@@ -7,7 +7,7 @@ from aiogram.exceptions import TelegramBadRequest
|
|
7
7
|
from arpakitlib.ar_exception_util import exception_to_traceback_str
|
8
8
|
from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
9
9
|
from project.sqlalchemy_db_.sqlalchemy_model import StoryLogDBM
|
10
|
-
from project.tg_bot.blank.
|
10
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
11
11
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
12
12
|
|
13
13
|
_logger = logging.getLogger(__name__)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import aiogram.filters
|
2
2
|
|
3
|
-
from project.tg_bot.blank.
|
3
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
4
4
|
from project.tg_bot.const import GeneralTgBotCommands
|
5
5
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
6
6
|
|
@@ -2,7 +2,7 @@ import aiogram.filters
|
|
2
2
|
from aiogram.filters import or_f
|
3
3
|
|
4
4
|
from arpakitlib.ar_str_util import remove_html
|
5
|
-
from project.tg_bot.blank.
|
5
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
6
6
|
from project.tg_bot.callback.client import HelloWorldClientCD
|
7
7
|
from project.tg_bot.const import GeneralTgBotCommands
|
8
8
|
from project.tg_bot.filter_.message_text import MessageTextTgBotFilter
|
arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/raw_callback_query.py
CHANGED
@@ -3,7 +3,7 @@ import logging
|
|
3
3
|
import aiogram.filters
|
4
4
|
from aiogram.exceptions import AiogramError
|
5
5
|
|
6
|
-
from project.tg_bot.blank.
|
6
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
7
7
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
8
8
|
|
9
9
|
_logger = logging.getLogger(__name__)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import aiogram.filters
|
2
2
|
|
3
|
-
from project.tg_bot.blank.
|
3
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
4
4
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
5
5
|
|
6
6
|
tg_bot_router = aiogram.Router()
|
@@ -4,7 +4,7 @@ import aiogram
|
|
4
4
|
from aiogram import Router
|
5
5
|
from aiogram.filters import Command, or_f
|
6
6
|
|
7
|
-
from project.tg_bot.blank.
|
7
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
8
8
|
from project.tg_bot.const import GeneralTgBotCommands
|
9
9
|
from project.tg_bot.filter_.message_text import MessageTextTgBotFilter
|
10
10
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
@@ -4,7 +4,7 @@ import aiogram
|
|
4
4
|
from aiogram import Router
|
5
5
|
from aiogram.filters import Command, or_f
|
6
6
|
|
7
|
-
from project.tg_bot.blank.
|
7
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
8
8
|
from project.tg_bot.const import GeneralTgBotCommands
|
9
9
|
from project.tg_bot.filter_.message_text import MessageTextTgBotFilter
|
10
10
|
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
@@ -8,7 +8,7 @@ from project.core.settings import get_cached_settings
|
|
8
8
|
from project.core.util import setup_logging
|
9
9
|
from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
10
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
|
-
from project.tg_bot.blank.
|
11
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
12
12
|
from project.tg_bot.const import GeneralTgBotCommands, AdminTgBotCommands
|
13
13
|
from project.tg_bot.tg_bot import get_cached_tg_bot
|
14
14
|
|
arpakitlib/ar_sqlalchemy_util.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
import asyncio
|
3
3
|
import logging
|
4
4
|
from datetime import timedelta, datetime
|
5
|
-
from typing import Any
|
5
|
+
from typing import Any, Collection
|
6
6
|
from urllib.parse import quote_plus
|
7
7
|
from uuid import uuid4
|
8
8
|
|
@@ -13,7 +13,6 @@ from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
|
13
13
|
from sqlalchemy.orm.session import Session
|
14
14
|
|
15
15
|
from arpakitlib.ar_datetime_util import now_utc_dt
|
16
|
-
from arpakitlib.ar_json_util import transfer_data_to_json_str
|
17
16
|
|
18
17
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
19
18
|
|
@@ -71,12 +70,14 @@ class BaseDBM(DeclarativeBase):
|
|
71
70
|
def simple_dict(
|
72
71
|
self,
|
73
72
|
*,
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
73
|
+
need_include_columns: bool = True,
|
74
|
+
need_include_sd_properties: bool = True,
|
75
|
+
include_columns: Collection[str] | None = None,
|
76
|
+
exclude_columns: Collection[str] | None = None,
|
77
|
+
include_sd_properties: Collection[str] | None = None,
|
78
|
+
exclude_sd_properties: Collection[str] | None = None,
|
79
|
+
include_columns_and_sd_properties: Collection[str] | None = None,
|
80
|
+
kwargs: dict[str, Any] | None = None
|
80
81
|
) -> dict[str, Any]:
|
81
82
|
if exclude_columns is None:
|
82
83
|
exclude_columns = set()
|
@@ -85,20 +86,18 @@ class BaseDBM(DeclarativeBase):
|
|
85
86
|
|
86
87
|
res = {}
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
res[c.key] = value # Просто сохраняем значение
|
89
|
+
if need_include_columns:
|
90
|
+
for c in inspect(self).mapper.column_attrs:
|
91
|
+
if include_columns_and_sd_properties is not None and c.key not in include_columns_and_sd_properties:
|
92
|
+
continue
|
93
|
+
if include_columns is not None and c.key not in include_columns:
|
94
|
+
continue
|
95
|
+
if c.key in exclude_columns:
|
96
|
+
continue
|
97
|
+
value = getattr(self, c.key)
|
98
|
+
res[c.key] = value
|
99
99
|
|
100
|
-
|
101
|
-
if include_sd_properties:
|
100
|
+
if need_include_sd_properties:
|
102
101
|
for attr_name in dir(self):
|
103
102
|
if not attr_name.startswith("sdp_") or not isinstance(getattr(type(self), attr_name, None), property):
|
104
103
|
continue
|
@@ -106,69 +105,21 @@ class BaseDBM(DeclarativeBase):
|
|
106
105
|
sd_property_name = attr_name.removeprefix("sdp_")
|
107
106
|
|
108
107
|
if (
|
109
|
-
|
110
|
-
and sd_property_name not in
|
108
|
+
include_columns_and_sd_properties is not None
|
109
|
+
and sd_property_name not in include_columns_and_sd_properties
|
111
110
|
):
|
112
|
-
continue
|
113
|
-
if
|
114
|
-
continue
|
111
|
+
continue
|
112
|
+
if include_sd_properties is not None and sd_property_name not in include_sd_properties:
|
113
|
+
continue
|
115
114
|
if sd_property_name in exclude_sd_properties:
|
116
|
-
continue
|
117
|
-
|
118
|
-
value = getattr(self, attr_name)
|
119
|
-
if isinstance(value, BaseDBM):
|
120
|
-
res[sd_property_name] = value.simple_dict(include_sd_properties=include_sd_properties)
|
121
|
-
elif isinstance(value, list):
|
122
|
-
res[sd_property_name] = [
|
123
|
-
item.simple_dict(include_sd_properties=include_sd_properties)
|
124
|
-
if isinstance(item, BaseDBM) else item
|
125
|
-
for item in value
|
126
|
-
]
|
127
|
-
else:
|
128
|
-
res[sd_property_name] = value
|
115
|
+
continue
|
129
116
|
|
130
|
-
|
117
|
+
res[sd_property_name] = getattr(self, attr_name)
|
131
118
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
only_columns: list[str] | None = None,
|
137
|
-
exclude_sdp_properties: set[str] | None = None,
|
138
|
-
only_sd_properties: list[str] | None = None,
|
139
|
-
only_columns_and_sd_properties: list[str] | None = None # Новый параметр
|
140
|
-
) -> dict[str, Any]:
|
141
|
-
return self.simple_dict(
|
142
|
-
include_sd_properties=True,
|
143
|
-
exclude_columns=exclude_columns,
|
144
|
-
only_columns=only_columns,
|
145
|
-
exclude_sd_properties=exclude_sdp_properties,
|
146
|
-
only_sd_properties=only_sd_properties,
|
147
|
-
only_columns_and_sd_properties=only_columns_and_sd_properties # Новый параметр
|
148
|
-
)
|
149
|
-
|
150
|
-
def simple_dict_json(
|
151
|
-
self,
|
152
|
-
*,
|
153
|
-
include_sd_properties: bool = True,
|
154
|
-
exclude_columns: set[str] | None = None,
|
155
|
-
only_columns: list[str] | None = None,
|
156
|
-
exclude_sd_properties: set[str] | None = None,
|
157
|
-
only_sd_properties: list[str] | None = None,
|
158
|
-
only_columns_and_sd_properties: list[str] | None = None,
|
159
|
-
**transfer_data_to_json_str_kwargs
|
160
|
-
) -> str:
|
161
|
-
return transfer_data_to_json_str(
|
162
|
-
data=self.simple_dict(
|
163
|
-
include_sd_properties=include_sd_properties,
|
164
|
-
exclude_columns=exclude_columns,
|
165
|
-
only_columns=only_columns,
|
166
|
-
exclude_sd_properties=exclude_sd_properties,
|
167
|
-
only_sd_properties=only_sd_properties,
|
168
|
-
only_columns_and_sd_properties=only_columns_and_sd_properties
|
169
|
-
),
|
170
|
-
**transfer_data_to_json_str_kwargs
|
171
|
-
)
|
119
|
+
if kwargs is not None:
|
120
|
+
res.update(kwargs)
|
121
|
+
|
122
|
+
return res
|
172
123
|
|
173
124
|
|
174
125
|
class SQLAlchemyDb:
|