django-ninja-aio-crud 0.10.0__py3-none-any.whl → 0.10.2__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.10.0.dist-info → django_ninja_aio_crud-0.10.2.dist-info}/METADATA +1 -1
- {django_ninja_aio_crud-0.10.0.dist-info → django_ninja_aio_crud-0.10.2.dist-info}/RECORD +6 -6
- ninja_aio/__init__.py +1 -1
- ninja_aio/views.py +26 -25
- {django_ninja_aio_crud-0.10.0.dist-info → django_ninja_aio_crud-0.10.2.dist-info}/WHEEL +0 -0
- {django_ninja_aio_crud-0.10.0.dist-info → django_ninja_aio_crud-0.10.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
ninja_aio/__init__.py,sha256=
|
|
1
|
+
ninja_aio/__init__.py,sha256=kXlRrvKYNdU9gmbossk8GM22iSY4k_go-OeZVJlQyn4,120
|
|
2
2
|
ninja_aio/api.py,sha256=Fe6l3YCy7MW5TY4-Lbl80CFuK2NT2Y7tHfmqPk6Mqak,1735
|
|
3
3
|
ninja_aio/auth.py,sha256=c_ILAySswjbSIqnE9Y0G5n1qreXzAtSAaWfrhyer-i8,1283
|
|
4
4
|
ninja_aio/exceptions.py,sha256=gPnZX1Do2GXudbU8wDYkwhO70Qj0ZNrIJJ2UXRs9vYk,2241
|
|
@@ -7,8 +7,8 @@ ninja_aio/parsers.py,sha256=e_4lGCPV7zs-HTqtdJTc8yQD2KPAn9njbL8nF_Mmgkc,153
|
|
|
7
7
|
ninja_aio/renders.py,sha256=0eYklRKd59aV4cZDom5vLZyA99Ob17OwkpMybsRXvyg,1970
|
|
8
8
|
ninja_aio/schemas.py,sha256=Fzu2ko3kUxkOnrjG5QYdmOXZd2gcpYGjVuocCW44NfQ,473
|
|
9
9
|
ninja_aio/types.py,sha256=TJSGlA7bt4g9fvPhJ7gzH5tKbLagPmZUzfgttEOp4xs,468
|
|
10
|
-
ninja_aio/views.py,sha256=
|
|
11
|
-
django_ninja_aio_crud-0.10.
|
|
12
|
-
django_ninja_aio_crud-0.10.
|
|
13
|
-
django_ninja_aio_crud-0.10.
|
|
14
|
-
django_ninja_aio_crud-0.10.
|
|
10
|
+
ninja_aio/views.py,sha256=Mb38z0QS9Iwe-qB9wuuxcfCOJymRI9SppbHOfns6yHg,20944
|
|
11
|
+
django_ninja_aio_crud-0.10.2.dist-info/licenses/LICENSE,sha256=yrDAYcm0gRp_Qyzo3GQa4BjYjWRkAhGC8QRva__RYq0,1073
|
|
12
|
+
django_ninja_aio_crud-0.10.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
13
|
+
django_ninja_aio_crud-0.10.2.dist-info/METADATA,sha256=NkJRoyTgKiXOQfJyKu91NJqdNF3JOJxHHZQ6QC-ykeU,14139
|
|
14
|
+
django_ninja_aio_crud-0.10.2.dist-info/RECORD,,
|
ninja_aio/__init__.py
CHANGED
ninja_aio/views.py
CHANGED
|
@@ -402,15 +402,14 @@ class APIViewSet:
|
|
|
402
402
|
@self.router.get(
|
|
403
403
|
f"{self.path_retrieve}{rel_path}",
|
|
404
404
|
response={
|
|
405
|
-
200: List[
|
|
406
|
-
|
|
407
|
-
],
|
|
408
|
-
self.error_codes : GenericMessageSchema,
|
|
405
|
+
200: List[model.generate_related_s(),],
|
|
406
|
+
self.error_codes: GenericMessageSchema,
|
|
409
407
|
},
|
|
410
408
|
auth=self.m2m_auth,
|
|
411
409
|
summary=f"Get {rel_util.model._meta.verbose_name_plural.capitalize()}",
|
|
412
410
|
description=f"Get all related {rel_util.model._meta.verbose_name_plural.capitalize()}",
|
|
413
411
|
)
|
|
412
|
+
@paginate(self.pagination_class)
|
|
414
413
|
async def get_related(request: HttpRequest, pk: Path[self.path_schema]): # type: ignore
|
|
415
414
|
obj = await self.model_util.get_object(request, self._get_pk(pk))
|
|
416
415
|
related_manager = getattr(obj, related_name)
|
|
@@ -422,15 +421,19 @@ class APIViewSet:
|
|
|
422
421
|
async for rel_obj in related_qs
|
|
423
422
|
]
|
|
424
423
|
return related_objs
|
|
424
|
+
|
|
425
425
|
get_related.__name__ = f"get_{self.model_util.model_name}_{rel_path}"
|
|
426
|
-
|
|
426
|
+
|
|
427
427
|
if self.m2m_add or self.m2m_remove:
|
|
428
|
-
if self.m2m_add and self.m2m_remove
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
428
|
+
summary = f"{'Add or Remove' if self.m2m_add and self.m2m_remove else 'Add' if self.m2m_add else 'Remove'} {rel_util.model._meta.verbose_name_plural.capitalize()}"
|
|
429
|
+
description = f"{'Add or remove' if self.m2m_add and self.m2m_remove else 'Add' if self.m2m_add else 'Remove'} {rel_util.model._meta.verbose_name_plural.capitalize()}"
|
|
430
|
+
schema_in = (
|
|
431
|
+
M2MSchemaIn
|
|
432
|
+
if self.m2m_add and self.m2m_remove
|
|
433
|
+
else M2MAddSchemaIn
|
|
434
|
+
if self.m2m_add
|
|
435
|
+
else M2MRemoveSchemaIn
|
|
436
|
+
)
|
|
434
437
|
|
|
435
438
|
@self.router.post(
|
|
436
439
|
f"{self.path_retrieve}{rel_path}/",
|
|
@@ -439,10 +442,10 @@ class APIViewSet:
|
|
|
439
442
|
self.error_codes: GenericMessageSchema,
|
|
440
443
|
},
|
|
441
444
|
auth=self.m2m_auth,
|
|
442
|
-
summary=
|
|
443
|
-
description=
|
|
445
|
+
summary=summary,
|
|
446
|
+
description=description,
|
|
444
447
|
)
|
|
445
|
-
async def
|
|
448
|
+
async def manage_related(
|
|
446
449
|
request: HttpRequest,
|
|
447
450
|
pk: Path[self.path_schema], # type: ignore
|
|
448
451
|
data: schema_in, # type: ignore
|
|
@@ -451,14 +454,9 @@ class APIViewSet:
|
|
|
451
454
|
request, self._get_pk(pk)
|
|
452
455
|
)
|
|
453
456
|
related_manager: QuerySet = getattr(obj, related_name)
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
add_objs,
|
|
458
|
-
remove_errors,
|
|
459
|
-
remove_details,
|
|
460
|
-
remove_objs,
|
|
461
|
-
) = [], [], [], [], [], []
|
|
457
|
+
add_errors, add_details, add_objs = [], [], []
|
|
458
|
+
remove_errors, remove_details, remove_objs = [], [], []
|
|
459
|
+
|
|
462
460
|
if self.m2m_add and hasattr(data, "add"):
|
|
463
461
|
(
|
|
464
462
|
add_errors,
|
|
@@ -479,6 +477,7 @@ class APIViewSet:
|
|
|
479
477
|
related_manager,
|
|
480
478
|
remove=True,
|
|
481
479
|
)
|
|
480
|
+
|
|
482
481
|
await asyncio.gather(
|
|
483
482
|
related_manager.aadd(*add_objs),
|
|
484
483
|
related_manager.aremove(*remove_objs),
|
|
@@ -496,8 +495,10 @@ class APIViewSet:
|
|
|
496
495
|
"details": errors,
|
|
497
496
|
},
|
|
498
497
|
}
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
|
|
499
|
+
manage_related.__name__ = (
|
|
500
|
+
f"manage_{self.model_util.model_name}_{rel_path}"
|
|
501
|
+
)
|
|
501
502
|
|
|
502
503
|
def _add_views(self):
|
|
503
504
|
if "all" in self.disable:
|
|
@@ -518,4 +519,4 @@ class APIViewSet:
|
|
|
518
519
|
return self.router
|
|
519
520
|
|
|
520
521
|
def add_views_to_route(self):
|
|
521
|
-
return self.api.add_router(f"{self.api_route_path}", self._add_views())
|
|
522
|
+
return self.api.add_router(f"{self.api_route_path}", self._add_views())
|
|
File without changes
|
{django_ninja_aio_crud-0.10.0.dist-info → django_ninja_aio_crud-0.10.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|