Skip to content
Snippets Groups Projects
compat.py 475 B
Newer Older
Dylann Cordel's avatar
Dylann Cordel committed

try:
    from cms.utils.page import get_page_from_request
except ImportError:
    from cms.utils.page_resolver import get_page_from_request  # noqa


def toolbar_use_draft(request, default=False):
    if hasattr(request, 'toolbar'):
        try:
            use_draft = request.toolbar.edit_mode_active
        except AttributeError:
            # Django CMS < 3.5
            use_draft = request.toolbar.use_draft
    else:
        use_draft = default
    return use_draft