Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature removed unpublished pages from menu item admin select view fo… #159

Merged
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
==================
Expand Down
12 changes: 11 additions & 1 deletion djangocms_navigation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@ 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 getattr(page.get_title_obj().versions.first(), "state", None)
joshyu marked this conversation as resolved.
Show resolved Hide resolved
!= '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)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

INSTALL_REQUIREMENTS = [
"Django>=1.11,<3.3",
"django-treebeard>=4.3",
"django-treebeard>=4.3,<4.6.0",
"django-cms",
]

Expand Down
8 changes: 3 additions & 5 deletions tests/requirements/requirements_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading