arpakitlib 1.7.103__py3-none-any.whl → 1.7.105__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/src/admin1/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/admin1/add_admin_in_app.py +23 -0
- arpakitlib/_arpakit_project_template/src/admin1/admin_auth.py +32 -0
- arpakitlib/_arpakit_project_template/src/admin1/model_view.py +14 -0
- arpakitlib/_arpakit_project_template/src/api/create_api_app.py +5 -2
- arpakitlib/_arpakit_project_template/src/core/settings.py +4 -0
- arpakitlib/ar_fastapi_util.py +0 -9
- {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.105.dist-info}/METADATA +9 -2
- {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.105.dist-info}/RECORD +13 -9
- {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.105.dist-info}/LICENSE +0 -0
- {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.105.dist-info}/NOTICE +0 -0
- {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.105.dist-info}/WHEEL +0 -0
- {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.105.dist-info}/entry_points.txt +0 -0
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
from fastapi import FastAPI
|
2
|
+
from sqladmin import Admin
|
3
|
+
|
4
|
+
from src.admin1.admin_auth import AdminAuth
|
5
|
+
from src.api.transmitted_api_data import TransmittedAPIData
|
6
|
+
|
7
|
+
|
8
|
+
def add_admin1_in_app(*, app: FastAPI) -> FastAPI:
|
9
|
+
transmitted_api_data: TransmittedAPIData = app.state.transmitted_api_data
|
10
|
+
|
11
|
+
authentication_backend = AdminAuth()
|
12
|
+
|
13
|
+
admin = Admin(
|
14
|
+
app=app,
|
15
|
+
engine=transmitted_api_data.sqlalchemy_db.engine,
|
16
|
+
base_url="/admin1",
|
17
|
+
authentication_backend=authentication_backend,
|
18
|
+
title="{PROJECT_NAME}"
|
19
|
+
)
|
20
|
+
|
21
|
+
# admin.add_model_view(CurrentSemesterMV)
|
22
|
+
|
23
|
+
return app
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from sqladmin.authentication import AuthenticationBackend
|
4
|
+
from starlette.requests import Request
|
5
|
+
|
6
|
+
from src.core.settings import get_cached_settings
|
7
|
+
|
8
|
+
|
9
|
+
class AdminAuth(AuthenticationBackend):
|
10
|
+
def __init__(self):
|
11
|
+
self._logger = logging.getLogger(self.__class__.__name__)
|
12
|
+
super().__init__(secret_key=get_cached_settings().sec)
|
13
|
+
|
14
|
+
async def login(self, request: Request) -> bool:
|
15
|
+
form = await request.form()
|
16
|
+
|
17
|
+
# ...
|
18
|
+
|
19
|
+
# request.session.update(...)
|
20
|
+
|
21
|
+
return True
|
22
|
+
|
23
|
+
async def logout(self, request: Request) -> bool:
|
24
|
+
request.session.clear()
|
25
|
+
return True
|
26
|
+
|
27
|
+
async def authenticate(self, request: Request) -> bool:
|
28
|
+
# request.session.get("...")
|
29
|
+
|
30
|
+
# ...
|
31
|
+
|
32
|
+
return True
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from sqladmin import ModelView
|
2
|
+
|
3
|
+
|
4
|
+
class BaseModelView(ModelView):
|
5
|
+
can_create = True
|
6
|
+
can_edit = True
|
7
|
+
can_delete = True
|
8
|
+
can_view_details = True
|
9
|
+
can_export = True
|
10
|
+
page_size = 50
|
11
|
+
page_size_options = [25, 50, 100, 200]
|
12
|
+
save_as = True
|
13
|
+
save_as_continue = True
|
14
|
+
export_types = ["xlsx", "csv", "json"]
|
@@ -2,7 +2,7 @@ from fastapi import FastAPI
|
|
2
2
|
|
3
3
|
from arpakitlib.ar_base_worker_util import SafeRunInBackgroundModes
|
4
4
|
from arpakitlib.ar_fastapi_util import create_fastapi_app, InitSqlalchemyDBStartupAPIEvent, InitFileStoragesInDir, \
|
5
|
-
create_handle_exception, create_story_log_before_response_in_handle_exception,
|
5
|
+
create_handle_exception, create_story_log_before_response_in_handle_exception, \
|
6
6
|
SafeRunWorkerStartupAPIEvent
|
7
7
|
from arpakitlib.ar_operation_execution_util import OperationExecutorWorker, ScheduledOperationCreatorWorker
|
8
8
|
from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
|
@@ -105,11 +105,14 @@ def create_api_app() -> FastAPI:
|
|
105
105
|
shutdown_api_events=shutdown_api_events,
|
106
106
|
transmitted_api_data=transmitted_api_data,
|
107
107
|
main_api_router=main_api_router,
|
108
|
-
contact=DEFAULT_CONTACT,
|
109
108
|
media_dirpath=settings.media_dirpath,
|
110
109
|
static_dirpath=STATIC_DIRPATH
|
111
110
|
)
|
112
111
|
|
112
|
+
if settings.api_enable_admin1:
|
113
|
+
from src.admin1.add_admin_in_app import add_admin1_in_app
|
114
|
+
add_admin1_in_app(app=api_app)
|
115
|
+
|
113
116
|
return api_app
|
114
117
|
|
115
118
|
|
@@ -37,6 +37,8 @@ class Settings(SimpleSettings):
|
|
37
37
|
|
38
38
|
api_correct_token: str | None = "1"
|
39
39
|
|
40
|
+
api_enable_admin1: bool = True
|
41
|
+
|
40
42
|
var_dirname: str | None = "var"
|
41
43
|
|
42
44
|
var_dirpath: str | None = os.path.join(BASE_DIRPATH, var_dirname)
|
@@ -63,6 +65,8 @@ class Settings(SimpleSettings):
|
|
63
65
|
def local_timezone_as_pytz(self) -> Any:
|
64
66
|
return pytz.timezone(self.local_timezone)
|
65
67
|
|
68
|
+
admin1_secret_key: str | None = "85a9583cb91c4de7a78d7eb1e5306a04418c9c43014c447ea8ec8dd5deb4cf71"
|
69
|
+
|
66
70
|
# ...
|
67
71
|
|
68
72
|
|
arpakitlib/ar_fastapi_util.py
CHANGED
@@ -693,12 +693,6 @@ def simple_api_router_for_testing():
|
|
693
693
|
return router
|
694
694
|
|
695
695
|
|
696
|
-
DEFAULT_CONTACT = {
|
697
|
-
"name": "ARPAKIT Company",
|
698
|
-
"email": "support@arpakit.com"
|
699
|
-
}
|
700
|
-
|
701
|
-
|
702
696
|
def create_fastapi_app(
|
703
697
|
*,
|
704
698
|
title: str = "arpakitlib FastAPI",
|
@@ -720,9 +714,6 @@ def create_fastapi_app(
|
|
720
714
|
if handle_exception_ is None:
|
721
715
|
handle_exception_ = create_handle_exception()
|
722
716
|
|
723
|
-
if contact is None:
|
724
|
-
contact = DEFAULT_CONTACT
|
725
|
-
|
726
717
|
if not startup_api_events:
|
727
718
|
startup_api_events = [BaseStartupAPIEvent()]
|
728
719
|
startup_api_events = [v for v in startup_api_events if v is not None]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: arpakitlib
|
3
|
-
Version: 1.7.
|
3
|
+
Version: 1.7.105
|
4
4
|
Summary: arpakitlib
|
5
5
|
Home-page: https://github.com/ARPAKIT-Company/arpakitlib
|
6
6
|
License: Apache-2.0
|
@@ -46,7 +46,7 @@ Requires-Dist: pytz (>=2024.2,<2025.0)
|
|
46
46
|
Requires-Dist: pyzabbix (>=1.3.1,<2.0.0)
|
47
47
|
Requires-Dist: redis (>=5.2.0,<6.0.0)
|
48
48
|
Requires-Dist: requests[socks] (>=2.32.3,<3.0.0)
|
49
|
-
Requires-Dist: sqladmin (>=0.20.1,<0.21.0)
|
49
|
+
Requires-Dist: sqladmin[full] (>=0.20.1,<0.21.0)
|
50
50
|
Requires-Dist: sqlalchemy (>=2.0.36,<3.0.0)
|
51
51
|
Requires-Dist: twine (>=6.0.1,<7.0.0)
|
52
52
|
Requires-Dist: uvicorn (>=0.32.1,<0.33.0)
|
@@ -80,6 +80,13 @@ poetry add arpakitlib
|
|
80
80
|
pip install arpakitlib
|
81
81
|
```
|
82
82
|
|
83
|
+
### Init template
|
84
|
+
|
85
|
+
```
|
86
|
+
# poetry run arpakitlib -c help
|
87
|
+
poetry run arpakitlib -c init_arpakit_project_template -project_dirpath ./ -overwrite_if_exists true -project_name ... -sql_db_port ... (optional) -api_port ... (optional) -ignore_paths_startswith ... (optional) -only_paths_startswith ...(optional)
|
88
|
+
```
|
89
|
+
|
83
90
|
---
|
84
91
|
|
85
92
|
### Links
|
@@ -71,11 +71,15 @@ arpakitlib/_arpakit_project_template/resource/static/helloworld,sha256=eH7Hbcr9I
|
|
71
71
|
arpakitlib/_arpakit_project_template/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
72
72
|
arpakitlib/_arpakit_project_template/src/additional_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
73
73
|
arpakitlib/_arpakit_project_template/src/additional_model/additional_model.py,sha256=4KCOvto9Hj5eMYpvfaJChghhR9bkCvKluGGPWrTezoY,134
|
74
|
+
arpakitlib/_arpakit_project_template/src/admin1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
75
|
+
arpakitlib/_arpakit_project_template/src/admin1/add_admin_in_app.py,sha256=mI4wPh49aEtylunAg4jL7YuCbKGs9RIk1vpmzrlX828,611
|
76
|
+
arpakitlib/_arpakit_project_template/src/admin1/admin_auth.py,sha256=8ONlFhGzja2grk9R8rlSTFY8P5VJKr06iP-p_C1bFiw,765
|
77
|
+
arpakitlib/_arpakit_project_template/src/admin1/model_view.py,sha256=jZLvrPfSHuxNu_Z54jG-CXi97ol6ILSMErgzYTSd8ig,331
|
74
78
|
arpakitlib/_arpakit_project_template/src/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
75
79
|
arpakitlib/_arpakit_project_template/src/api/asgi.py,sha256=a5UBxOyNC8NG3E0ayhiDo3t5tPoB3WtOf2gbZJFWBAA,74
|
76
80
|
arpakitlib/_arpakit_project_template/src/api/auth.py,sha256=dcvj5C9E2F2KCsGZPBBncQf_EvVJAC1qQgnyD8P4ZEw,6
|
77
81
|
arpakitlib/_arpakit_project_template/src/api/const.py,sha256=7d4qD5hedqr7QxVzbfsA7E1bNZn2Pm2U8joXGtpANu0,287
|
78
|
-
arpakitlib/_arpakit_project_template/src/api/create_api_app.py,sha256=
|
82
|
+
arpakitlib/_arpakit_project_template/src/api/create_api_app.py,sha256=dyQ27STh002v1TJsozJr9dM0r0WOU4jjR3_iaYWkq7w,4685
|
79
83
|
arpakitlib/_arpakit_project_template/src/api/event.py,sha256=58wCVyVSIe_kydWi44M0Wvp7bTnV8xvO30gMXzjbFYc,750
|
80
84
|
arpakitlib/_arpakit_project_template/src/api/router/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
81
85
|
arpakitlib/_arpakit_project_template/src/api/router/main_router.py,sha256=Yv699WCJDcdiJMXFg1kPTvolqj-NAGoXfqe-vzbMzIU,228
|
@@ -93,7 +97,7 @@ arpakitlib/_arpakit_project_template/src/api/util.py,sha256=47DEQpj8HBSa-_TImW-5
|
|
93
97
|
arpakitlib/_arpakit_project_template/src/business_service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
94
98
|
arpakitlib/_arpakit_project_template/src/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
95
99
|
arpakitlib/_arpakit_project_template/src/core/const.py,sha256=CZZew674y7LhCAlYhvuF5cV4Zb9nQ17j2Tcuj2GEBf4,1232
|
96
|
-
arpakitlib/_arpakit_project_template/src/core/settings.py,sha256=
|
100
|
+
arpakitlib/_arpakit_project_template/src/core/settings.py,sha256=Q58I0qHbVCfPtZxGcFKPdFMC8KGWiSR0OsxP_kr4-nc,2378
|
97
101
|
arpakitlib/_arpakit_project_template/src/core/util.py,sha256=5R8gvcZdvuDQes45FBnLC2IDv2Jhajp1VhJJYNKYjMQ,1539
|
98
102
|
arpakitlib/_arpakit_project_template/src/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
99
103
|
arpakitlib/_arpakit_project_template/src/db/const.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -149,7 +153,7 @@ arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css,sha256=jzPZlgJTFwSdSphk9C
|
|
149
153
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css.map,sha256=5wq8eXMLU6Zxb45orZPL1zAsBFJReFw6GjYqGpUX3hg,262650
|
150
154
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js,sha256=ffrLZHHEQ_g84A-ul3yWa10Kk09waOAxHcQXPuZuavg,339292
|
151
155
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map,sha256=9UhIW7MqCOZPAz1Sl1IKfZUuhWU0p-LJqrnjjJD9Xhc,1159454
|
152
|
-
arpakitlib/ar_fastapi_util.py,sha256=
|
156
|
+
arpakitlib/ar_fastapi_util.py,sha256=G3UmPZobcCJzmO0Tw-hCoCVIJLDjAcrhXJqM8A6-DcQ,27573
|
153
157
|
arpakitlib/ar_file_storage_in_dir_util.py,sha256=D3e3rGuHoI6xqAA5mVvEpVVpOWY1jyjNsjj2UhyHRbE,3674
|
154
158
|
arpakitlib/ar_file_util.py,sha256=GUdJYm1tUZnYpY-SIPRHAZBHGra8NKy1eYEI0D5AfhY,489
|
155
159
|
arpakitlib/ar_func_util.py,sha256=bCuWbSMoFXBaMNhb89sevj2oaXRk4Jk6Qjot8OXMDT4,1319
|
@@ -179,9 +183,9 @@ arpakitlib/ar_str_util.py,sha256=tFoGSDYoGpfdVHWor5Li9pEOFmDFlHkX-Z8iOy1LK7Y,353
|
|
179
183
|
arpakitlib/ar_type_util.py,sha256=7eqhkRcRpTIsIP_9EvnU-WoySLt1o1Ro88-5ZJui600,3719
|
180
184
|
arpakitlib/ar_yookassa_api_client_util.py,sha256=sh4fcUkAkdOetFn9JYoTvjcSXP-M1wU04KEY-ECLfLg,5137
|
181
185
|
arpakitlib/ar_zabbix_api_client_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
|
182
|
-
arpakitlib-1.7.
|
183
|
-
arpakitlib-1.7.
|
184
|
-
arpakitlib-1.7.
|
185
|
-
arpakitlib-1.7.
|
186
|
-
arpakitlib-1.7.
|
187
|
-
arpakitlib-1.7.
|
186
|
+
arpakitlib-1.7.105.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
187
|
+
arpakitlib-1.7.105.dist-info/METADATA,sha256=D5IJfRiZhi5JdIZ22aW6at2YKBKLpyw59nD5433YF-k,3140
|
188
|
+
arpakitlib-1.7.105.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
|
189
|
+
arpakitlib-1.7.105.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
190
|
+
arpakitlib-1.7.105.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
|
191
|
+
arpakitlib-1.7.105.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|