general: do not preload tile cells when rendering page (#54592)

This commit is contained in:
Frédéric Péters 2021-06-04 15:15:55 +02:00
parent b023480505
commit 188be78eaf
2 changed files with 8 additions and 1 deletions

View File

@ -869,6 +869,7 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
prefetch_validity_info=False,
select_related=None,
load_contenttypes=False,
cells_exclude=None,
**kwargs,
):
"""Returns the list of cells of various classes matching **kwargs"""
@ -904,6 +905,8 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
if cell_filter and not cell_filter(klass):
continue
cells_queryset = klass.objects.filter(**kwargs)
if cells_exclude:
cells_queryset = cells_queryset.exclude(cells_exclude)
if extra_filter:
cells_queryset = cells_queryset.filter(extra_filter)
if select_related:

View File

@ -27,6 +27,7 @@ from django.contrib.auth.models import User
from django.core import signing
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.db import transaction
from django.db.models import Q
from django.forms.widgets import Media
from django.http import (
Http404,
@ -567,7 +568,10 @@ def publish_page(request, page, status=200, template_name=None):
return HttpResponseRedirect(redirect_url)
cells = CellBase.get_cells(
page=page, select_related={'data_linkcell': ['link_page']}, prefetch_validity_info=True
page=page,
select_related={'data_linkcell': ['link_page']},
prefetch_validity_info=True,
cells_exclude=Q(placeholder__in=['_auto_tile', '_dashboard', '_suggested_tile']),
)
extend_with_parent_cells(cells, hierarchy=pages)
cells = [x for x in cells if x.is_visible(user=request.user)]