django-ninja-aio-crud 0.6.2__py3-none-any.whl → 0.6.4__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-0.6.2.dist-info → django_ninja_aio_crud-0.6.4.dist-info}/METADATA +5 -5
- {django_ninja_aio_crud-0.6.2.dist-info → django_ninja_aio_crud-0.6.4.dist-info}/RECORD +6 -6
- ninja_aio/__init__.py +1 -1
- ninja_aio/models.py +6 -3
- ninja_aio/views.py +7 -7
- {django_ninja_aio_crud-0.6.2.dist-info → django_ninja_aio_crud-0.6.4.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: django-ninja-aio-crud
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.4
|
|
4
4
|
Summary: Django Ninja AIO CRUD - Rest Framework
|
|
5
5
|
Author: Giuseppe Casillo
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -196,7 +196,7 @@ class Foo(ModelSerializer):
|
|
|
196
196
|
bar = models.CharField(max_length=30, default="")
|
|
197
197
|
active = models.BooleanField(default=False)
|
|
198
198
|
|
|
199
|
-
@
|
|
199
|
+
@property
|
|
200
200
|
def full_name(self):
|
|
201
201
|
return f"{self.name} example_full_name"
|
|
202
202
|
|
|
@@ -472,7 +472,7 @@ api = NinjaAIO()
|
|
|
472
472
|
class FooAPI(APIViewSet):
|
|
473
473
|
model = Foo
|
|
474
474
|
api = api
|
|
475
|
-
|
|
475
|
+
auth = CustomJWTBearer()
|
|
476
476
|
|
|
477
477
|
|
|
478
478
|
class ExampleSchemaOut(Schema):
|
|
@@ -488,10 +488,10 @@ class SumView(APIView):
|
|
|
488
488
|
api = api
|
|
489
489
|
api_router_path = "numbers-sum/"
|
|
490
490
|
router_tag = "Sum"
|
|
491
|
-
|
|
491
|
+
auth = CustomJWTBearer()
|
|
492
492
|
|
|
493
493
|
def views(self):
|
|
494
|
-
@self.router.post("/", response={200: ExampleSchemaOut}, auth=self.
|
|
494
|
+
@self.router.post("/", response={200: ExampleSchemaOut}, auth=self.auth)
|
|
495
495
|
async def sum(request: HttpRequest, data: ExampleSchemaIn):
|
|
496
496
|
return 200, {sum: data.n1 + data.n2}
|
|
497
497
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
ninja_aio/__init__.py,sha256=
|
|
1
|
+
ninja_aio/__init__.py,sha256=He13CnD_ZdNDB5ItYJnH39b2l_xnkGParFmyfLD1cCc,119
|
|
2
2
|
ninja_aio/api.py,sha256=Fe6l3YCy7MW5TY4-Lbl80CFuK2NT2Y7tHfmqPk6Mqak,1735
|
|
3
3
|
ninja_aio/auth.py,sha256=fKboioU4sezPukKJukIwiboxml_KV7irhCH3vGYt5pU,1008
|
|
4
4
|
ninja_aio/exceptions.py,sha256=gPnZX1Do2GXudbU8wDYkwhO70Qj0ZNrIJJ2UXRs9vYk,2241
|
|
5
|
-
ninja_aio/models.py,sha256=
|
|
5
|
+
ninja_aio/models.py,sha256=p8X_G2WVlygDE8UEJ7O2fajauJYu1d_pgcvFPDkHRwc,15638
|
|
6
6
|
ninja_aio/parsers.py,sha256=e_4lGCPV7zs-HTqtdJTc8yQD2KPAn9njbL8nF_Mmgkc,153
|
|
7
7
|
ninja_aio/renders.py,sha256=mHeKNJtmDhZmgFpS9B6SPn5uZFcyVXrsoMhr149LeW8,1555
|
|
8
8
|
ninja_aio/schemas.py,sha256=EgRkfhnzZqwGvdBmqlZixMtMcoD1ZxV_qzJ3fmaAy20,113
|
|
9
9
|
ninja_aio/types.py,sha256=EHznS-6KWLwSX5hLeXbAi7qHWla09_rGeQraiLpH-aY,491
|
|
10
|
-
ninja_aio/views.py,sha256=
|
|
11
|
-
django_ninja_aio_crud-0.6.
|
|
12
|
-
django_ninja_aio_crud-0.6.
|
|
13
|
-
django_ninja_aio_crud-0.6.
|
|
10
|
+
ninja_aio/views.py,sha256=qROag0OsMeVUXcnUYKV7ZmWj4E0F-QH52PI2-56zVRs,9263
|
|
11
|
+
django_ninja_aio_crud-0.6.4.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
|
12
|
+
django_ninja_aio_crud-0.6.4.dist-info/METADATA,sha256=VFT8uPTiMq7nHgAvoRqHmrs9Nh0K0BLR9Z9DF1tWw0Y,13737
|
|
13
|
+
django_ninja_aio_crud-0.6.4.dist-info/RECORD,,
|
ninja_aio/__init__.py
CHANGED
ninja_aio/models.py
CHANGED
|
@@ -51,13 +51,14 @@ class ModelUtil:
|
|
|
51
51
|
pk: int | str = None,
|
|
52
52
|
filters: dict = None,
|
|
53
53
|
getters: dict = None,
|
|
54
|
+
with_qs_request=True,
|
|
54
55
|
):
|
|
55
56
|
get_q = {self.model_pk_name: pk} if pk is not None else {}
|
|
56
57
|
if getters:
|
|
57
58
|
get_q |= getters
|
|
58
59
|
|
|
59
60
|
obj_qs = self.model.objects.select_related()
|
|
60
|
-
if isinstance(self.model, ModelSerializerMeta):
|
|
61
|
+
if isinstance(self.model, ModelSerializerMeta) and with_qs_request:
|
|
61
62
|
obj_qs = await self.model.queryset_request(request)
|
|
62
63
|
|
|
63
64
|
obj_qs = obj_qs.prefetch_related(*self.get_reverse_relations())
|
|
@@ -108,7 +109,9 @@ class ModelUtil:
|
|
|
108
109
|
raise SerializeError({k: ". ".join(exc.args)}, 400)
|
|
109
110
|
if isinstance(field_obj, models.ForeignKey):
|
|
110
111
|
rel_util = ModelUtil(field_obj.related_model)
|
|
111
|
-
rel: ModelSerializer = await rel_util.get_object(
|
|
112
|
+
rel: ModelSerializer = await rel_util.get_object(
|
|
113
|
+
request, v, with_qs_request=False
|
|
114
|
+
)
|
|
112
115
|
payload |= {k: rel}
|
|
113
116
|
new_payload = {
|
|
114
117
|
k: v for k, v in payload.items() if k not in (customs.keys() or optionals)
|
|
@@ -132,7 +135,7 @@ class ModelUtil:
|
|
|
132
135
|
):
|
|
133
136
|
rel_util = ModelUtil(field_obj.related_model)
|
|
134
137
|
rel: ModelSerializer = await rel_util.get_object(
|
|
135
|
-
request, list(v.values())[0]
|
|
138
|
+
request, list(v.values())[0], with_qs_request=False
|
|
136
139
|
)
|
|
137
140
|
if isinstance(field_obj, models.ForeignKey):
|
|
138
141
|
for rel_k, rel_v in v.items():
|
ninja_aio/views.py
CHANGED
|
@@ -18,7 +18,7 @@ class APIView:
|
|
|
18
18
|
api: NinjaAPI
|
|
19
19
|
router_tag: str
|
|
20
20
|
api_route_path: str
|
|
21
|
-
|
|
21
|
+
auth: list | None = NOT_SET
|
|
22
22
|
|
|
23
23
|
def __init__(self) -> None:
|
|
24
24
|
self.router = Router(tags=[self.router_tag])
|
|
@@ -71,7 +71,7 @@ class APIViewSet:
|
|
|
71
71
|
schema_in: Schema | None = None
|
|
72
72
|
schema_out: Schema | None = None
|
|
73
73
|
schema_update: Schema | None = None
|
|
74
|
-
|
|
74
|
+
auth: list | None = NOT_SET
|
|
75
75
|
pagination_class: type[AsyncPaginationBase] = PageNumberPagination
|
|
76
76
|
query_params: dict[str, tuple[type, ...]] = {}
|
|
77
77
|
disable: list[type[VIEW_TYPES]] = []
|
|
@@ -137,7 +137,7 @@ class APIViewSet:
|
|
|
137
137
|
def create_view(self):
|
|
138
138
|
@self.router.post(
|
|
139
139
|
self.path,
|
|
140
|
-
auth=self.
|
|
140
|
+
auth=self.auth,
|
|
141
141
|
response={201: self.schema_out, self.error_codes: GenericMessageSchema},
|
|
142
142
|
)
|
|
143
143
|
async def create(request: HttpRequest, data: self.schema_in):
|
|
@@ -149,7 +149,7 @@ class APIViewSet:
|
|
|
149
149
|
def list_view(self):
|
|
150
150
|
@self.router.get(
|
|
151
151
|
self.path,
|
|
152
|
-
auth=self.
|
|
152
|
+
auth=self.auth,
|
|
153
153
|
response={
|
|
154
154
|
200: List[self.schema_out],
|
|
155
155
|
self.error_codes: GenericMessageSchema,
|
|
@@ -179,7 +179,7 @@ class APIViewSet:
|
|
|
179
179
|
def retrieve_view(self):
|
|
180
180
|
@self.router.get(
|
|
181
181
|
self.path_retrieve,
|
|
182
|
-
auth=self.
|
|
182
|
+
auth=self.auth,
|
|
183
183
|
response={200: self.schema_out, self.error_codes: GenericMessageSchema},
|
|
184
184
|
)
|
|
185
185
|
async def retrieve(request: HttpRequest, pk: Path[self.path_schema]):
|
|
@@ -192,7 +192,7 @@ class APIViewSet:
|
|
|
192
192
|
def update_view(self):
|
|
193
193
|
@self.router.patch(
|
|
194
194
|
self.path_retrieve,
|
|
195
|
-
auth=self.
|
|
195
|
+
auth=self.auth,
|
|
196
196
|
response={200: self.schema_out, self.error_codes: GenericMessageSchema},
|
|
197
197
|
)
|
|
198
198
|
async def update(
|
|
@@ -208,7 +208,7 @@ class APIViewSet:
|
|
|
208
208
|
def delete_view(self):
|
|
209
209
|
@self.router.delete(
|
|
210
210
|
self.path_retrieve,
|
|
211
|
-
auth=self.
|
|
211
|
+
auth=self.auth,
|
|
212
212
|
response={204: None, self.error_codes: GenericMessageSchema},
|
|
213
213
|
)
|
|
214
214
|
async def delete(request: HttpRequest, pk: Path[self.path_schema]):
|
|
File without changes
|