Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Fixes issue with toolbar in some circumstances #351

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion aldryn_newsblog/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class NewsBlogMenu(CMSAttachMenu):
def get_queryset(self, request):
"""Returns base queryset with support for preview-mode."""
queryset = Article.objects
if not (request.toolbar and request.toolbar.edit_mode):
if not (hasattr(request, "toolbar") and
getattr(request.toolbar, "edit_mode", False)):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a new version of Django cms we changed this and newsblog has this code to check edit_mode for old and new django-cms
https://github.com/divio/aldryn-newsblog/blob/master/aldryn_newsblog/compat.py
also:
https://github.com/divio/django-cms/blob/develop/cms/toolbar/toolbar.py#L81
https://github.com/divio/django-cms/blob/develop/cms/toolbar/toolbar.py#L493

but checking hasattr toolbar in a request is good in my opinion

queryset = queryset.published()
return queryset

Expand Down
3 changes: 2 additions & 1 deletion aldryn_newsblog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class EditModeMixin(object):

def dispatch(self, request, *args, **kwargs):
self.edit_mode = (
self.request.toolbar and self.request.toolbar.edit_mode)
hasattr(self.request, "toolbar") and
getattr(self.request.toolbar, "edit_mode"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, we should have here:

self.edit_mode = (
            hasattr(request, "toolbar") and toolbar_edit_mode_active(request))

return super(EditModeMixin, self).dispatch(request, *args, **kwargs)


Expand Down