django-ninja-aio-crud 2.14.0__py3-none-any.whl → 2.15.1__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.
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.1.dist-info}/METADATA +1 -1
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.1.dist-info}/RECORD +7 -7
- ninja_aio/__init__.py +1 -1
- ninja_aio/auth.py +0 -5
- ninja_aio/models/serializers.py +30 -13
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.1.dist-info}/WHEEL +0 -0
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
ninja_aio/__init__.py,sha256=
|
|
1
|
+
ninja_aio/__init__.py,sha256=UFEs6cNB-kwFYmp9hCdjKOccadx3Y4iBVqJZQgpgOag,120
|
|
2
2
|
ninja_aio/api.py,sha256=tuC7vdvn7s1GkCnSFy9Kn1zv0glZfYptRQVvo8ZRtGQ,2429
|
|
3
|
-
ninja_aio/auth.py,sha256=
|
|
3
|
+
ninja_aio/auth.py,sha256=f4yk45fLi36Qctu0A0zgHTFedb9yk3ewq5rOMpoPYIE,9035
|
|
4
4
|
ninja_aio/exceptions.py,sha256=_3xFqfFCOfrrMhSA0xbMqgXy8R0UQjhXaExrFvaDAjY,3891
|
|
5
5
|
ninja_aio/parsers.py,sha256=e_4lGCPV7zs-HTqtdJTc8yQD2KPAn9njbL8nF_Mmgkc,153
|
|
6
6
|
ninja_aio/renders.py,sha256=CW0xDa05Xna-UvL0MZqZeDEgueEaUassV_nG7Rh1-cw,1824
|
|
@@ -14,7 +14,7 @@ ninja_aio/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
|
14
14
|
ninja_aio/helpers/api.py,sha256=O2nGvP3VSsG-AReQRn90yDH8vS3kMKh125j-ikwgGoQ,20987
|
|
15
15
|
ninja_aio/helpers/query.py,sha256=Lqv4nrWYr543tC5K-SEcBottLID8cb83aDc26i2Wxj4,5053
|
|
16
16
|
ninja_aio/models/__init__.py,sha256=L3UQnQAlKoI3F7jinadL-Nn55hkPvnSRPYW0JtnbWFo,114
|
|
17
|
-
ninja_aio/models/serializers.py,sha256=
|
|
17
|
+
ninja_aio/models/serializers.py,sha256=fwuEQrBcybCNBHPo1i-EHXIX8F4Fd52iduZf_Cl9wE4,42823
|
|
18
18
|
ninja_aio/models/utils.py,sha256=lAXtc3YY7_n4f0jIacX4DSXhUOzMy7y5MsBnInNxtfk,32874
|
|
19
19
|
ninja_aio/schemas/__init__.py,sha256=dHILiYBKMb51lDcyQdiXRw_0nzqM7Lu81UX2hv7kEfo,837
|
|
20
20
|
ninja_aio/schemas/api.py,sha256=dGUpJXR1iAf93QNR4kYj1uqIkTjiMfXultCotY6GtaQ,361
|
|
@@ -24,7 +24,7 @@ ninja_aio/schemas/helpers.py,sha256=h4zQRf21NVLMQbIVH-psAE4FICUBc857EqngblEy7og,
|
|
|
24
24
|
ninja_aio/views/__init__.py,sha256=DEzjWA6y3WF0V10nNF8eEurLNEodgxKzyFd09AqVp3s,148
|
|
25
25
|
ninja_aio/views/api.py,sha256=AAqkj0xT8J3PmJvsbluZ33cfrmrXJHiV9ARe2BqnfQ8,22492
|
|
26
26
|
ninja_aio/views/mixins.py,sha256=Zl6J8gbVagwT85bzDuKyJTk3iFxxFgX0YgYkjiUxZGg,17040
|
|
27
|
-
django_ninja_aio_crud-2.
|
|
28
|
-
django_ninja_aio_crud-2.
|
|
29
|
-
django_ninja_aio_crud-2.
|
|
30
|
-
django_ninja_aio_crud-2.
|
|
27
|
+
django_ninja_aio_crud-2.15.1.dist-info/licenses/LICENSE,sha256=yrDAYcm0gRp_Qyzo3GQa4BjYjWRkAhGC8QRva__RYq0,1073
|
|
28
|
+
django_ninja_aio_crud-2.15.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
29
|
+
django_ninja_aio_crud-2.15.1.dist-info/METADATA,sha256=uc2HGzkCM18x7vvzkykDsBxtm_nwVKKMpwVk-yFaQq8,9964
|
|
30
|
+
django_ninja_aio_crud-2.15.1.dist-info/RECORD,,
|
ninja_aio/__init__.py
CHANGED
ninja_aio/auth.py
CHANGED
|
@@ -107,11 +107,6 @@ class AsyncJwtBearer(HttpBearer):
|
|
|
107
107
|
"""
|
|
108
108
|
try:
|
|
109
109
|
self.dcd = jwt.decode(token, self.jwt_public, algorithms=self.algorithms)
|
|
110
|
-
except ValueError:
|
|
111
|
-
# raise AuthError(", ".join(exc.args), 401)
|
|
112
|
-
return False
|
|
113
|
-
|
|
114
|
-
try:
|
|
115
110
|
self.validate_claims(self.dcd.claims)
|
|
116
111
|
except errors.JoseError:
|
|
117
112
|
return False
|
ninja_aio/models/serializers.py
CHANGED
|
@@ -46,8 +46,23 @@ def _extract_pk(v: Any) -> Any:
|
|
|
46
46
|
return v
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
class PkFromModel:
|
|
50
|
+
"""Subscriptable type for extracting PK from model instances during serialization.
|
|
51
|
+
|
|
52
|
+
Usage:
|
|
53
|
+
PkFromModel[int] -> for integer PKs
|
|
54
|
+
PkFromModel[str] -> for string PKs
|
|
55
|
+
PkFromModel[UUID] -> for UUID PKs
|
|
56
|
+
PkFromModel -> defaults to int (backwards compatible)
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
_default = Annotated[int, BeforeValidator(_extract_pk)]
|
|
60
|
+
|
|
61
|
+
def __class_getitem__(cls, pk_type: type) -> type:
|
|
62
|
+
return Annotated[pk_type, BeforeValidator(_extract_pk)]
|
|
63
|
+
|
|
64
|
+
def __new__(cls):
|
|
65
|
+
return cls._default
|
|
51
66
|
|
|
52
67
|
|
|
53
68
|
class BaseSerializer:
|
|
@@ -290,9 +305,8 @@ class BaseSerializer:
|
|
|
290
305
|
"""
|
|
291
306
|
# Auto-resolve ModelSerializer with readable fields
|
|
292
307
|
if isinstance(rel_model, ModelSerializerMeta):
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return None
|
|
308
|
+
has_readable_fields = rel_model.get_fields("read") or rel_model.get_custom_fields("read")
|
|
309
|
+
return rel_model.generate_related_s() if has_readable_fields else None
|
|
296
310
|
|
|
297
311
|
# Resolve from explicit serializer mapping
|
|
298
312
|
rel_serializers = cls._get_relations_serializers() or {}
|
|
@@ -415,12 +429,14 @@ class BaseSerializer:
|
|
|
415
429
|
|
|
416
430
|
# Handle relations_as_id for reverse relations
|
|
417
431
|
if field_name in relations_as_id:
|
|
432
|
+
from ninja_aio.models.utils import ModelUtil
|
|
433
|
+
pk_field_type = ModelUtil(rel_model).pk_field_type
|
|
418
434
|
if many:
|
|
419
435
|
# For many relations, use PkFromModel to extract PKs from model instances
|
|
420
|
-
return (field_name, list[PkFromModel], Field(default_factory=list))
|
|
436
|
+
return (field_name, list[PkFromModel[pk_field_type]], Field(default_factory=list))
|
|
421
437
|
else:
|
|
422
438
|
# For single reverse relations (ReverseOneToOne), extract pk
|
|
423
|
-
return (field_name, PkFromModel | None, None)
|
|
439
|
+
return (field_name, PkFromModel[pk_field_type] | None, None)
|
|
424
440
|
|
|
425
441
|
schema = cls._resolve_relation_schema(field_name, rel_model)
|
|
426
442
|
if not schema:
|
|
@@ -455,15 +471,16 @@ class BaseSerializer:
|
|
|
455
471
|
|
|
456
472
|
# Handle relations_as_id: serialize as the raw FK ID
|
|
457
473
|
if field_name in relations_as_id:
|
|
474
|
+
from ninja_aio.models.utils import ModelUtil
|
|
475
|
+
pk_field_type = ModelUtil(rel_model).pk_field_type
|
|
458
476
|
# Use PkFromModel to extract pk from the related instance during serialization
|
|
459
|
-
return (field_name, PkFromModel | None, None)
|
|
477
|
+
return (field_name, PkFromModel[pk_field_type] | None, None)
|
|
460
478
|
|
|
461
479
|
# Special case: ModelSerializer with no readable fields should be skipped entirely
|
|
462
|
-
if isinstance(rel_model, ModelSerializerMeta)
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
return None
|
|
480
|
+
if isinstance(rel_model, ModelSerializerMeta) and not (
|
|
481
|
+
rel_model.get_fields("read") or rel_model.get_custom_fields("read")
|
|
482
|
+
):
|
|
483
|
+
return None
|
|
467
484
|
|
|
468
485
|
schema = cls._resolve_relation_schema(field_name, rel_model)
|
|
469
486
|
if not schema:
|
|
File without changes
|
{django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|