django-small-view-set 0.2.2__tar.gz → 0.2.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_small_view_set-0.2.2 → django_small_view_set-0.2.4}/PKG-INFO +1 -2
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/pyproject.toml +2 -3
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/decorators.py +1 -1
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/small_view_set.py +8 -6
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/LICENSE +0 -0
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/README.md +0 -0
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/README.md +0 -0
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/__init__.py +0 -0
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/config.py +0 -0
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/exceptions.py +0 -0
- {django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/helpers.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: django-small-view-set
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.4
|
4
4
|
Summary: A lightweight Django ViewSet alternative with minimal abstraction.
|
5
5
|
Home-page: https://github.com/nateonguitar/django-small-view-set
|
6
6
|
License: MIT
|
@@ -14,7 +14,6 @@ Classifier: Programming Language :: Python :: 3.9
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
16
16
|
Requires-Dist: django (>=3.2)
|
17
|
-
Requires-Dist: pytest-django (>=4.11.1,<5.0.0)
|
18
17
|
Project-URL: Repository, https://github.com/nateonguitar/django-small-view-set
|
19
18
|
Description-Content-Type: text/markdown
|
20
19
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
4
4
|
|
5
5
|
[tool.poetry]
|
6
6
|
name = "django-small-view-set"
|
7
|
-
version = "0.2.
|
7
|
+
version = "0.2.4"
|
8
8
|
description = "A lightweight Django ViewSet alternative with minimal abstraction."
|
9
9
|
readme = "README.md"
|
10
10
|
authors = ["Nate Brooks"]
|
@@ -18,11 +18,10 @@ packages = [
|
|
18
18
|
[tool.poetry.dependencies]
|
19
19
|
python = ">=3.8"
|
20
20
|
django = ">=3.2"
|
21
|
-
pytest-django = "^4.11.1"
|
22
21
|
|
23
22
|
[tool.poetry.dev-dependencies]
|
24
23
|
pytest = "*"
|
25
|
-
pytest-django = "
|
24
|
+
pytest-django = "^4.11.1"
|
26
25
|
|
27
26
|
[tool.pytest.ini_options]
|
28
27
|
DJANGO_SETTINGS_MODULE = "tests.settings"
|
{django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/decorators.py
RENAMED
@@ -61,7 +61,7 @@ def endpoint_disabled(func):
|
|
61
61
|
```python
|
62
62
|
class ExampleViewSet(SmallViewSet):
|
63
63
|
|
64
|
-
@
|
64
|
+
@endpoint(allowed_method=['GET'])
|
65
65
|
@endpoint_disabled
|
66
66
|
def retrieve(self, request: Request) -> JsonResponse:
|
67
67
|
self.protect_retrieve(request)
|
{django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/small_view_set.py
RENAMED
@@ -1,9 +1,10 @@
|
|
1
1
|
import inspect
|
2
2
|
import json
|
3
3
|
import logging
|
4
|
-
from django.http import JsonResponse
|
5
4
|
from urllib.request import Request
|
6
5
|
|
6
|
+
|
7
|
+
from .decorators import endpoint
|
7
8
|
from .exceptions import BadRequest, MethodNotAllowed
|
8
9
|
|
9
10
|
logger = logging.getLogger('app')
|
@@ -79,11 +80,12 @@ class SmallViewSet:
|
|
79
80
|
"""
|
80
81
|
pass
|
81
82
|
|
83
|
+
@endpoint(allowed_methods=['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD'])
|
82
84
|
async def default_router(self, request: Request, pk=None, *args, **kwargs):
|
83
85
|
"""
|
84
86
|
This method routes requests to the appropriate method based on the HTTP method and presence of a primary key (pk).
|
85
87
|
|
86
|
-
It also handles errors and returns appropriate JSON responses by using the decorator @
|
88
|
+
It also handles errors and returns appropriate JSON responses by using the decorator @endpoint(allowed_method=[]).
|
87
89
|
|
88
90
|
GET/POST for collection endpoints and GET/PUT/PATCH/DELETE for detail endpoints.
|
89
91
|
|
@@ -99,23 +101,23 @@ class SmallViewSet:
|
|
99
101
|
path('api/comments/<int:pk>/custom_put/', self.custom_put, name='comments_custom_put_detail'),
|
100
102
|
]
|
101
103
|
|
102
|
-
@
|
104
|
+
@endpoint(allowed_method=['POST'])
|
103
105
|
def create(self, request: Request):
|
104
106
|
self.protect_create(request)
|
105
107
|
. . .
|
106
108
|
|
107
|
-
@
|
109
|
+
@endpoint(allowed_method=['PUT', 'PATCH'])
|
108
110
|
def update(self, request: Request, pk: int):
|
109
111
|
self.protect_update(request)
|
110
112
|
. . .
|
111
113
|
|
112
|
-
@
|
114
|
+
@endpoint(allowed_method=['PUT'])
|
113
115
|
def custom_put(self, request: Request, pk: int):
|
114
116
|
self.protect_update(request)
|
115
117
|
. . .
|
116
118
|
|
117
119
|
@disable_endpoint
|
118
|
-
@
|
120
|
+
@endpoint(allowed_method=['GET'])
|
119
121
|
def some_disabled_endpoint(self, request: Request):
|
120
122
|
self.protect_retrieve(request)
|
121
123
|
. . .
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{django_small_view_set-0.2.2 → django_small_view_set-0.2.4}/src/small_view_set/exceptions.py
RENAMED
File without changes
|
File without changes
|