brilliance-admin 0.44.1__py3-none-any.whl → 0.44.3__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.
- brilliance_admin/integrations/sqlalchemy/auth.py +1 -2
- brilliance_admin/integrations/sqlalchemy/fields.py +22 -9
- {brilliance_admin-0.44.1.dist-info → brilliance_admin-0.44.3.dist-info}/METADATA +2 -1
- {brilliance_admin-0.44.1.dist-info → brilliance_admin-0.44.3.dist-info}/RECORD +7 -7
- {brilliance_admin-0.44.1.dist-info → brilliance_admin-0.44.3.dist-info}/WHEEL +0 -0
- {brilliance_admin-0.44.1.dist-info → brilliance_admin-0.44.3.dist-info}/licenses/LICENSE +0 -0
- {brilliance_admin-0.44.1.dist-info → brilliance_admin-0.44.3.dist-info}/top_level.txt +0 -0
|
@@ -122,6 +122,7 @@ class SQLAlchemyJWTAdminAuthentication(AdminAuthentication):
|
|
|
122
122
|
try:
|
|
123
123
|
async with self.db_async_session() as session:
|
|
124
124
|
result = await session.execute(stmt)
|
|
125
|
+
user = result.scalar_one_or_none()
|
|
125
126
|
|
|
126
127
|
except ConnectionRefusedError as e:
|
|
127
128
|
logger.exception(
|
|
@@ -133,8 +134,6 @@ class SQLAlchemyJWTAdminAuthentication(AdminAuthentication):
|
|
|
133
134
|
status_code=500,
|
|
134
135
|
) from e
|
|
135
136
|
|
|
136
|
-
user = result.scalar_one_or_none()
|
|
137
|
-
|
|
138
137
|
if not user:
|
|
139
138
|
raise AdminAPIException(
|
|
140
139
|
APIError(message="User not found", code="user_not_found"),
|
|
@@ -6,7 +6,7 @@ from brilliance_admin.auth import UserABC
|
|
|
6
6
|
from brilliance_admin.exceptions import AdminAPIException, APIError, FieldError
|
|
7
7
|
from brilliance_admin.schema.category import FieldSchemaData
|
|
8
8
|
from brilliance_admin.schema.table.fields.base import TableField
|
|
9
|
-
from brilliance_admin.schema.table.table_models import Record
|
|
9
|
+
from brilliance_admin.schema.table.table_models import AutocompleteData, Record
|
|
10
10
|
from brilliance_admin.translations import LanguageContext
|
|
11
11
|
from brilliance_admin.translations import TranslateText as _
|
|
12
12
|
from brilliance_admin.utils import DeserializeAction
|
|
@@ -96,10 +96,9 @@ class SQLAlchemyRelatedField(TableField):
|
|
|
96
96
|
msg = f'Cannot resolve target model for FK "{field_slug}"'
|
|
97
97
|
raise AttributeError(msg)
|
|
98
98
|
|
|
99
|
-
async def autocomplete(self, model, data, user, *, extra: dict | None = None) -> List[Record]:
|
|
99
|
+
async def autocomplete(self, model, data: AutocompleteData, user, *, extra: dict | None = None) -> List[Record]:
|
|
100
100
|
# pylint: disable=import-outside-toplevel
|
|
101
101
|
from sqlalchemy import select
|
|
102
|
-
from sqlalchemy.sql import expression
|
|
103
102
|
|
|
104
103
|
if extra is None or extra.get('db_async_session') is None:
|
|
105
104
|
msg = f'SQLAlchemyRelatedField.autocomplete {type(self).__name__} requires extra["db_async_session"] (AsyncSession)'
|
|
@@ -113,23 +112,37 @@ class SQLAlchemyRelatedField(TableField):
|
|
|
113
112
|
limit = min(150, data.limit)
|
|
114
113
|
stmt = select(target_model).limit(limit)
|
|
115
114
|
|
|
115
|
+
pk = get_pk(target_model)
|
|
116
|
+
python_pk_type = pk.property.columns[0].type.python_type
|
|
117
|
+
|
|
116
118
|
if data.search_string:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
try:
|
|
120
|
+
value = python_pk_type(data.search_string)
|
|
121
|
+
except (ValueError, TypeError):
|
|
122
|
+
# Search string cannot be cast to primary key type, skip id filter
|
|
123
|
+
value = None
|
|
124
|
+
|
|
125
|
+
stmt = stmt.where(pk == value)
|
|
119
126
|
|
|
120
127
|
# Add already selected choices
|
|
121
|
-
existed_choices = []
|
|
122
128
|
if data.existed_choices:
|
|
123
129
|
existed_choices = [i['key'] for i in data.existed_choices if 'key' in i]
|
|
124
130
|
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
values = []
|
|
132
|
+
for value in existed_choices:
|
|
133
|
+
try:
|
|
134
|
+
values.append(python_pk_type(value))
|
|
135
|
+
except (ValueError, TypeError) as e:
|
|
136
|
+
msg = f'Invalid existed_choices value "{value}" for pk {pk} python_pk_type:{python_pk_type.__name__}'
|
|
137
|
+
raise AdminAPIException(APIError(message=msg), status_code=500) from e
|
|
138
|
+
|
|
139
|
+
stmt = stmt.where(pk.in_(values))
|
|
127
140
|
|
|
128
141
|
async with db_async_session() as session:
|
|
129
142
|
records = (await session.execute(stmt)).scalars().all()
|
|
130
143
|
|
|
131
144
|
for record in records:
|
|
132
|
-
results.append(Record(key=getattr(record,
|
|
145
|
+
results.append(Record(key=getattr(record, pk.key), title=str(record)))
|
|
133
146
|
|
|
134
147
|
return results
|
|
135
148
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brilliance-admin
|
|
3
|
-
Version: 0.44.
|
|
3
|
+
Version: 0.44.3
|
|
4
4
|
Summary: Simple and lightweight data managment framework powered by FastAPI and Vue3 Vuetify all-in-one. Some call it heavenly in its brilliance.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -18,6 +18,7 @@ Requires-Dist: structlog>=25.5.0; extra == "example"
|
|
|
18
18
|
Requires-Dist: rich>=14.2.0; extra == "example"
|
|
19
19
|
Requires-Dist: asyncpg>=0.31.0; extra == "example"
|
|
20
20
|
Requires-Dist: pydantic-settings>=2.12.0; extra == "example"
|
|
21
|
+
Requires-Dist: twine; extra == "example"
|
|
21
22
|
Provides-Extra: tests
|
|
22
23
|
Requires-Dist: pytest>=8.4.2; extra == "tests"
|
|
23
24
|
Requires-Dist: pytest-asyncio>=1.2.0; extra == "tests"
|
|
@@ -17,9 +17,9 @@ brilliance_admin/api/views/settings.py,sha256=2A9suZQONEtW9LkFban29Fe5ipQaaGT0Cz
|
|
|
17
17
|
brilliance_admin/api/views/table.py,sha256=ZCckiEaBVAF7Px-oDWkFkL4F3KmFJi-70LSqFXomovk,5939
|
|
18
18
|
brilliance_admin/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
brilliance_admin/integrations/sqlalchemy/__init__.py,sha256=AmQHOvegS6_uaE4xYDHzRMdA9PyHn0cCt1s1IWc9G2U,318
|
|
20
|
-
brilliance_admin/integrations/sqlalchemy/auth.py,sha256=
|
|
20
|
+
brilliance_admin/integrations/sqlalchemy/auth.py,sha256=N9CjFfnXmKeNbJBxHMDlbPaTQPmYWlYTz_73PYBkaNk,4931
|
|
21
21
|
brilliance_admin/integrations/sqlalchemy/autocomplete.py,sha256=Q2BDwPL3d7FErqYkO-s6Q6pDg2PTZ1RUUAWc9tbllT8,1436
|
|
22
|
-
brilliance_admin/integrations/sqlalchemy/fields.py,sha256=
|
|
22
|
+
brilliance_admin/integrations/sqlalchemy/fields.py,sha256=7D0E4-12rqraqHek2yNuHzRdO7hhxjp0edhJu-mTnWQ,9897
|
|
23
23
|
brilliance_admin/integrations/sqlalchemy/fields_schema.py,sha256=7WkOrt5dVvrsZppNZEZS8QaQPMSrfcWChwOaOFSRVOg,11419
|
|
24
24
|
brilliance_admin/integrations/sqlalchemy/table/__init__.py,sha256=g_in2pLTi8UQnT5uNFA8mLW5mxlT84irQ7yVaP_OSS4,605
|
|
25
25
|
brilliance_admin/integrations/sqlalchemy/table/base.py,sha256=-osqhTvqE7YcBxsAjqIUMWyYk1df04GIDmdvtieTXcg,4885
|
|
@@ -66,8 +66,8 @@ brilliance_admin/static/tinymce/plugins/codesample/css/prism.css,sha256=exAdMtHb
|
|
|
66
66
|
brilliance_admin/static/tinymce/plugins/customLink/plugin.js,sha256=illBNpnHDkBsLG6wo_jDPF6z7CGnO1MQWUoDwZKy6vQ,5589
|
|
67
67
|
brilliance_admin/static/tinymce/plugins/customLink/css/link.css,sha256=gh5nvY8Z92hJfCEBPnIm4jIPCcKKbJnab-30oIfX7Hc,56
|
|
68
68
|
brilliance_admin/templates/index.html,sha256=JK7a-EQtaRweQJ1KoXc3L82M4d7GSCXJEe85cxuvWaQ,1294
|
|
69
|
-
brilliance_admin-0.44.
|
|
70
|
-
brilliance_admin-0.44.
|
|
71
|
-
brilliance_admin-0.44.
|
|
72
|
-
brilliance_admin-0.44.
|
|
73
|
-
brilliance_admin-0.44.
|
|
69
|
+
brilliance_admin-0.44.3.dist-info/licenses/LICENSE,sha256=rgWE5Cxk53W0PhTOVmcQedABEWN1QMG-PRz3fz531sE,1074
|
|
70
|
+
brilliance_admin-0.44.3.dist-info/METADATA,sha256=LozqBEUQsCnU5hR6tlynhFb8ZmCg4rkfIeMMNhpukXI,6951
|
|
71
|
+
brilliance_admin-0.44.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
72
|
+
brilliance_admin-0.44.3.dist-info/top_level.txt,sha256=almFFSWrVYieI3i54hYL0fMUaeuIYiazS2Kx4wtK-ns,17
|
|
73
|
+
brilliance_admin-0.44.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|