arpakitlib 1.8.15__py3-none-any.whl → 1.8.17__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_4/arpakitlib_project_template_info.json +3 -0
- arpakitlib/_arpakit_project_template_v_4/command/beautify_json.py +10 -0
- arpakitlib/_arpakit_project_template_v_4/command/demojize.py +9 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/drop_json_db.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/drop_sqlalchemy_db.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/generate_settings_env_example.py +2 -2
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/reinit_json_db.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/reinit_sqlalchemy_db.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/remove_operations.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/remove_story_logs.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/rm_all_records_in_json_db.py +1 -1
- arpakitlib/_arpakit_project_template_v_4/command/set_tg_bot_commands.py +16 -0
- arpakitlib/_arpakit_project_template_v_4/command/show_settings.py +10 -0
- arpakitlib/_arpakit_project_template_v_4/command/start_sqladmin.py +19 -0
- arpakitlib/_arpakit_project_template_v_4/command/start_sqladmin_for_prod.py +19 -0
- arpakitlib/_arpakit_project_template_v_4/command/start_sqladmin_with_reload.py +19 -0
- arpakitlib/_arpakit_project_template_v_4/command/start_tg_bot_for_prod.py +11 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/example.env +11 -5
- arpakitlib/_arpakit_project_template_v_4/project/additional_model/common.py +8 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/auth.py +111 -35
- arpakitlib/_arpakit_project_template_v_4/project/api/auth2.py +171 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/create_api_app.py +7 -7
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/event.py +8 -8
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/exception.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/exception_handler.py +38 -36
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/openapi_ui.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/response.py +5 -5
- arpakitlib/_arpakit_project_template_v_4/project/api/router/admin/get_arpakitlib_project_template_info.py +23 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/router/admin/get_auth_data.py +30 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/router/admin/main_router.py +3 -0
- arpakitlib/{_arpakit_project_template_v_2/project/api/router/general → _arpakit_project_template_v_4/project/api/router/client}/get_errors_info.py +3 -9
- arpakitlib/_arpakit_project_template_v_4/project/api/router/client/main_router.py +3 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/router/client/now_utc_datetime.py +22 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/router/general/healthcheck.py +21 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/router/general/main_router.py +10 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/router/main_router.py +23 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/admin/common.py +10 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/admin/operation.py +23 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/admin/story_log.py +17 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/client/common.py +10 -0
- arpakitlib/{_arpakit_project_template_v_2/project/api/schema/common/out.py → _arpakit_project_template_v_4/project/api/schema/out/common/datetime_.py} +2 -19
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/common/raw_data.py +7 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/common.py +5 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/general/error.py +11 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/general/errors_info_general.py +6 -0
- arpakitlib/_arpakit_project_template_v_4/project/api/schema/out/general/healthcheck.py +5 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/core/const.py +2 -2
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/core/settings.py +43 -39
- arpakitlib/_arpakit_project_template_v_4/project/site/router/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/sqladmin_/__init__.py +0 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqladmin_/admin_auth.py +17 -12
- arpakitlib/_arpakit_project_template_v_4/project/sqladmin_/asgi.py +3 -0
- arpakitlib/_arpakit_project_template_v_4/project/sqladmin_/create_sqladmin_app.py +49 -0
- arpakitlib/_arpakit_project_template_v_4/project/sqladmin_/event.py +40 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqladmin_/model_view/operation.py +1 -1
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqladmin_/model_view/story_log.py +1 -1
- arpakitlib/_arpakit_project_template_v_4/project/sqlalchemy_db_/__init__.py +0 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqlalchemy_db_/sqlalchemy_model/__init__.py +4 -0
- arpakitlib/_arpakit_project_template_v_4/project/sqlalchemy_db_/sqlalchemy_model/api_key.py +44 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqlalchemy_db_/sqlalchemy_model/common.py +29 -6
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqlalchemy_db_/sqlalchemy_model/story_log.py +2 -1
- arpakitlib/_arpakit_project_template_v_4/project/sqlalchemy_db_/sqlalchemy_model/user.py +87 -0
- arpakitlib/_arpakit_project_template_v_4/project/sqlalchemy_db_/sqlalchemy_model/user_token.py +41 -0
- arpakitlib/_arpakit_project_template_v_4/project/test_data/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/blank/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/blank/admin.py +45 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/blank/client.py +44 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/blank/common.py +5 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/callback/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/callback/admin.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/callback/client.py +5 -0
- arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/kb/inline_/callback.py → _arpakit_project_template_v_4/project/tg_bot/callback/common.py} +7 -7
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/tg_bot/const.py +22 -6
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/error_handler.py +37 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/tg_bot/event.py +43 -13
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/filter_/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/filter_/is_private_chat.py +12 -0
- arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/filter_.py → _arpakit_project_template_v_4/project/tg_bot/filter_/message_text.py} +1 -22
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/filter_/not_prod_mode_filter.py +8 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/filter_/prod_mode_filter.py +8 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/filter_/user_roles_has_admin.py +27 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/filter_/user_roles_has_client.py +27 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/inline_/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/inline_/admin/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/inline_/admin/common.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/inline_/client/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/inline_/client/common.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/inline_/client/hello_world.py +16 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/inline_/common.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/static_/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/static_/admin/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/static_/admin/common.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/static_/client/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/static_/client/common.py +0 -0
- arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/kb/static_/common.py → _arpakit_project_template_v_4/project/tg_bot/kb/static_/client/hello_world.py} +3 -3
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/kb/static_/common.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/middleware/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/middleware/common.py +13 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/middleware/init_user.py +84 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/tg_bot/middleware/middleware.py +1 -2
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/admin/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/admin/arpakitlib_project_template_info.py +25 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/admin/main_router.py +15 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/admin/me.py +20 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/admin/raise_fake_error.py +20 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/admin/reinit_sqlalchemy_db.py +27 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/client/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/client/healthcheck.py +16 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/client/hello_world.py +44 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/client/main_router.py +14 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/client/start.py +33 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/router/main_router.py +13 -0
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/tg_bot/start_tg_bot.py +2 -2
- arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/tg_bot/tg_bot.py +7 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/util/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/util/etc.py +0 -0
- arpakitlib/_arpakit_project_template_v_4/project/tg_bot/util/set_tg_bot_commands.py +76 -0
- arpakitlib/_arpakit_project_template_v_4/project/util/__init__.py +0 -0
- arpakitlib/ar_aiogram_util.py +0 -3
- arpakitlib/ar_arpakit_schedule_uust_api_client_util.py +1 -65
- arpakitlib/ar_json_util.py +43 -12
- arpakitlib/ar_sqlalchemy_util.py +2 -2
- arpakitlib/ar_ssh_runner_util.py +2 -2
- arpakitlib/ar_str_util.py +15 -0
- {arpakitlib-1.8.15.dist-info → arpakitlib-1.8.17.dist-info}/METADATA +3 -1
- arpakitlib-1.8.17.dist-info/RECORD +330 -0
- arpakitlib/_arpakit_project_template_v_2/arpakitlib_project_template_info.json +0 -3
- arpakitlib/_arpakit_project_template_v_2/command/beautify_json.py +0 -10
- arpakitlib/_arpakit_project_template_v_2/command/show_settings.py +0 -10
- arpakitlib/_arpakit_project_template_v_2/project/additional_model/common.py +0 -1
- arpakitlib/_arpakit_project_template_v_2/project/api/router/general/get_auth_data.py +0 -31
- arpakitlib/_arpakit_project_template_v_2/project/api/router/general/healthcheck.py +0 -26
- arpakitlib/_arpakit_project_template_v_2/project/api/router/general/main_router.py +0 -24
- arpakitlib/_arpakit_project_template_v_2/project/api/router/general/now_utc_datetime.py +0 -26
- arpakitlib/_arpakit_project_template_v_2/project/api/router/main_router.py +0 -11
- arpakitlib/_arpakit_project_template_v_2/project/api/schema/common/in_.py +0 -5
- arpakitlib/_arpakit_project_template_v_2/project/api/schema/example/in_.py +0 -5
- arpakitlib/_arpakit_project_template_v_2/project/api/schema/example/out.py +0 -45
- arpakitlib/_arpakit_project_template_v_2/project/api/schema/general/in_.py +0 -5
- arpakitlib/_arpakit_project_template_v_2/project/api/schema/general/out.py +0 -14
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/blank/blank.py +0 -24
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/kb/inline_/common.py +0 -15
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/middleware/init_user.py +0 -21
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/router/arpakitlib_project_template_info.py +0 -14
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/router/error.py +0 -16
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/router/healthcheck.py +0 -11
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/router/main_router.py +0 -12
- arpakitlib/_arpakit_project_template_v_2/project/tg_bot/util.py +0 -1
- arpakitlib-1.8.15.dist-info/RECORD +0 -265
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/.gitignore +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/.python-version +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/LICENSE +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/README.md +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/alembic/README +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/alembic/env.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/alembic/script.py.mako +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/alembic/versions/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/alembic.ini +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/alembic_history.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/alembic_revision_autogenerate.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/alembic_upgrade_head.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/check_logging.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/check_sqlalchemy_db.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/docker_ps_a.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/docker_rm_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/docker_run_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/docker_start_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/docker_stop_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_commit.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_push_arpakit_company_github_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_push_arpakit_company_gitlab_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_push_arpakit_github_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_push_arpakit_gitlab_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_remote_v.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_set_arpakit_company_origin.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_set_arpakit_origin.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_set_divarteam_origin.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/git_status.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/hello_world.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/init_json_db.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/init_sqlalchemy_db.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_check.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_clear_cache.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_config.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_install.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_lock.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_remove_and_add_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_show.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_show_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_update.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/poetry_update_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/command/start_api_for_not_prod.py → _arpakit_project_template_v_4/command/start_api.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/command/start_api_for_prod.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/command/start_api_with_reload_for_not_prod.py → _arpakit_project_template_v_4/command/start_api_with_reload.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/command/start_operation_executor_worker_for_not_prod.py → _arpakit_project_template_v_4/command/start_operation_executor_worker.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/command/start_operation_executor_workers_for_not_prod.py → _arpakit_project_template_v_4/command/start_operation_executor_workers.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/command/start_scheduled_operation_creator_worker_for_not_prod.py → _arpakit_project_template_v_4/command/start_scheduled_operation_creator_worker.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/command/start_tg_bot_for_prod.py → _arpakit_project_template_v_4/command/start_tg_bot.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/note/note_1.txt +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/note/note_2.txt +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/note/note_3.txt +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/note/note_4.txt +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/note/note_5.txt +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/additional_model/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/asgi.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/const.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/api/router/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/api/router/general → _arpakit_project_template_v_4/project/api/router/admin}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/api/schema → _arpakit_project_template_v_4/project/api/router/client}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/api/schema/common → _arpakit_project_template_v_4/project/api/router/general}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/api/schema/example → _arpakit_project_template_v_4/project/api/schema}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/api/schema/base_schema.py → _arpakit_project_template_v_4/project/api/schema/common.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/api/schema/general → _arpakit_project_template_v_4/project/api/schema/in_}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/business_service → _arpakit_project_template_v_4/project/api/schema/in_/admin}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/api/util.py → _arpakit_project_template_v_4/project/api/schema/in_/admin/common.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/celery_ → _arpakit_project_template_v_4/project/api/schema/in_/client}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/core/__init__.py → _arpakit_project_template_v_4/project/api/schema/in_/client/common.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/json_db → _arpakit_project_template_v_4/project/api/schema/in_/general}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/operation_execution/__init__.py → _arpakit_project_template_v_4/project/api/schema/in_/general/common.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/resource → _arpakit_project_template_v_4/project/api/schema/out}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/sandbox → _arpakit_project_template_v_4/project/api/schema/out/admin}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/site → _arpakit_project_template_v_4/project/api/schema/out/client}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/site/router → _arpakit_project_template_v_4/project/api/schema/out/common}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/sqladmin_ → _arpakit_project_template_v_4/project/api/schema/out/general}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/site/consts.py → _arpakit_project_template_v_4/project/api/schema/out/general/common.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/site/exception_handler.py → _arpakit_project_template_v_4/project/api/util.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/sqlalchemy_db_ → _arpakit_project_template_v_4/project/business_service}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/business_service/hello_world.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/business_service/remove_operations.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/test_data → _arpakit_project_template_v_4/project/celery_}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/tg_bot → _arpakit_project_template_v_4/project/core}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/core/cache_file_storage_in_dir.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/core/dump_file_storage_in_dir.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/core/jinja2_templates.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/core/media_file_storage_in_dir.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/core/util.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/blank → _arpakit_project_template_v_4/project/json_db}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/json_db/json_db.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/more/helloworld +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/kb → _arpakit_project_template_v_4/project/operation_execution}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/operation_execution/const.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/operation_execution/operation_executor_worker.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/operation_execution/scheduled_operation_creator_worker.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/operation_execution/scheduled_operations.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/operation_execution/util.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/kb/inline_ → _arpakit_project_template_v_4/project/resource}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/1 +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/healthcheck +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/helloworld +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/openapi-favicon.png +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/redoc/redoc.standalone.js +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/favicon-16x16.png +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/favicon-32x32.png +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/index.css +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/index.html +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/oauth2-redirect.html +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-initializer.js +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-bundle.js +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-bundle.js.map +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-es-bundle-core.js +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-es-bundle-core.js.map +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-es-bundle.js +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-es-bundle.js.map +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-standalone-preset.js +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui-standalone-preset.js.map +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui.css +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui.css.map +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui.js +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/resource/static/swagger-ui/swagger-ui.js.map +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/kb/static_ → _arpakit_project_template_v_4/project/sandbox}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sandbox/sandbox_1.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sandbox/sandbox_2.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sandbox/sandbox_3.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sandbox/sandbox_4.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sandbox/sandbox_5.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sandbox/sandbox_6.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sandbox/sandbox_7.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/middleware → _arpakit_project_template_v_4/project/site}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/site/asgi.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/tg_bot/router/__init__.py → _arpakit_project_template_v_4/project/site/consts.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/site/create_site_app.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/site/event.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2/project/util/__init__.py → _arpakit_project_template_v_4/project/site/exception_handler.py} +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/site/router/main_router.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqladmin_/add_admin_in_app.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqladmin_/model_view/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqladmin_/model_view/common.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqlalchemy_db_/const.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqlalchemy_db_/sqlalchemy_db.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqlalchemy_db_/sqlalchemy_model/operation.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/sqlalchemy_db_/util.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/test_data/make_test_data_1.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/test_data/make_test_data_2.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/test_data/make_test_data_3.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/test_data/make_test_data_4.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/test_data/make_test_data_5.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/tg_bot/tg_bot_dispatcher.py +0 -0
- /arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/util/arpakitlib_project_template.py +0 -0
- {arpakitlib-1.8.15.dist-info → arpakitlib-1.8.17.dist-info}/LICENSE +0 -0
- {arpakitlib-1.8.15.dist-info → arpakitlib-1.8.17.dist-info}/WHEEL +0 -0
- {arpakitlib-1.8.15.dist-info → arpakitlib-1.8.17.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
from pydantic import BaseModel, ConfigDict
|
4
|
+
|
5
|
+
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
6
|
+
|
7
|
+
|
8
|
+
class MiddlewareDataTgBot(BaseModel):
|
9
|
+
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True, from_attributes=True)
|
10
|
+
|
11
|
+
user_dbm: UserDBM | None = None
|
12
|
+
user_dbm_just_created: bool | None = None
|
13
|
+
additional_data: dict[str, Any] = {}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import logging
|
2
|
+
from typing import Any, Awaitable, Callable, Dict
|
3
|
+
|
4
|
+
import aiogram
|
5
|
+
from aiogram import BaseMiddleware
|
6
|
+
from aiogram.types import TelegramObject
|
7
|
+
|
8
|
+
from project.core.settings import get_cached_settings
|
9
|
+
from project.core.util import now_local_dt
|
10
|
+
from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
11
|
+
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
12
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
13
|
+
|
14
|
+
_logger = logging.getLogger(__name__)
|
15
|
+
|
16
|
+
|
17
|
+
class InitUserTgBotMiddleware(BaseMiddleware):
|
18
|
+
|
19
|
+
async def __call__(
|
20
|
+
self,
|
21
|
+
handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],
|
22
|
+
event: TelegramObject,
|
23
|
+
data: Dict[str, Any],
|
24
|
+
) -> Any:
|
25
|
+
_logger.info("start")
|
26
|
+
|
27
|
+
if "middleware_data_tg_bot" in data:
|
28
|
+
middleware_data_tg_bot = data["middleware_data_tg_bot"]
|
29
|
+
else:
|
30
|
+
middleware_data_tg_bot = MiddlewareDataTgBot()
|
31
|
+
data["middleware_data_tg_bot"] = middleware_data_tg_bot
|
32
|
+
|
33
|
+
tg_user: aiogram.types.User | None = None
|
34
|
+
if event.event_type == "message":
|
35
|
+
tg_user = event.message.from_user
|
36
|
+
elif event.event_type == "callback_query":
|
37
|
+
tg_user = event.callback_query.from_user
|
38
|
+
elif event.event_type == "inline_query":
|
39
|
+
tg_user = event.inline_query.from_user
|
40
|
+
|
41
|
+
if tg_user is not None:
|
42
|
+
middleware_data_tg_bot.additional_data["tg_user_was_found"] = tg_user
|
43
|
+
middleware_data_tg_bot.additional_data["found_tg_user_id"] = tg_user.id
|
44
|
+
|
45
|
+
now_local_dt_ = now_local_dt()
|
46
|
+
|
47
|
+
if tg_user is not None and get_cached_sqlalchemy_db() is not None:
|
48
|
+
with get_cached_sqlalchemy_db().new_session() as session:
|
49
|
+
middleware_data_tg_bot.user_dbm = (
|
50
|
+
session.query(UserDBM).filter(UserDBM.tg_id == tg_user.id).one_or_none()
|
51
|
+
)
|
52
|
+
if middleware_data_tg_bot.user_dbm is None:
|
53
|
+
roles = [UserDBM.Roles.client]
|
54
|
+
if tg_user.id in get_cached_settings().tg_bot_admin_tg_ids:
|
55
|
+
roles.append(UserDBM.Roles.admin)
|
56
|
+
middleware_data_tg_bot.user_dbm = UserDBM(
|
57
|
+
creation_dt=now_local_dt_,
|
58
|
+
roles=roles,
|
59
|
+
tg_id=tg_user.id,
|
60
|
+
tg_data=tg_user.model_dump(mode="json"),
|
61
|
+
tg_bot_last_action_dt=now_local_dt_
|
62
|
+
)
|
63
|
+
session.add(middleware_data_tg_bot.user_dbm)
|
64
|
+
session.commit()
|
65
|
+
session.refresh(middleware_data_tg_bot.user_dbm)
|
66
|
+
middleware_data_tg_bot.user_dbm_just_created = True
|
67
|
+
_logger.info(f"user_dbm was added, {middleware_data_tg_bot.user_dbm}")
|
68
|
+
else:
|
69
|
+
middleware_data_tg_bot.user_dbm.tg_data = tg_user.model_dump(mode="json")
|
70
|
+
middleware_data_tg_bot.user_dbm.tg_bot_last_action_dt = now_local_dt_
|
71
|
+
if (
|
72
|
+
tg_user.id in get_cached_settings().tg_bot_admin_tg_ids
|
73
|
+
and UserDBM.Roles.admin not in middleware_data_tg_bot.user_dbm.roles
|
74
|
+
):
|
75
|
+
middleware_data_tg_bot.user_dbm.roles = (
|
76
|
+
middleware_data_tg_bot.user_dbm.roles + [UserDBM.Roles.admin]
|
77
|
+
)
|
78
|
+
session.commit()
|
79
|
+
session.refresh(middleware_data_tg_bot.user_dbm)
|
80
|
+
middleware_data_tg_bot.user_dbm_just_created = False
|
81
|
+
|
82
|
+
_logger.info("finish")
|
83
|
+
|
84
|
+
return await handler(event, data)
|
@@ -5,8 +5,7 @@ from project.tg_bot.middleware.init_user import InitUserTgBotMiddleware
|
|
5
5
|
|
6
6
|
def register_middlewares_to_tg_bot(
|
7
7
|
*,
|
8
|
-
tg_bot_dispatcher: aiogram.Dispatcher
|
9
|
-
**kwargs
|
8
|
+
tg_bot_dispatcher: aiogram.Dispatcher
|
10
9
|
) -> aiogram.Dispatcher:
|
11
10
|
tg_bot_dispatcher.update.outer_middleware.register(InitUserTgBotMiddleware())
|
12
11
|
return tg_bot_dispatcher
|
File without changes
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import aiogram.filters
|
2
|
+
|
3
|
+
from arpakitlib.ar_aiogram_util import as_tg_command
|
4
|
+
from project.tg_bot.blank.admin import get_cached_admin_tg_bot_blank
|
5
|
+
from project.tg_bot.const import AdminTgBotCommands
|
6
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
7
|
+
from project.util.arpakitlib_project_template import get_arpakitlib_project_template_info
|
8
|
+
|
9
|
+
tg_bot_router = aiogram.Router()
|
10
|
+
|
11
|
+
|
12
|
+
@tg_bot_router.message(
|
13
|
+
aiogram.filters.Command(AdminTgBotCommands.arpakitlib_project_template_info)
|
14
|
+
)
|
15
|
+
@as_tg_command()
|
16
|
+
async def _(
|
17
|
+
m: aiogram.types.Message,
|
18
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
19
|
+
**kwargs
|
20
|
+
):
|
21
|
+
await m.answer(
|
22
|
+
text=get_cached_admin_tg_bot_blank().arpakit_project_template_info(
|
23
|
+
arpakitlib_project_template_info=get_arpakitlib_project_template_info()
|
24
|
+
)
|
25
|
+
)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from aiogram import Router
|
2
|
+
|
3
|
+
from project.tg_bot.filter_.is_private_chat import IsPrivateChatTgBotFilter
|
4
|
+
from project.tg_bot.filter_.user_roles_has_admin import UserRolesHasAdminTgBotFilter
|
5
|
+
from project.tg_bot.router.admin import reinit_sqlalchemy_db, arpakitlib_project_template_info, raise_fake_error, me
|
6
|
+
|
7
|
+
main_admin_tg_bot_router = Router()
|
8
|
+
for observer in main_admin_tg_bot_router.observers.values():
|
9
|
+
observer.filter(UserRolesHasAdminTgBotFilter())
|
10
|
+
observer.filter(IsPrivateChatTgBotFilter())
|
11
|
+
|
12
|
+
main_admin_tg_bot_router.include_router(reinit_sqlalchemy_db.tg_bot_router)
|
13
|
+
main_admin_tg_bot_router.include_router(arpakitlib_project_template_info.tg_bot_router)
|
14
|
+
main_admin_tg_bot_router.include_router(raise_fake_error.tg_bot_router)
|
15
|
+
main_admin_tg_bot_router.include_router(me.tg_bot_router)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import aiogram.filters
|
2
|
+
|
3
|
+
from arpakitlib.ar_aiogram_util import as_tg_command
|
4
|
+
from project.tg_bot.blank.admin import get_cached_admin_tg_bot_blank
|
5
|
+
from project.tg_bot.const import AdminTgBotCommands
|
6
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
7
|
+
|
8
|
+
tg_bot_router = aiogram.Router()
|
9
|
+
|
10
|
+
|
11
|
+
@tg_bot_router.message(
|
12
|
+
aiogram.filters.Command(AdminTgBotCommands.me)
|
13
|
+
)
|
14
|
+
@as_tg_command()
|
15
|
+
async def _(
|
16
|
+
m: aiogram.types.Message,
|
17
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
18
|
+
**kwargs
|
19
|
+
):
|
20
|
+
await m.answer(text=get_cached_admin_tg_bot_blank().user_dbm(user_dbm=middleware_data_tg_bot.user_dbm))
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import aiogram.filters
|
2
|
+
|
3
|
+
from arpakitlib.ar_aiogram_util import as_tg_command
|
4
|
+
from project.core.settings import get_cached_settings
|
5
|
+
from project.tg_bot.const import AdminTgBotCommands
|
6
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
7
|
+
|
8
|
+
tg_bot_router = aiogram.Router()
|
9
|
+
|
10
|
+
|
11
|
+
@tg_bot_router.message(
|
12
|
+
aiogram.filters.Command(AdminTgBotCommands.raise_fake_err)
|
13
|
+
)
|
14
|
+
@as_tg_command(passwd_validator=get_cached_settings().tg_bot_command_passwd)
|
15
|
+
async def _(
|
16
|
+
m: aiogram.types.Message,
|
17
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
18
|
+
**kwargs
|
19
|
+
):
|
20
|
+
raise Exception("fake error")
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import aiogram
|
2
|
+
from aiogram import Router
|
3
|
+
from aiogram.filters import Command
|
4
|
+
|
5
|
+
from arpakitlib.ar_aiogram_util import as_tg_command
|
6
|
+
from project.core.settings import get_cached_settings
|
7
|
+
from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
8
|
+
from project.tg_bot.blank.admin import get_cached_admin_tg_bot_blank
|
9
|
+
from project.tg_bot.const import AdminTgBotCommands
|
10
|
+
from project.tg_bot.filter_.not_prod_mode_filter import NotProdModeTgBotFilter
|
11
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
12
|
+
|
13
|
+
tg_bot_router = Router()
|
14
|
+
|
15
|
+
|
16
|
+
@tg_bot_router.message(
|
17
|
+
Command(AdminTgBotCommands.reinit_sqlalchemy_db),
|
18
|
+
NotProdModeTgBotFilter()
|
19
|
+
)
|
20
|
+
@as_tg_command(passwd_validator=get_cached_settings().tg_bot_command_passwd)
|
21
|
+
async def handler(
|
22
|
+
m: aiogram.types.Message,
|
23
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
24
|
+
**kwargs
|
25
|
+
):
|
26
|
+
get_cached_sqlalchemy_db().reinit()
|
27
|
+
await m.answer(text=get_cached_admin_tg_bot_blank().done())
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import aiogram.filters
|
2
|
+
|
3
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
4
|
+
from project.tg_bot.const import ClientTgBotCommands
|
5
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
6
|
+
|
7
|
+
tg_bot_router = aiogram.Router()
|
8
|
+
|
9
|
+
|
10
|
+
@tg_bot_router.message(aiogram.filters.Command(ClientTgBotCommands.healthcheck))
|
11
|
+
async def _(
|
12
|
+
m: aiogram.types.Message,
|
13
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
14
|
+
**kwargs
|
15
|
+
):
|
16
|
+
await m.answer(text=get_cached_client_tg_bot_blank().healthcheck())
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import aiogram.filters
|
2
|
+
from aiogram.filters import or_f
|
3
|
+
|
4
|
+
from arpakitlib.ar_str_util import remove_html
|
5
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
6
|
+
from project.tg_bot.callback.client import HelloWorldClientCD
|
7
|
+
from project.tg_bot.const import ClientTgBotCommands
|
8
|
+
from project.tg_bot.filter_.message_text import MessageTextTgBotFilter
|
9
|
+
from project.tg_bot.kb.inline_.client.hello_world import hello_world_client_inline_kb_tg_bot
|
10
|
+
from project.tg_bot.kb.static_.client.hello_world import hello_world_client_static_kb_tg_bot
|
11
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
12
|
+
|
13
|
+
tg_bot_router = aiogram.Router()
|
14
|
+
|
15
|
+
|
16
|
+
@tg_bot_router.message(
|
17
|
+
or_f(
|
18
|
+
aiogram.filters.Command(ClientTgBotCommands.hello_world),
|
19
|
+
MessageTextTgBotFilter(get_cached_client_tg_bot_blank().but_hello_world())
|
20
|
+
)
|
21
|
+
)
|
22
|
+
async def _(
|
23
|
+
m: aiogram.types.Message,
|
24
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
25
|
+
**kwargs
|
26
|
+
):
|
27
|
+
await m.answer(
|
28
|
+
text=get_cached_client_tg_bot_blank().hello_world(),
|
29
|
+
reply_markup=hello_world_client_inline_kb_tg_bot()
|
30
|
+
)
|
31
|
+
await m.answer(
|
32
|
+
text=get_cached_client_tg_bot_blank().hello_world(),
|
33
|
+
reply_markup=hello_world_client_static_kb_tg_bot()
|
34
|
+
)
|
35
|
+
|
36
|
+
|
37
|
+
@tg_bot_router.callback_query(HelloWorldClientCD.filter())
|
38
|
+
async def _(
|
39
|
+
cq: aiogram.types.CallbackQuery,
|
40
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
41
|
+
**kwargs
|
42
|
+
):
|
43
|
+
await cq.message.delete_reply_markup()
|
44
|
+
await cq.message.answer(text=remove_html(get_cached_client_tg_bot_blank().hello_world()))
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from aiogram import Router
|
2
|
+
|
3
|
+
from project.tg_bot.filter_.user_roles_has_client import UserRolesHasClientTgBotFilter
|
4
|
+
from project.tg_bot.router.client import start, healthcheck, hello_world
|
5
|
+
|
6
|
+
main_client_tg_bot_router = Router()
|
7
|
+
for observer in main_client_tg_bot_router.observers.values():
|
8
|
+
observer.filter(UserRolesHasClientTgBotFilter())
|
9
|
+
|
10
|
+
main_client_tg_bot_router.include_router(router=start.tg_bot_router)
|
11
|
+
|
12
|
+
main_client_tg_bot_router.include_router(router=healthcheck.tg_bot_router)
|
13
|
+
|
14
|
+
main_client_tg_bot_router.include_router(router=hello_world.tg_bot_router)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
import aiogram
|
4
|
+
from aiogram import Router
|
5
|
+
from aiogram.filters import Command, or_f
|
6
|
+
|
7
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
8
|
+
from project.tg_bot.const import ClientTgBotCommands
|
9
|
+
from project.tg_bot.filter_.message_text import MessageTextTgBotFilter
|
10
|
+
from project.tg_bot.middleware.common import MiddlewareDataTgBot
|
11
|
+
|
12
|
+
tg_bot_router = Router()
|
13
|
+
_logger = logging.getLogger(__name__)
|
14
|
+
|
15
|
+
|
16
|
+
@tg_bot_router.message(
|
17
|
+
or_f(
|
18
|
+
Command(ClientTgBotCommands.start),
|
19
|
+
MessageTextTgBotFilter([
|
20
|
+
"начать",
|
21
|
+
"старт",
|
22
|
+
"привет",
|
23
|
+
"запуск",
|
24
|
+
"start",
|
25
|
+
], ignore_case=True)
|
26
|
+
)
|
27
|
+
)
|
28
|
+
async def _(
|
29
|
+
m: aiogram.types.Message,
|
30
|
+
middleware_data_tg_bot: MiddlewareDataTgBot,
|
31
|
+
**kwargs
|
32
|
+
):
|
33
|
+
await m.answer(text=get_cached_client_tg_bot_blank().welcome())
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from aiogram import Router
|
2
|
+
|
3
|
+
from project.tg_bot import error_handler
|
4
|
+
from project.tg_bot.router.admin.main_router import main_admin_tg_bot_router
|
5
|
+
from project.tg_bot.router.client.main_router import main_client_tg_bot_router
|
6
|
+
|
7
|
+
main_tg_bot_router = Router()
|
8
|
+
|
9
|
+
main_tg_bot_router.include_router(router=error_handler.tg_bot_router)
|
10
|
+
|
11
|
+
main_tg_bot_router.include_router(router=main_admin_tg_bot_router)
|
12
|
+
|
13
|
+
main_tg_bot_router.include_router(router=main_client_tg_bot_router)
|
@@ -6,14 +6,14 @@ from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_applicati
|
|
6
6
|
|
7
7
|
from project.core.settings import get_cached_settings
|
8
8
|
from project.core.util import setup_logging
|
9
|
-
from project.tg_bot.tg_bot import
|
9
|
+
from project.tg_bot.tg_bot import get_cached_tg_bot
|
10
10
|
from project.tg_bot.tg_bot_dispatcher import create_tg_bot_dispatcher
|
11
11
|
|
12
12
|
|
13
13
|
def start_tg_bot():
|
14
14
|
setup_logging()
|
15
15
|
|
16
|
-
tg_bot =
|
16
|
+
tg_bot = get_cached_tg_bot()
|
17
17
|
|
18
18
|
tg_bot_dispatcher = create_tg_bot_dispatcher()
|
19
19
|
|
arpakitlib/{_arpakit_project_template_v_2 → _arpakit_project_template_v_4}/project/tg_bot/tg_bot.py
RENAMED
@@ -1,3 +1,5 @@
|
|
1
|
+
from functools import lru_cache
|
2
|
+
|
1
3
|
import aiogram
|
2
4
|
from aiogram.client.default import DefaultBotProperties
|
3
5
|
from aiogram.client.session.aiohttp import AiohttpSession
|
@@ -22,3 +24,8 @@ def create_tg_bot() -> aiogram.Bot:
|
|
22
24
|
)
|
23
25
|
|
24
26
|
return tg_bot
|
27
|
+
|
28
|
+
|
29
|
+
@lru_cache()
|
30
|
+
def get_cached_tg_bot() -> aiogram.Bot:
|
31
|
+
return create_tg_bot()
|
File without changes
|
File without changes
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import asyncio
|
2
|
+
import logging
|
3
|
+
|
4
|
+
from aiogram.types import BotCommand, BotCommandScopeChat
|
5
|
+
|
6
|
+
from arpakitlib.ar_str_util import return_str_if_none
|
7
|
+
from project.core.util import setup_logging
|
8
|
+
from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
9
|
+
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
10
|
+
from project.tg_bot.blank.client import get_cached_client_tg_bot_blank
|
11
|
+
from project.tg_bot.const import ClientTgBotCommands, AdminTgBotCommands
|
12
|
+
from project.tg_bot.tg_bot import get_cached_tg_bot
|
13
|
+
|
14
|
+
_logger = logging.getLogger(__name__)
|
15
|
+
|
16
|
+
|
17
|
+
def get_client_tg_bot_commands_to_set() -> list[BotCommand]:
|
18
|
+
res = [
|
19
|
+
BotCommand(
|
20
|
+
command=ClientTgBotCommands.start,
|
21
|
+
description=return_str_if_none(
|
22
|
+
get_cached_client_tg_bot_blank().command_to_desc().get(ClientTgBotCommands.start),
|
23
|
+
ClientTgBotCommands.start
|
24
|
+
)
|
25
|
+
),
|
26
|
+
BotCommand(
|
27
|
+
command=ClientTgBotCommands.about,
|
28
|
+
description=return_str_if_none(
|
29
|
+
get_cached_client_tg_bot_blank().command_to_desc().get(ClientTgBotCommands.about),
|
30
|
+
ClientTgBotCommands.about
|
31
|
+
)
|
32
|
+
)
|
33
|
+
]
|
34
|
+
return res
|
35
|
+
|
36
|
+
|
37
|
+
def get_admin_tg_bot_commands_to_set() -> list[BotCommand]:
|
38
|
+
res = []
|
39
|
+
for command in AdminTgBotCommands.values_list():
|
40
|
+
res.append(BotCommand(
|
41
|
+
command=command,
|
42
|
+
description=command
|
43
|
+
))
|
44
|
+
return res
|
45
|
+
|
46
|
+
|
47
|
+
async def set_client_tg_bot_commands():
|
48
|
+
_logger.info(f"start")
|
49
|
+
await get_cached_tg_bot().set_my_commands(commands=get_client_tg_bot_commands_to_set())
|
50
|
+
_logger.info("finish")
|
51
|
+
|
52
|
+
|
53
|
+
async def set_admin_tg_bot_commands():
|
54
|
+
_logger.info(f"start")
|
55
|
+
|
56
|
+
with get_cached_sqlalchemy_db().new_session() as session:
|
57
|
+
user_dbms: list[UserDBM] = session.query(UserDBM).filter(UserDBM.roles.any(UserDBM.Roles.admin)).all()
|
58
|
+
|
59
|
+
for user_dbm in user_dbms:
|
60
|
+
await get_cached_tg_bot().set_my_commands(
|
61
|
+
commands=get_client_tg_bot_commands_to_set() + get_admin_tg_bot_commands_to_set(),
|
62
|
+
scope=BotCommandScopeChat(chat_id=user_dbm.tg_id)
|
63
|
+
)
|
64
|
+
|
65
|
+
_logger.info("finish")
|
66
|
+
|
67
|
+
|
68
|
+
async def __async_example():
|
69
|
+
setup_logging()
|
70
|
+
await set_client_tg_bot_commands()
|
71
|
+
await set_admin_tg_bot_commands()
|
72
|
+
await get_cached_tg_bot().session.close()
|
73
|
+
|
74
|
+
|
75
|
+
if __name__ == '__main__':
|
76
|
+
asyncio.run(__async_example())
|
File without changes
|
arpakitlib/ar_aiogram_util.py
CHANGED
@@ -45,7 +45,6 @@ def as_tg_command(
|
|
45
45
|
*params: TgCommandFlagParam | TgCommandKeyValueParam,
|
46
46
|
desc: str | None = None,
|
47
47
|
passwd_validator: Callable | str | None = None,
|
48
|
-
passwd: str | None = None,
|
49
48
|
remove_message_after_correct_passwd: bool = True
|
50
49
|
):
|
51
50
|
_PASSWD_KEY = "passwd"
|
@@ -53,8 +52,6 @@ def as_tg_command(
|
|
53
52
|
|
54
53
|
params = list(params)
|
55
54
|
|
56
|
-
if passwd_validator is None and passwd is not None:
|
57
|
-
passwd_validator = passwd
|
58
55
|
if passwd_validator is not None:
|
59
56
|
raise_for_types(passwd_validator, [Callable, str])
|
60
57
|
params.append(TgCommandKeyValueParam(key=_PASSWD_KEY, required=True, index=None, need_type=NeedTypes.str_))
|
@@ -14,7 +14,6 @@ from pydantic import ConfigDict, BaseModel
|
|
14
14
|
|
15
15
|
from arpakitlib.ar_enumeration_util import Enumeration
|
16
16
|
from arpakitlib.ar_http_request_util import async_make_http_request
|
17
|
-
from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
|
18
17
|
|
19
18
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
20
19
|
|
@@ -415,70 +414,7 @@ def __example():
|
|
415
414
|
|
416
415
|
|
417
416
|
async def __async_example():
|
418
|
-
|
419
|
-
|
420
|
-
print(f"check_auth")
|
421
|
-
print(safely_transfer_obj_to_json_str(await client.check_auth()))
|
422
|
-
|
423
|
-
print(f"get_weather_in_ufa")
|
424
|
-
print(safely_transfer_obj_to_json_str((await client.get_weather_in_ufa()).model_dump()))
|
425
|
-
|
426
|
-
print(f"get_now_datetime_in_ufa")
|
427
|
-
print(safely_transfer_obj_to_json_str((await client.get_now_datetime_in_ufa()).model_dump()))
|
428
|
-
|
429
|
-
# print(f"get_current_week")
|
430
|
-
# print(safely_transfer_obj_to_json_str((await client.get_current_week()).model_dump()))
|
431
|
-
#
|
432
|
-
# print(f"get_current_semester")
|
433
|
-
# print(safely_transfer_obj_to_json_str((await client.get_current_semester()).model_dump()))
|
434
|
-
#
|
435
|
-
# # Group
|
436
|
-
# print(f"get_groups")
|
437
|
-
# print(safely_transfer_obj_to_json_str((await client.get_groups())))
|
438
|
-
#
|
439
|
-
# print(f"get_group")
|
440
|
-
# if await client.get_group(filter_id=25285, filter_uust_api_id=6674):
|
441
|
-
# print(safely_transfer_obj_to_json_str(
|
442
|
-
# (await client.get_group(filter_id=25285, filter_uust_api_id=6674)).model_dump()))
|
443
|
-
# else:
|
444
|
-
# print("Group is none")
|
445
|
-
#
|
446
|
-
# print(f"find_groups")
|
447
|
-
# print(safely_transfer_obj_to_json_str((await client.find_groups(q="ПИ-427Б"))))
|
448
|
-
#
|
449
|
-
# # Teacher
|
450
|
-
# print(f"get_teachers")
|
451
|
-
# print(safely_transfer_obj_to_json_str((await client.get_teachers())))
|
452
|
-
#
|
453
|
-
# print(f"get_teacher")
|
454
|
-
# if await client.get_teacher(filter_id=16975, filter_uust_api_id=112978):
|
455
|
-
# print(safely_transfer_obj_to_json_str(
|
456
|
-
# (await client.get_teacher(filter_id=16975, filter_uust_api_id=112978)).model_dump()))
|
457
|
-
# else:
|
458
|
-
# print("Teacher is none")
|
459
|
-
#
|
460
|
-
# print(f"find_teachers")
|
461
|
-
# print(safely_transfer_obj_to_json_str((await client.find_teachers(q="Казанцев"))))
|
462
|
-
#
|
463
|
-
# # Group Lesson
|
464
|
-
# print(f"get_group_lessons")
|
465
|
-
# if await client.get_group_lessons(filter_group_id=25285, filter_group_uust_api_id=6674):
|
466
|
-
# print(safely_transfer_obj_to_json_str((await client.get_group_lessons(filter_group_id=25285,
|
467
|
-
# filter_group_uust_api_id=6674))))
|
468
|
-
# else:
|
469
|
-
# print("Group lessons is none")
|
470
|
-
#
|
471
|
-
# # Teacher Lesson
|
472
|
-
# print(f"get_teacher_lessons")
|
473
|
-
# if await client.get_teacher_lessons(filter_teacher_id=16975, filter_teacher_uust_api_id=112978):
|
474
|
-
# print(safely_transfer_obj_to_json_str((await client.get_teacher_lessons(filter_teacher_id=16975,
|
475
|
-
# filter_teacher_uust_api_id=112978))))
|
476
|
-
# else:
|
477
|
-
# print("Teacher lessons is none")
|
478
|
-
#
|
479
|
-
# # Find Any
|
480
|
-
# print(f"find_any")
|
481
|
-
# print(safely_transfer_obj_to_json_str((await client.find_any(q="ПИ"))))
|
417
|
+
pass
|
482
418
|
|
483
419
|
|
484
420
|
if __name__ == '__main__':
|
arpakitlib/ar_json_util.py
CHANGED
@@ -3,33 +3,64 @@
|
|
3
3
|
import json
|
4
4
|
from typing import Any
|
5
5
|
|
6
|
+
import orjson
|
7
|
+
|
8
|
+
from arpakitlib.ar_datetime_util import now_utc_dt
|
9
|
+
|
6
10
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
7
11
|
|
8
12
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
def transfer_json_str_to_data(
|
14
|
+
json_str: str, fast: bool = False
|
15
|
+
) -> dict[Any, Any] | list[Any] | None:
|
16
|
+
if not isinstance(json_str, str):
|
17
|
+
raise ValueError("not isinstance(json_str, str)")
|
18
|
+
if fast:
|
19
|
+
return orjson.loads(json_str)
|
20
|
+
else:
|
21
|
+
return json.loads(json_str)
|
13
22
|
|
14
23
|
|
15
|
-
def
|
24
|
+
def transfer_data_to_json_str(
|
25
|
+
data: dict[Any, Any] | list[Any] | None, beautify: bool = True, fast: bool = False
|
26
|
+
) -> str:
|
16
27
|
if not isinstance(data, dict) and not isinstance(data, list) and data is not None:
|
17
28
|
raise ValueError("not isinstance(data, dict) and not isinstance(data, list) and data is not None")
|
18
|
-
|
29
|
+
if fast:
|
30
|
+
return orjson.dumps(data).decode()
|
31
|
+
else:
|
32
|
+
if beautify:
|
33
|
+
return json.dumps(data, ensure_ascii=False, indent=2, default=str)
|
34
|
+
else:
|
35
|
+
return json.dumps(data, ensure_ascii=False, default=str)
|
19
36
|
|
20
37
|
|
21
|
-
def
|
22
|
-
data: dict[Any, Any] | list[Any] | None
|
38
|
+
def transfer_data_to_json_str_to_data(
|
39
|
+
data: dict[Any, Any] | list[Any] | None, fast: bool = False
|
23
40
|
) -> dict[Any, Any] | list[Any] | None:
|
24
|
-
return
|
41
|
+
return transfer_json_str_to_data(transfer_data_to_json_str(data=data, fast=fast), fast=fast)
|
25
42
|
|
26
43
|
|
27
|
-
def
|
28
|
-
|
44
|
+
def transfer_json_str_to_data_to_json_str(
|
45
|
+
json_str: str, beautify: bool = True, fast: bool = False
|
46
|
+
) -> str:
|
47
|
+
return transfer_data_to_json_str(
|
48
|
+
transfer_json_str_to_data(json_str=json_str, fast=fast), beautify=beautify, fast=fast
|
49
|
+
)
|
29
50
|
|
30
51
|
|
31
52
|
def __example():
|
32
|
-
|
53
|
+
res = {str(k): v * "123" for k, v in enumerate(list(range(90000)))}
|
54
|
+
|
55
|
+
print("---")
|
56
|
+
|
57
|
+
now = now_utc_dt()
|
58
|
+
transfer_data_to_json_str(data=res, beautify=True, fast=False)
|
59
|
+
print(now_utc_dt() - now)
|
60
|
+
|
61
|
+
now = now_utc_dt()
|
62
|
+
transfer_data_to_json_str(data=res, fast=True)
|
63
|
+
print(now_utc_dt() - now)
|
33
64
|
|
34
65
|
|
35
66
|
if __name__ == '__main__':
|
arpakitlib/ar_sqlalchemy_util.py
CHANGED
@@ -12,7 +12,7 @@ from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
|
12
12
|
from sqlalchemy.orm.session import Session
|
13
13
|
|
14
14
|
from arpakitlib.ar_datetime_util import now_utc_dt
|
15
|
-
from arpakitlib.ar_json_util import
|
15
|
+
from arpakitlib.ar_json_util import transfer_data_to_json_str
|
16
16
|
|
17
17
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
18
18
|
|
@@ -105,7 +105,7 @@ class BaseDBM(DeclarativeBase):
|
|
105
105
|
return self.simple_dict(include_sd_properties=True)
|
106
106
|
|
107
107
|
def simple_dict_json(self, *, include_sd_properties: bool = True) -> str:
|
108
|
-
return
|
108
|
+
return transfer_data_to_json_str(self.simple_dict(include_sd_properties=include_sd_properties))
|
109
109
|
|
110
110
|
|
111
111
|
class SQLAlchemyDb:
|