fastapi-rtk 1.0.13__py3-none-any.whl → 1.0.18__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.
- fastapi_rtk/_version.py +1 -1
- fastapi_rtk/api/model_rest_api.py +7 -7
- fastapi_rtk/manager.py +8 -14
- {fastapi_rtk-1.0.13.dist-info → fastapi_rtk-1.0.18.dist-info}/METADATA +1 -1
- {fastapi_rtk-1.0.13.dist-info → fastapi_rtk-1.0.18.dist-info}/RECORD +8 -8
- {fastapi_rtk-1.0.13.dist-info → fastapi_rtk-1.0.18.dist-info}/WHEEL +0 -0
- {fastapi_rtk-1.0.13.dist-info → fastapi_rtk-1.0.18.dist-info}/entry_points.txt +0 -0
- {fastapi_rtk-1.0.13.dist-info → fastapi_rtk-1.0.18.dist-info}/licenses/LICENSE +0 -0
fastapi_rtk/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.0.
|
|
1
|
+
__version__ = "1.0.18"
|
|
@@ -1050,16 +1050,16 @@ class ModelRestApi(BaseApi):
|
|
|
1050
1050
|
Returns:
|
|
1051
1051
|
Callable[..., Coroutine[Any, Any, Tuple[QuerySchema, AsyncSession | Session | None]]]: The dependency that yields the tuple.
|
|
1052
1052
|
"""
|
|
1053
|
-
session_factory = self.datamodel.get_session_factory()
|
|
1054
1053
|
|
|
1055
|
-
async def dependency(
|
|
1054
|
+
async def dependency(
|
|
1055
|
+
q: self.query_schema = Depends(), # type: ignore
|
|
1056
|
+
session=Depends(self.datamodel.get_session_factory()),
|
|
1057
|
+
):
|
|
1056
1058
|
q: QuerySchema = q
|
|
1057
1059
|
if not self.list_query_count_enabled or not q.with_count:
|
|
1058
|
-
|
|
1059
|
-
return
|
|
1060
|
-
|
|
1061
|
-
async for session in session_factory():
|
|
1062
|
-
yield q, session
|
|
1060
|
+
# TODO: Find a better way to not request session count when not needed
|
|
1061
|
+
return q, None
|
|
1062
|
+
return q, session
|
|
1063
1063
|
|
|
1064
1064
|
return dependency
|
|
1065
1065
|
|
fastapi_rtk/manager.py
CHANGED
|
@@ -81,6 +81,8 @@ class UserManager(IDParser, BaseUserManager[User, int]):
|
|
|
81
81
|
Returns:
|
|
82
82
|
list[Role]: A list of Role objects that match the given role names.
|
|
83
83
|
"""
|
|
84
|
+
if not roles:
|
|
85
|
+
return []
|
|
84
86
|
if isinstance(roles, str):
|
|
85
87
|
roles = [roles]
|
|
86
88
|
statement = select(Role).where(Role.name.in_(roles))
|
|
@@ -354,18 +356,14 @@ class UserManager(IDParser, BaseUserManager[User, int]):
|
|
|
354
356
|
password = user_dict.pop("password")
|
|
355
357
|
user_dict["hashed_password"] = self.password_helper.hash(password)
|
|
356
358
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if request:
|
|
360
|
-
from .setting import Setting
|
|
359
|
+
if roles is None and request:
|
|
360
|
+
from .setting import Setting
|
|
361
361
|
|
|
362
|
-
|
|
362
|
+
roles = Setting.AUTH_USER_REGISTRATION_ROLE
|
|
363
363
|
|
|
364
364
|
# Get the roles if they exist
|
|
365
|
-
if
|
|
366
|
-
|
|
367
|
-
role_names = [role_names]
|
|
368
|
-
user_dict["roles"] = await self.get_roles_by_names(role_names)
|
|
365
|
+
if roles is not None:
|
|
366
|
+
user_dict["roles"] = await self.get_roles_by_names(roles)
|
|
369
367
|
|
|
370
368
|
created_user = await self.user_db.create(user_dict)
|
|
371
369
|
|
|
@@ -408,8 +406,6 @@ class UserManager(IDParser, BaseUserManager[User, int]):
|
|
|
408
406
|
)
|
|
409
407
|
)
|
|
410
408
|
if roles is not None:
|
|
411
|
-
if isinstance(roles, str):
|
|
412
|
-
roles = [roles]
|
|
413
409
|
updated_user_data["roles"] = await self.get_roles_by_names(roles)
|
|
414
410
|
updated_user = await self._update(user, updated_user_data)
|
|
415
411
|
await self.on_after_update(updated_user, updated_user_data, request)
|
|
@@ -718,13 +714,11 @@ class UserManager(IDParser, BaseUserManager[User, int]):
|
|
|
718
714
|
Returns:
|
|
719
715
|
User | dict[str, Any]: The updated user or user dictionary with roles.
|
|
720
716
|
"""
|
|
721
|
-
if
|
|
717
|
+
if role_keys is None:
|
|
722
718
|
return user_or_user_dict
|
|
723
719
|
role_names = [Setting.AUTH_ROLES_MAPPING.get(key, []) for key in role_keys]
|
|
724
720
|
role_names = [name for sublist in role_names for name in sublist]
|
|
725
721
|
role_names = list(dict.fromkeys(role_names).keys())
|
|
726
|
-
if not role_names:
|
|
727
|
-
return user_or_user_dict
|
|
728
722
|
if isinstance(user_or_user_dict, User):
|
|
729
723
|
user_or_user_dict = await self.update({}, user_or_user_dict, role_names)
|
|
730
724
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-rtk
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.18
|
|
4
4
|
Summary: A package that provides a set of tools to build a FastAPI application with a Class-Based CRUD API.
|
|
5
5
|
Project-URL: Homepage, https://codeberg.org/datatactics/fastapi-rtk
|
|
6
6
|
Project-URL: Issues, https://codeberg.org/datatactics/fastapi-rtk/issues
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
fastapi_rtk/__init__.py,sha256=Lg6Er5blOMcbtQSRJMNWbRQ1VX4PWEPMVFm2ie5r8mA,6183
|
|
2
|
-
fastapi_rtk/_version.py,sha256=
|
|
2
|
+
fastapi_rtk/_version.py,sha256=4Q9JfUgIQNLvUFicJMyEkNm8HoOBiK9BeIp9ImHf4Bg,23
|
|
3
3
|
fastapi_rtk/apis.py,sha256=6X_Lhl98m7lKrDRybg2Oe24pLFLJ29eCOQSwCAvpKhY,172
|
|
4
4
|
fastapi_rtk/config.py,sha256=9PZF9E5i1gxmnsZEprZZKxVHSk0dFEklJSplX9NEqdo,14036
|
|
5
5
|
fastapi_rtk/const.py,sha256=sEj_cYeerj9pVwbCu0k5Sy1EYpdr1EHzUjqqbnporgc,4905
|
|
@@ -10,7 +10,7 @@ fastapi_rtk/exceptions.py,sha256=P0qwd4VkeWFotgMVQHgmdT1NphFQaEznKLFIvJzW4Zs,259
|
|
|
10
10
|
fastapi_rtk/fastapi_react_toolkit.py,sha256=lvtieBLzCAlozKQU9dkAUVoW7Ofi1ncri_hDyeHazF4,29803
|
|
11
11
|
fastapi_rtk/filters.py,sha256=weCH3suCxpGJQYmwhj9D1iAqMPiRnmbRiN7stK0rhoE,181
|
|
12
12
|
fastapi_rtk/globals.py,sha256=TcoMHCueM7sFwZ8iYorUe4q-3KpVFfV04RAPuMTYFKY,8863
|
|
13
|
-
fastapi_rtk/manager.py,sha256=
|
|
13
|
+
fastapi_rtk/manager.py,sha256=F57aD0DApH98H7GPpnxrwKHz0nETuxQG2bax4FDfJgM,33737
|
|
14
14
|
fastapi_rtk/middlewares.py,sha256=ycdaAdLIUaNEZ7KotczTHS6OOqy98Mn1_O7Hpe7Sma8,10325
|
|
15
15
|
fastapi_rtk/mixins.py,sha256=78RqwrRJFOz6KAxf-GSNOmRdr7R3b-ws7OIENYlzRQQ,238
|
|
16
16
|
fastapi_rtk/models.py,sha256=lQSqe-r0H7jWBVdqXjEi_bNL1cGQr0YWnyI1ToS_coc,178
|
|
@@ -21,7 +21,7 @@ fastapi_rtk/types.py,sha256=-LPnTIbHvqJW81__gab3EWrhjNmznHhptz0BtXkEAHQ,3612
|
|
|
21
21
|
fastapi_rtk/version.py,sha256=D2cmQf2LNeHOiEfcNzVOOfcAmuLvPEmGEtZv5G54D0c,195
|
|
22
22
|
fastapi_rtk/api/__init__.py,sha256=MwFR7HHppnhbjZGg3sOdQ6nqy9uxnHHXvicpswNFMNA,245
|
|
23
23
|
fastapi_rtk/api/base_api.py,sha256=42I9v3b25lqxNAMDGEtajA5-btIDSyUWF0xMDgGkA8c,8078
|
|
24
|
-
fastapi_rtk/api/model_rest_api.py,sha256=
|
|
24
|
+
fastapi_rtk/api/model_rest_api.py,sha256=cRjMg_v5TsXCare8Tg7b5qQssB6fGo7RpaoGWQvdoO8,106572
|
|
25
25
|
fastapi_rtk/auth/__init__.py,sha256=iX7O41NivBYDfdomEaqm4lUx9KD17wI4g3EFLF6kUTw,336
|
|
26
26
|
fastapi_rtk/auth/auth.py,sha256=F2qZoR7go_7FnvVJrDxUCd6vtRz5XW8yyOv143MWPts,20664
|
|
27
27
|
fastapi_rtk/auth/hashers/__init__.py,sha256=uBThFj2VPPSMSioxYTktNiM4-mVgtDAjTpKA3ZzWxxs,110
|
|
@@ -126,8 +126,8 @@ fastapi_rtk/utils/timezone.py,sha256=62S0pPWuDFFXxV1YTFCsc4uKiSP_Ba36Fv7S3gYjfhs
|
|
|
126
126
|
fastapi_rtk/utils/update_signature.py,sha256=PIzZgNpGEwvDNgQ3G51Zi-QhVV3mbxvUvSwDwf_-yYs,2209
|
|
127
127
|
fastapi_rtk/utils/use_default_when_none.py,sha256=H2HqhKy_8eYk3i1xijEjuaKak0oWkMIkrdz6T7DK9QU,469
|
|
128
128
|
fastapi_rtk/utils/werkzeug.py,sha256=1Gv-oyqSmhVGrmNbB9fDqpqJzPpANOzWf4zMMrhW9UA,3245
|
|
129
|
-
fastapi_rtk-1.0.
|
|
130
|
-
fastapi_rtk-1.0.
|
|
131
|
-
fastapi_rtk-1.0.
|
|
132
|
-
fastapi_rtk-1.0.
|
|
133
|
-
fastapi_rtk-1.0.
|
|
129
|
+
fastapi_rtk-1.0.18.dist-info/METADATA,sha256=XV1b_3Enq1nruSbQvf1nOb9ufulbPMFKoV0Oz-08x5w,1302
|
|
130
|
+
fastapi_rtk-1.0.18.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
131
|
+
fastapi_rtk-1.0.18.dist-info/entry_points.txt,sha256=UuTkxSVIokSlVN28TMhoxzRRUaPxlVRSH3Gsx6yip60,53
|
|
132
|
+
fastapi_rtk-1.0.18.dist-info/licenses/LICENSE,sha256=NDrWi4Qwcxal3u1r2lBWGA6TVh3OeW7yMan098mQz98,1073
|
|
133
|
+
fastapi_rtk-1.0.18.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|