From e25306608bf9175b62d683c7336a0b174e4fae7a Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 15 Feb 2023 11:13:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=85=8B=E9=9A=86?= =?UTF-8?q?=E7=BD=91=E5=85=B3=E6=B2=A1=E6=9C=89=E5=85=8B=E9=9A=86=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/domain.py | 4 ++-- apps/assets/serializers/gateway.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/assets/api/domain.py b/apps/assets/api/domain.py index c2cf0da65..7ccaa6dcb 100644 --- a/apps/assets/api/domain.py +++ b/apps/assets/api/domain.py @@ -3,10 +3,10 @@ from django.utils.translation import ugettext as _ from django.views.generic.detail import SingleObjectMixin from rest_framework.serializers import ValidationError from rest_framework.views import APIView, Response - from common.utils import get_logger from assets.tasks import test_gateways_connectivity_manual from orgs.mixins.api import OrgBulkModelViewSet +from .asset import AssetViewSet from .. import serializers from ..models import Domain, Gateway @@ -28,7 +28,7 @@ class DomainViewSet(OrgBulkModelViewSet): return super().get_serializer_class() -class GatewayViewSet(OrgBulkModelViewSet): +class GatewayViewSet(AssetViewSet): perm_model = Gateway filterset_fields = ("domain__name", "name", "domain") search_fields = ("domain__name",) diff --git a/apps/assets/serializers/gateway.py b/apps/assets/serializers/gateway.py index 012348719..78d8afda5 100644 --- a/apps/assets/serializers/gateway.py +++ b/apps/assets/serializers/gateway.py @@ -20,9 +20,7 @@ class GatewaySerializer(HostSerializer): queryset = queryset.exclude(id=self.instance.id) has = queryset.exists() if has: - raise serializers.ValidationError( - _('This field must be unique.') - ) + raise serializers.ValidationError(_('This field must be unique.')) return value