def page_ancestors(request):
    page = get_page_from_request(request)
    ancestors_list = list()
    if page:
        ancestors_list = [ ance.reverse_id for ance in page.get_ancestors() if ance.reverse_id ]

    return { 'page_ancestors': ancestors_list }
Пример #2
0
def get_category_from_request(request, use_session=True):
    """Get category for post at current cms page
    """
    try:
        key = request.session.get('referer', 'page_path')
        if use_session:
            request.path = request.session[key]
        page = get_page_from_request(request)
    except KeyError:
            raise Http404('You are behind django-cms')
    language = get_language_from_request(request)
    cms_category_plugins = page.cmsplugin_set.filter(
        Q(language=language) &
        Q(plugin_type__exact='PersonListOnPagePlugin')
    )
    if not cms_category_plugins.count():
        raise Http404('Category not found')
    return cms_category_plugins[0].personsincategory.category
Пример #3
0
 def __get__(self, request, obj_type=None):
     if not hasattr(request, '_current_page_cache'):
         request._current_page_cache = get_page_from_request(request)
     return request._current_page_cache
Пример #4
0
 def __get__(self, request, obj_type=None):
     if not hasattr(request, '_current_page_cache'):
         request._current_page_cache = get_page_from_request(request)
     return request._current_page_cache
Пример #5
0
 def __get__(self, request, obj_type=None):
     if not hasattr(request, '_current_page_cache'):
         request._current_page_cache = get_page_from_request(request) or Page.objects.filter(soft_root=True)[0]
     return request._current_page_cache