def get_view_restrictions(pages):
 restricted_pages = defaultdict(list)
 if (not get_cms_setting('PERMISSION')):
  return restricted_pages
 if (not pages):
  return restricted_pages
 is_public_pages = (not pages[0].publisher_is_draft)
 if is_public_pages:
  draft_ids = (page.publisher_public_id for page in pages)
  pages = Page.objects.filter(pk__in=draft_ids).select_related('parent')
 pages_list = load_ancestors(pages)
 pages_by_id = dict(((page.pk, page) for page in pages_list))
 page_permissions = PagePermission.objects.filter(page__in=pages_by_id, can_view=True)
 for perm in page_permissions:
  perm._page_cache = pages_by_id[perm.page_id]
  for page_id in perm.get_page_ids():
   restricted_pages[page_id].append(perm)
 return restricted_pages

def get_view_restrictions ( pages ) : restricted_pages = defaultdict ( list ) if ( not get_cms_setting ( 'PERMISSION' ) ) : return restricted_pages if ( not pages ) : return restricted_pages is_public_pages = ( not pages [ 0 ] . publisher_is_draft ) if is_public_pages : draft_ids = ( page . publisher_public_id for page in pages ) pages = Page . objects . filter ( pk__in = draft_ids ) . select_related ( 'parent' ) pages_list = load_ancestors ( pages ) pages_by_id = dict ( ( ( page . pk , page ) for page in pages_list ) ) page_permissions = PagePermission . objects . filter ( page__in = pages_by_id , can_view = True ) for perm in page_permissions : perm . _page_cache = pages_by_id [ perm . page_id ] for page_id in perm . get_page_ids ( ) : restricted_pages [ page_id ] . append ( perm ) return restricted_pages
load all view restrictions for the pages .