diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55bd8a566..2ab23deda 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.7, 3.8, 3.9 ] + python-version: [ 3.8, 3.9 ] requirements-file: [ dj22_cms40.txt, dj32_cms40.txt, diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5d7e8c73b..888d3c713 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog Unreleased ========== +* feat: Removed unpublished pages from menu item admin select view for page drop down 1.8.2 (2022-10-25) ================== diff --git a/djangocms_navigation/views.py b/djangocms_navigation/views.py index 61e1c540d..91be896ce 100644 --- a/djangocms_navigation/views.py +++ b/djangocms_navigation/views.py @@ -32,8 +32,16 @@ def get(self, request, *args, **kwargs): if not is_model_supported(self.menu_content_model, model): return HttpResponseBadRequest() + queryset_data = self.get_data() + + # Removing unpublished pages from queryset + if model == Page: + queryset_data = [ + page for page in queryset_data if page.get_title_obj().versions.first().state != 'unpublished' + ] + data = { - "results": [{"text": str(obj), "id": obj.pk} for obj in self.get_data()] + "results": [{"text": str(obj), "id": obj.pk} for obj in queryset_data] } return JsonResponse(data) diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index 360803480..476db111c 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -6,8 +6,6 @@ flake8 isort lxml tox - -# Unreleased django-cms 4.0 compatible packages https://github.com/django-cms/django-cms/tarball/develop-4#egg=django-cms https://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djangocms-text-ckeditor https://github.com/django-cms/djangocms-versioning/tarball/master#egg=djangocms-versioning diff --git a/tox.ini b/tox.ini index 72e50f766..eeb535987 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist = flake8 isort - py{37,38,39}-dj{22}-sqlite-cms40 + py{38,39}-dj{22}-sqlite-cms40 skip_missing_interpreters=True @@ -15,7 +15,6 @@ deps = dj32: -r{toxinidir}/tests/requirements/dj32_cms40.txt basepython = - py37: python3.7 py38: python3.8 py39: python3.9