From bb93ec88defe11caa610783a84944f858c4ddcfb Mon Sep 17 00:00:00 2001 From: Vipul Narang Date: Mon, 23 Jan 2023 14:23:53 +0530 Subject: [PATCH 01/11] feature removed unpublished pages from menu item admin select view for page --- CHANGELOG.rst | 1 + djangocms_navigation/views.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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..0f569273f 100644 --- a/djangocms_navigation/views.py +++ b/djangocms_navigation/views.py @@ -32,8 +32,14 @@ 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) From 86928aa3b21c422be3105a25d85cd78b5cf60d9e Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:55:43 +0530 Subject: [PATCH 02/11] Update views.py reduced characters in line --- djangocms_navigation/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/djangocms_navigation/views.py b/djangocms_navigation/views.py index 0f569273f..91be896ce 100644 --- a/djangocms_navigation/views.py +++ b/djangocms_navigation/views.py @@ -36,7 +36,9 @@ def get(self, request, *args, **kwargs): # 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'] + 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 queryset_data] From 965cb2ff5f5bca08469ee009b59e6bbfe34550d4 Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:51:37 +0530 Subject: [PATCH 03/11] Update requirements_base.txt corrected released versions --- tests/requirements/requirements_base.txt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index 360803480..d843b3e12 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -6,12 +6,10 @@ 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 -https://github.com/FidelityInternational/djangocms-version-locking/tarball/master#egg=djangocms-version-locking -https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation -https://github.com/FidelityInternational/djangocms-references/tarball/master#egg=djangocms-references -https://github.com/django-cms/djangocms-alias/tarball/master#egg=djangocms-alias +djangocms-versioning==1.2.2 +djangocms-alias==1.11.0 +djangocms-references==1.4.1 +djangocms-version-locking==1.2.0 +django-cms==4.0.1.dev2 +djangocms-text-ckeditor==4.0.1.dev1 +djangocms-moderation==2.1.5 From 857bed41b8aa787166d6f2c4bb943512ebadd799 Mon Sep 17 00:00:00 2001 From: Dennis Schwertel Date: Tue, 19 Dec 2023 11:16:31 +0100 Subject: [PATCH 04/11] dependency test --- tests/requirements/requirements_base.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index d843b3e12..476db111c 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -6,10 +6,10 @@ flake8 isort lxml tox -djangocms-versioning==1.2.2 -djangocms-alias==1.11.0 -djangocms-references==1.4.1 -djangocms-version-locking==1.2.0 -django-cms==4.0.1.dev2 -djangocms-text-ckeditor==4.0.1.dev1 -djangocms-moderation==2.1.5 +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 +https://github.com/FidelityInternational/djangocms-version-locking/tarball/master#egg=djangocms-version-locking +https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation +https://github.com/FidelityInternational/djangocms-references/tarball/master#egg=djangocms-references +https://github.com/django-cms/djangocms-alias/tarball/master#egg=djangocms-alias From 2eaf66af4eb681a23d066768374cbe4540246a57 Mon Sep 17 00:00:00 2001 From: Evan-Pi Date: Mon, 15 Jan 2024 13:54:24 +0100 Subject: [PATCH 05/11] Update dependencies - Pin django-cms to version 4.0.0 - Pin djangocms-alias to version 1.11.0 - Pin djangocms-versioning to version 1.2.2 All of the above where required as they previously followed latest releases for which djangocms-navigation was incompatible with. --- setup.py | 2 +- tests/requirements/requirements_base.txt | 6 +++--- tox.ini | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 6572d8e55..a79dfab59 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ INSTALL_REQUIREMENTS = [ "Django>=1.11,<3.3", - "django-treebeard>=4.3", + "django-treebeard>=4.3,<4.6.0", "django-cms", ] diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index 476db111c..4e9da9c37 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -6,10 +6,10 @@ flake8 isort lxml tox -https://github.com/django-cms/django-cms/tarball/develop-4#egg=django-cms +https://github.com/django-cms/django-cms/tarball/4.0.0#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 +https://github.com/django-cms/djangocms-versioning/tarball/1.2.2#egg=djangocms-versioning https://github.com/FidelityInternational/djangocms-version-locking/tarball/master#egg=djangocms-version-locking https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation https://github.com/FidelityInternational/djangocms-references/tarball/master#egg=djangocms-references -https://github.com/django-cms/djangocms-alias/tarball/master#egg=djangocms-alias +https://github.com/django-cms/djangocms-alias/tarball/1.11.0#egg=djangocms-alias diff --git a/tox.ini b/tox.ini index 72e50f766..77efdb657 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist = flake8 isort - py{37,38,39}-dj{22}-sqlite-cms40 + py{37,38,39}-dj{22,32}-sqlite-cms40 skip_missing_interpreters=True From 654401dadc612bbc7cede7fb960229aaac0deae3 Mon Sep 17 00:00:00 2001 From: Evan-Pi Date: Fri, 26 Jan 2024 19:02:16 +0100 Subject: [PATCH 06/11] Fix bug on unpublished pages filtering logic It seems like page.get_title_obj().versions.first() can be of type NoneType which is something that we need to take into account when trying to access its state attribute. --- djangocms_navigation/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/djangocms_navigation/views.py b/djangocms_navigation/views.py index 91be896ce..da82566c0 100644 --- a/djangocms_navigation/views.py +++ b/djangocms_navigation/views.py @@ -37,7 +37,9 @@ def get(self, request, *args, **kwargs): # 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' + page for page in queryset_data + if getattr(page.get_title_obj().versions.first(), "state", None) + != 'unpublished' ] data = { From 804242becba4f2694289c1a7724af43d4499b6a2 Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Wed, 6 Mar 2024 13:54:15 +0530 Subject: [PATCH 07/11] Update views.py as per comments --- djangocms_navigation/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/djangocms_navigation/views.py b/djangocms_navigation/views.py index da82566c0..e1a7b5540 100644 --- a/djangocms_navigation/views.py +++ b/djangocms_navigation/views.py @@ -9,6 +9,7 @@ from cms.utils import get_current_site, get_language_from_request from djangocms_navigation.utils import is_model_supported, supported_models +from djangocms_versioning.constants import ARCHIVED, UNPUBLISHED class ContentObjectSelect2View(View): @@ -38,8 +39,7 @@ def get(self, request, *args, **kwargs): if model == Page: queryset_data = [ page for page in queryset_data - if getattr(page.get_title_obj().versions.first(), "state", None) - != 'unpublished' + if not getattr(page.get_title_obj().versions.first(), "state", None) in [ ARCHIVED, UNPUBLISHED ] ] data = { From 2594cbad63ab81be80182e10689a964ac808b50f Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Wed, 6 Mar 2024 13:59:10 +0530 Subject: [PATCH 08/11] Update views.py --- djangocms_navigation/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/djangocms_navigation/views.py b/djangocms_navigation/views.py index e1a7b5540..bb49a4ff4 100644 --- a/djangocms_navigation/views.py +++ b/djangocms_navigation/views.py @@ -8,9 +8,10 @@ from cms.models import Page from cms.utils import get_current_site, get_language_from_request -from djangocms_navigation.utils import is_model_supported, supported_models from djangocms_versioning.constants import ARCHIVED, UNPUBLISHED +from djangocms_navigation.utils import is_model_supported, supported_models + class ContentObjectSelect2View(View): menu_content_model = None @@ -39,7 +40,7 @@ def get(self, request, *args, **kwargs): if model == Page: queryset_data = [ page for page in queryset_data - if not getattr(page.get_title_obj().versions.first(), "state", None) in [ ARCHIVED, UNPUBLISHED ] + if not getattr(page.get_title_obj().versions.first(), "state", None) in [ARCHIVED, UNPUBLISHED] ] data = { From e6f806b9e0a73e871213f69f03b4082d4b8e0188 Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:04:43 +0530 Subject: [PATCH 09/11] Update requirements_base.txt pinned djangocms-references --- tests/requirements/requirements_base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index 4e9da9c37..1d43d32d7 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -11,5 +11,5 @@ https://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djang https://github.com/django-cms/djangocms-versioning/tarball/1.2.2#egg=djangocms-versioning https://github.com/FidelityInternational/djangocms-version-locking/tarball/master#egg=djangocms-version-locking https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation -https://github.com/FidelityInternational/djangocms-references/tarball/master#egg=djangocms-references +https://github.com/FidelityInternational/djangocms-references/tarball/1.4.1#egg=djangocms-references https://github.com/django-cms/djangocms-alias/tarball/1.11.0#egg=djangocms-alias From 24e1f9781bbd0cbf05880b74bf2c93ba52b964ad Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:21:41 +0530 Subject: [PATCH 10/11] Update requirements_base.txt reverting back --- tests/requirements/requirements_base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index 1d43d32d7..4e9da9c37 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -11,5 +11,5 @@ https://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djang https://github.com/django-cms/djangocms-versioning/tarball/1.2.2#egg=djangocms-versioning https://github.com/FidelityInternational/djangocms-version-locking/tarball/master#egg=djangocms-version-locking https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation -https://github.com/FidelityInternational/djangocms-references/tarball/1.4.1#egg=djangocms-references +https://github.com/FidelityInternational/djangocms-references/tarball/master#egg=djangocms-references https://github.com/django-cms/djangocms-alias/tarball/1.11.0#egg=djangocms-alias From eaf2bc4faaa558d91bce06534a170049235c6eb3 Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:51:08 +0530 Subject: [PATCH 11/11] Update requirements_base.txt updated references to 1.4.3 --- tests/requirements/requirements_base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index 4e9da9c37..329a0a83e 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -11,5 +11,5 @@ https://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djang https://github.com/django-cms/djangocms-versioning/tarball/1.2.2#egg=djangocms-versioning https://github.com/FidelityInternational/djangocms-version-locking/tarball/master#egg=djangocms-version-locking https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation -https://github.com/FidelityInternational/djangocms-references/tarball/master#egg=djangocms-references +https://github.com/FidelityInternational/djangocms-references/tarball/1.4.3#egg=djangocms-references https://github.com/django-cms/djangocms-alias/tarball/1.11.0#egg=djangocms-alias