Browse Source

perf: 账号模版 protocols 过滤

pull/10337/head
ibuler 2 years ago committed by Jiangjie.Bai
parent
commit
a105748a55
  1. 10
      apps/accounts/api/account/template.py
  2. 6
      apps/assets/const/custom.py

10
apps/accounts/api/account/template.py

@ -1,13 +1,13 @@
from django_filters import rest_framework as drf_filters
from assets.const import Protocol
from accounts import serializers
from accounts.models import AccountTemplate
from orgs.mixins.api import OrgBulkModelViewSet
from rbac.permissions import RBACPermission
from assets.const import Protocol
from common.drf.filters import BaseFilterSet
from common.permissions import UserConfirmation, ConfirmType
from common.views.mixins import RecordViewLogMixin
from common.drf.filters import BaseFilterSet
from orgs.mixins.api import OrgBulkModelViewSet
from rbac.permissions import RBACPermission
class AccountTemplateFilterSet(BaseFilterSet):
@ -27,6 +27,8 @@ class AccountTemplateFilterSet(BaseFilterSet):
continue
_st = protocol_secret_type_map[p].get('secret_types', [])
secret_types.update(_st)
if not secret_types:
secret_types = ['password']
queryset = queryset.filter(secret_type__in=secret_types)
return queryset

6
apps/assets/const/custom.py

@ -48,11 +48,7 @@ class CustomTypes(BaseType):
@classmethod
def internal_platforms(cls):
return {
# cls.PUBLIC: [],
# cls.PRIVATE: [{'name': 'Vmware-vSphere'}],
# cls.K8S: [{'name': 'Kubernetes'}],
}
return {}
@classmethod
def get_custom_platforms(cls):

Loading…
Cancel
Save