perf: 优化 labels 绑定资源 (#12361)

* perf: 优化 labels 绑定资源

* perf: 优化 labels list 显示

* perf: add migrations

---------

Co-authored-by: ibuler <ibuler@qq.com>
pull/12363/head
fit2bot 2023-12-19 10:20:11 +08:00 committed by GitHub
parent 1358cf532f
commit 1afad40dd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 3 deletions

View File

@ -45,7 +45,6 @@ class ContentTypeViewSet(JMSModelViewSet):
keyword = request.query_params.get('search')
if keyword:
queryset = content_type.filter_queryset(queryset, keyword)
queryset = queryset.order_by('res_type')
return self.get_paginated_response_from_queryset(queryset)

View File

@ -1,10 +1,10 @@
from django.contrib.contenttypes.models import ContentType
from django.utils.functional import LazyObject
class LabeledResourceType(LazyObject):
@staticmethod
def get_res_types():
from rbac.models import ContentType
content_types = ContentType.objects.all()
ids = []
for ct in content_types:

View File

@ -19,7 +19,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='labeledresource',
name='label',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='labeled_resources', to='labels.label'),
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='labeled_resources', to='labels.label', verbose_name='Label'),
),
migrations.AlterUniqueTogether(
name='labeledresource',