general: use django-model-utils InheritanceManager to get cells (#17645)
This commit is contained in:
parent
84bb64e877
commit
6e461b07a9
|
@ -44,6 +44,8 @@ from django.forms.widgets import MediaDefiningClass
|
|||
from django.template import Context, engines
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
from model_utils.managers import InheritanceManager
|
||||
|
||||
from .fields import RichTextField
|
||||
|
||||
from jsonfield import JSONField
|
||||
|
@ -354,6 +356,8 @@ class CellBase(models.Model):
|
|||
subclass = models.IntegerField(default=-1)
|
||||
subclassid = models.IntegerField(default=-1)
|
||||
|
||||
objects = InheritanceManager()
|
||||
|
||||
class Meta:
|
||||
abstract = False
|
||||
|
||||
|
@ -391,11 +395,10 @@ class CellBase(models.Model):
|
|||
def get_cells(cls, cell_filter=None, **kwargs):
|
||||
"""Returns the list of cells of various classes matching **kwargs"""
|
||||
cells = []
|
||||
for klass in get_cell_classes():
|
||||
if cell_filter and not cell_filter(klass):
|
||||
for cell in cls.objects.filter(**kwargs).order_by('order').select_subclasses():
|
||||
if cell_filter and not cell_filter(cell):
|
||||
continue
|
||||
cells.extend(klass.objects.filter(**kwargs))
|
||||
cells.sort(lambda x, y: cmp(x.order, y.order))
|
||||
cells.append(cell)
|
||||
return cells
|
||||
|
||||
def get_reference(self):
|
||||
|
|
|
@ -11,6 +11,7 @@ Architecture: all
|
|||
Depends: ${misc:Depends}, ${python:Depends},
|
||||
python-django (>= 1.8), python-django (<< 1.9),
|
||||
python-djangorestframework (>= 3.3),
|
||||
python-django-model-utils,
|
||||
python-gadjo,
|
||||
python-requests,
|
||||
python-feedparser,
|
||||
|
|
Loading…
Reference in New Issue