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

Commit

Permalink
Merge pull request #381 from aldryn/issue/fix-preview-mode-mixin-for-…
Browse files Browse the repository at this point in the history
…stuf-users-not-in-edit-mode

Article detail view: Adjust PreviewModeMixin to show not publishe items not in edit mode
  • Loading branch information
Kirill Kniazev committed Apr 22, 2016
2 parents 74998fd + 9608eac commit 915b1a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aldryn_newsblog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ class PreviewModeMixin(EditModeMixin):
"""
def get_queryset(self):
qs = super(PreviewModeMixin, self).get_queryset()
if not self.edit_mode:
# check if user can see unpublished items. this will allow to switch
# to edit mode instead of 404 on article detail page. CMS handles the
# permissions.
user = self.request.user
user_can_edit = user.is_staff or user.is_superuser
if not (self.edit_mode or user_can_edit):
qs = qs.published()
language = translation.get_language()
qs = qs.active_translations(language).namespace(self.namespace)
Expand Down

0 comments on commit 915b1a4

Please sign in to comment.