Skip to content

Commit

Permalink
Release 5.11.14
Browse files Browse the repository at this point in the history
### Changelog:
- Fix(backend): Actions shouldn't be routed if they're None.
  • Loading branch information
onegreyonewhite committed Nov 22, 2024
1 parent f788793 commit 87792cd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
10 changes: 10 additions & 0 deletions test_src/test_proj/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,16 @@ def test_openapi_schema_content(self):
'operations_availability',
)

# check None actions
self.assertNotIn(
'delete',
api['paths']['/hosts_without_auth/{id}/'],
)
self.assertNotIn(
'delete',
api['paths']['/cacheable/{id}/host/{host_id}/'],
)

# Check that's schema is correct and fields are working
host_obj = self.get_model_class('test_proj.HostList').objects.create(name='123')
results = self.bulk([
Expand Down
3 changes: 3 additions & 0 deletions test_src/test_proj/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def new_action_detail(self, request, *args, **kwargs):


class HostCreateDummyMixin:
destroy = None

def create(self, request, *args, **kwargs):
return responses.HTTP_201_CREATED("OK")

Expand All @@ -285,6 +287,7 @@ def test_json_serializer(self, request, *_, **__):
CacheableView = create_view(CachableProxyModel)


@nested_view('host', 'id', manager_name=lambda *_, **__: Host.objects.all(), view=HostWithoutAuthViewSet)
class CacheableViewSet(CacheableView):
def get_etag_value(self, model_class, request):
return super().get_etag_value((model_class, gui_version), request)
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ allowlist_externals =
yarn
commands =
pip uninstall vstutils -y
pip cache dir
install: rm -rfv {envdir}/dist/
install: pip wheel {toxinidir} -w {envdir}/dist/ --no-deps
install: bash -ec "pip install -U $(ls {envdir}/dist/*.whl | head -1)[all]"
pwd
install: python -m {env:EXECUTE_ARGS} {posargs}
coverage: pip install -U -e ..[all]
coverage: pip install -v -U -e ..[all]
coverage: python -m test_proj makemigrations vstutils vstutils_api vstutils_webpush --check
coverage: coverage erase --rcfile={env:COVRC}
coverage: coverage run --rcfile={env:COVRC} {env:EXECUTE_ARGS} --durations 20 {posargs}
Expand Down
2 changes: 1 addition & 1 deletion vstutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# pylint: disable=django-not-available
__version__: str = '5.11.13'
__version__: str = '5.11.14'
10 changes: 5 additions & 5 deletions vstutils/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,15 @@ def get_view_methods(cls, detail=False):
if methods is not None:
return methods
methods = []
if not detail and hasattr(cls, 'create'):
if not detail and getattr(cls, 'create', None):
methods.append('post')
if hasattr(cls, 'list') or hasattr(cls, 'retrieve'):
if getattr(cls, 'list', None) or getattr(cls, 'retrieve', None):
methods.append('get')
if detail and hasattr(cls, 'update'):
if detail and getattr(cls, 'update', None):
methods.append('put')
if detail and hasattr(cls, 'partial_update'):
if detail and getattr(cls, 'partial_update', None):
methods.append('patch')
if detail and hasattr(cls, 'destroy'):
if detail and getattr(cls, 'destroy', None):
methods.append('delete')
setattr(cls, attr_name, methods)
return methods
Expand Down

0 comments on commit 87792cd

Please sign in to comment.