mirror of https://github.com/jumpserver/jumpserver
perf: support change gateway platform
parent
1baacd0b2c
commit
7973239424
|
@ -1,4 +1,5 @@
|
|||
from django.db.models import Count
|
||||
from django_filters import rest_framework as filters
|
||||
from rest_framework import generics
|
||||
from rest_framework import serializers
|
||||
from rest_framework.decorators import action
|
||||
|
@ -14,6 +15,14 @@ from common.serializers import GroupedChoiceSerializer
|
|||
__all__ = ['AssetPlatformViewSet', 'PlatformAutomationMethodsApi', 'PlatformProtocolViewSet']
|
||||
|
||||
|
||||
class PlatformFilter(filters.FilterSet):
|
||||
name__startswith = filters.CharFilter(field_name='name', lookup_expr='istartswith')
|
||||
|
||||
class Meta:
|
||||
model = Platform
|
||||
fields = ['name', 'category', 'type']
|
||||
|
||||
|
||||
class AssetPlatformViewSet(JMSModelViewSet):
|
||||
queryset = Platform.objects.all()
|
||||
serializer_classes = {
|
||||
|
@ -21,7 +30,7 @@ class AssetPlatformViewSet(JMSModelViewSet):
|
|||
'list': PlatformListSerializer,
|
||||
'categories': GroupedChoiceSerializer,
|
||||
}
|
||||
filterset_fields = ['name', 'category', 'type']
|
||||
filterset_class = PlatformFilter
|
||||
search_fields = ['name']
|
||||
ordering = ['-internal', 'name']
|
||||
rbac_perms = {
|
||||
|
|
|
@ -14,6 +14,11 @@ class GatewaySerializer(HostSerializer):
|
|||
class Meta(HostSerializer.Meta):
|
||||
model = Gateway
|
||||
|
||||
def validate_platform(self, p):
|
||||
if not p.name.startswith('Gateway'):
|
||||
raise serializers.ValidationError(_('The platform must start with Gateway'))
|
||||
return p
|
||||
|
||||
def validate_name(self, value):
|
||||
queryset = Asset.objects.filter(name=value)
|
||||
if self.instance:
|
||||
|
|
|
@ -543,6 +543,7 @@
|
|||
"GatewayCreate": "Create gateway",
|
||||
"GatewayList": "Gateways",
|
||||
"GatewayUpdate": "Update the gateway",
|
||||
"GatewayPlatformHelpText": "Only platforms with names starting with ‘Gateway’ can be used as gateways.",
|
||||
"GatherAccounts": "Gather accounts",
|
||||
"GatherAccountsHelpText": "Collect account information on assets. the collected account information can be imported into the system for centralized management.",
|
||||
"GatheredAccountList": "Gathered accounts",
|
||||
|
|
|
@ -543,6 +543,7 @@
|
|||
"GatewayCreate": "创建网关",
|
||||
"GatewayList": "网关列表",
|
||||
"GatewayUpdate": "更新网关",
|
||||
"GatewayPlatformHelpText": "网关平台只能选择以 Gateway 开头的平台",
|
||||
"GatherAccounts": "账号收集",
|
||||
"GatherAccountsHelpText": "收集资产上的账号信息。收集后的账号信息可以导入到系统中,方便统一管理",
|
||||
"GatheredAccountList": "收集的账号",
|
||||
|
|
Loading…
Reference in New Issue