diff --git a/apps/assets/api.py b/apps/assets/api.py index f3bfedb5a..5f1c73bf0 100644 --- a/apps/assets/api.py +++ b/apps/assets/api.py @@ -18,7 +18,7 @@ from rest_framework.response import Response from rest_framework_bulk import BulkModelViewSet from rest_framework_bulk import ListBulkCreateUpdateDestroyAPIView from django.shortcuts import get_object_or_404 -from django.db.models import Q +from django.db.models import Q, Count from rest_framework.pagination import LimitOffsetPagination from common.mixins import CustomFilterMixin @@ -87,7 +87,7 @@ class AssetGroupViewSet(CustomFilterMixin, BulkModelViewSet): """ Asset group api set, for add,delete,update,list,retrieve resource """ - queryset = AssetGroup.objects.all() + queryset = AssetGroup.objects.all().annotate(asset_count=Count("assets")) serializer_class = serializers.AssetGroupSerializer permission_classes = (IsSuperUser,) diff --git a/apps/assets/serializers.py b/apps/assets/serializers.py index cb939fcc6..024d88e22 100644 --- a/apps/assets/serializers.py +++ b/apps/assets/serializers.py @@ -22,7 +22,7 @@ class AssetGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer): @staticmethod def get_assets_amount(obj): - return obj.assets.count() + return obj.asset_count class AssetUpdateSystemUserSerializer(serializers.ModelSerializer): diff --git a/apps/assets/templates/assets/asset_group_list.html b/apps/assets/templates/assets/asset_group_list.html index e27d78867..58fbbc51c 100644 --- a/apps/assets/templates/assets/asset_group_list.html +++ b/apps/assets/templates/assets/asset_group_list.html @@ -34,10 +34,6 @@ $(document).ready(function(){ var detail_btn = '' + cellData + ''; $(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id)); }}, - {targets: 3, createdCell: function (td, cellData) { - var innerHtml = cellData.length > 30 ? cellData.substring(0, 30) + '...': cellData; - $(td).html('' + innerHtml + ''); - }}, {targets: 4, createdCell: function (td, cellData, rowData) { var update_btn = '{% trans "Update" %}'.replace('{{ DEFAULT_PK }}', cellData); var del_btn = '{% trans "Delete" %}'.replace('{{ DEFAULT_PK }}', cellData); diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index 06db81d85..7a8aa422e 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -274,7 +274,7 @@ EMAIL_HOST_USER = CONFIG.EMAIL_HOST_USER EMAIL_HOST_PASSWORD = CONFIG.EMAIL_HOST_PASSWORD EMAIL_USE_SSL = CONFIG.EMAIL_USE_SSL EMAIL_USE_TLS = CONFIG.EMAIL_USE_TLS -EMAIL_SUBJECT_PREFIX = CONFIG.EMAIL_SUBJECT_PREFIX +EMAIL_SUBJECT_PREFIX = CONFIG.EMAIL_SUBJECT_PREFIX or '' REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions,