Newer
Older
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.http import Http404
from django.utils.translation import get_language
class NewsboxCMSEditModeMixinView(object):
"""
Restrict to published content even if user has change permission.
Display drafts, only if us has change permisssion (newsbox.views feature) AND cms toolbar is in
"use draft mode" (edit_mode or build_mode)
If related app page does not exists, raise a 404 to avoid reverse not match into the template
"""
def get(self, request, *args, **kwargs):
if request.resolver_match._func_path.split('.')[0] == 'cms':
if page.publisher_is_draft:
page = page.publisher_draft
if not page.is_published(get_language()):
raise Http404
return super(NewsboxCMSEditModeMixinView, self).get(request, *args, **kwargs)
def get_queryset(self):
queryset = super(NewsboxCMSEditModeMixinView, self).get_queryset()
queryset = queryset.filter(self.model.q_published())
return queryset