django-ninja-aio-crud 0.11.3__tar.gz → 0.11.4__tar.gz
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.11.3 → django_ninja_aio_crud-0.11.4}/PKG-INFO +1 -1
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/__init__.py +1 -1
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/views.py +19 -8
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/LICENSE +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/README.md +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/api.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/auth.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/decorators.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/exceptions.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/models.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/parsers.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/renders.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/schemas.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/ninja_aio/types.py +0 -0
- {django_ninja_aio_crud-0.11.3 → django_ninja_aio_crud-0.11.4}/pyproject.toml +0 -0
|
@@ -101,7 +101,11 @@ class APIViewSet:
|
|
|
101
101
|
- **retrieve_docs** (`str`): Documentation for the retrieve view.
|
|
102
102
|
- **update_docs** (`str`): Documentation for the update view.
|
|
103
103
|
- **delete_docs** (`str`): Documentation for the delete view.
|
|
104
|
-
- **m2m_relations** (`tuple[ModelSerializer | Model, str]`): Many-to-many relations to manage.
|
|
104
|
+
- **m2m_relations** (`list[tuple[ModelSerializer | Model, str, str, list]]`): Many-to-many relations to manage. Each tuple contains:
|
|
105
|
+
- The related model.
|
|
106
|
+
- The related name on the main model.
|
|
107
|
+
- The name of the path, if not provided a default will be used.
|
|
108
|
+
- The authentication for the m2m views.
|
|
105
109
|
- **m2m_add** (`bool`): Enable add operation for M2M relations.
|
|
106
110
|
- **m2m_remove** (`bool`): Enable remove operation for M2M relations.
|
|
107
111
|
- **m2m_get** (`bool`): Enable get operation for M2M relations.
|
|
@@ -150,12 +154,11 @@ class APIViewSet:
|
|
|
150
154
|
retrieve_docs = "Retrieve a specific object by its primary key."
|
|
151
155
|
update_docs = "Update an object by its primary key."
|
|
152
156
|
delete_docs = "Delete an object by its primary key."
|
|
153
|
-
m2m_relations: list[tuple[ModelSerializer | Model, str]] = []
|
|
157
|
+
m2m_relations: list[tuple[ModelSerializer | Model, str, str, list]] = []
|
|
154
158
|
m2m_add = True
|
|
155
159
|
m2m_remove = True
|
|
156
160
|
m2m_get = True
|
|
157
161
|
m2m_auth: list | None = NOT_SET
|
|
158
|
-
m2m_path: str = ""
|
|
159
162
|
|
|
160
163
|
def __init__(self) -> None:
|
|
161
164
|
self.error_codes = ERROR_CODES
|
|
@@ -396,12 +399,20 @@ class APIViewSet:
|
|
|
396
399
|
return errors, objs_detail, objs
|
|
397
400
|
|
|
398
401
|
def _m2m_views(self):
|
|
399
|
-
for
|
|
402
|
+
for m2m_data in self.m2m_relations:
|
|
403
|
+
m2m_auth = self.m2m_auth
|
|
404
|
+
if len(m2m_data) == 3:
|
|
405
|
+
model, related_name, m2m_path = m2m_data
|
|
406
|
+
elif len(m2m_data) == 4:
|
|
407
|
+
model, related_name, m2m_path, m2m_auth = m2m_data
|
|
408
|
+
else:
|
|
409
|
+
model, related_name = m2m_data
|
|
410
|
+
m2m_path = ""
|
|
400
411
|
rel_util = ModelUtil(model)
|
|
401
412
|
rel_path = (
|
|
402
413
|
rel_util.verbose_name_path_resolver()
|
|
403
|
-
if not
|
|
404
|
-
else
|
|
414
|
+
if not m2m_path
|
|
415
|
+
else m2m_path
|
|
405
416
|
)
|
|
406
417
|
if self.m2m_get:
|
|
407
418
|
|
|
@@ -411,7 +422,7 @@ class APIViewSet:
|
|
|
411
422
|
200: List[model.generate_related_s(),],
|
|
412
423
|
self.error_codes: GenericMessageSchema,
|
|
413
424
|
},
|
|
414
|
-
auth=
|
|
425
|
+
auth=m2m_auth,
|
|
415
426
|
summary=f"Get {rel_util.model._meta.verbose_name_plural.capitalize()}",
|
|
416
427
|
description=f"Get all related {rel_util.model._meta.verbose_name_plural.capitalize()}",
|
|
417
428
|
)
|
|
@@ -446,7 +457,7 @@ class APIViewSet:
|
|
|
446
457
|
200: M2MSchemaOut,
|
|
447
458
|
self.error_codes: GenericMessageSchema,
|
|
448
459
|
},
|
|
449
|
-
auth=
|
|
460
|
+
auth=m2m_auth,
|
|
450
461
|
summary=summary,
|
|
451
462
|
description=description,
|
|
452
463
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|