'Get html for the descendants (only) of given page or if no page_id is
provided, all the root nodes.
Used for lazy loading pages in cms.pagetree.js
Permission checks is done in admin_utils.get_admin_menu_item_context
which is called by admin_utils.render_admin_menu_item.'

def get_tree(self, request):

    page_id = request.GET.get('pageId', None)
    site_id = request.GET.get('site', None)
    try:
        site_id = int(site_id)
        site = Site.objects.get(id=site_id)
    except (TypeError, ValueError, MultipleObjectsReturned, ObjectDoesNotExist):
        site = get_current_site(request)
    if page_id:
        page = get_object_or_404(self.model, pk=int(page_id))
        pages = page.get_children()
    else:
        pages = Page.get_root_nodes().filter(site=site, publisher_is_draft=True)
    pages = pages.select_related('parent', 'publisher_public', 'site').prefetch_related('children')
    response = render_admin_rows(request, pages, site=site, filtered=False)
    return HttpResponse(response)
