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

Divio test #160

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feature removed unpublished pages from menu item admin select view fo…
…r page
vipulnarang95 committed Jan 30, 2023
commit bb93ec88defe11caa610783a84944f858c4ddcfb
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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)
==================
8 changes: 7 additions & 1 deletion djangocms_navigation/views.py
Original file line number Diff line number Diff line change
@@ -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)