mirror of https://github.com/jumpserver/jumpserver
perf: 修改标签的搜索
parent
9b2b71dddc
commit
ac5991fc43
|
@ -223,7 +223,7 @@ class LabelFilterBackend(filters.BaseFilterBackend):
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
model = queryset.model
|
model = queryset.model
|
||||||
labeled_resource_cls = model.labels.field.related_model
|
labeled_resource_cls = model._labels.field.related_model
|
||||||
app_label = model._meta.app_label
|
app_label = model._meta.app_label
|
||||||
model_name = model._meta.model_name
|
model_name = model._meta.model_name
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ class LabeledResourceType(LazyObject):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_res_types():
|
def get_res_types():
|
||||||
from rbac.models import ContentType
|
from rbac.models import ContentType
|
||||||
|
from .mixins import LabeledMixin
|
||||||
content_types = ContentType.objects.all()
|
content_types = ContentType.objects.all()
|
||||||
ids = []
|
ids = []
|
||||||
for ct in content_types:
|
for ct in content_types:
|
||||||
|
@ -13,7 +14,7 @@ class LabeledResourceType(LazyObject):
|
||||||
continue
|
continue
|
||||||
if model_cls._meta.parents:
|
if model_cls._meta.parents:
|
||||||
continue
|
continue
|
||||||
if 'labels' in model_cls._meta._forward_fields_map.keys():
|
if issubclass(model_cls, LabeledMixin):
|
||||||
ids.append(ct.id)
|
ids.append(ct.id)
|
||||||
return ContentType.objects.filter(id__in=ids)
|
return ContentType.objects.filter(id__in=ids)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue