perf: 修改 groups api

pull/12928/head
ibuler 2024-03-15 19:18:49 +08:00
parent cae9f03892
commit d04ac09e82
10 changed files with 17 additions and 48 deletions

View File

@ -110,22 +110,10 @@ class BaseType(TextChoices):
def get_community_types(cls):
return cls._get_choices_to_types()
@classmethod
def get_lite_types(cls):
return []
@classmethod
def get_choices(cls):
if not settings.XPACK_ENABLED:
choices = [(tp.value, tp.label) for tp in cls.get_community_types()]
else:
choices = cls.choices
if not settings.LITE:
return choices
lite_choices = cls.get_lite_types()
if lite_choices:
lite_choices = [c.value for c in lite_choices]
choices = [c for c in choices if c[0] in lite_choices]
return choices

View File

@ -107,10 +107,3 @@ class DatabaseTypes(BaseType):
return [
cls.MYSQL, cls.MARIADB, cls.MONGODB, cls.REDIS
]
@classmethod
def get_lite_types(cls):
return [
cls.MYSQL, cls.MARIADB, cls.POSTGRESQL, cls.ORACLE,
cls.SQLSERVER, cls.DB2
]

View File

@ -169,11 +169,11 @@ class AllTypes(ChoicesMixin):
(Category.HOST, HostTypes),
(Category.DEVICE, DeviceTypes),
(Category.DATABASE, DatabaseTypes),
(Category.WEB, WebTypes),
]
if not settings.LITE:
if settings.XPACK_ENABLED:
types.extend([
(Category.CLOUD, CloudTypes),
(Category.WEB, WebTypes),
(Category.GPT, GPTTypes),
(Category.CUSTOM, CustomTypes),
])

View File

@ -7761,7 +7761,7 @@ msgid "Org roles"
msgstr ""
#: users/serializers/user.py:90
msgid "Password option"
msgid "Password setting"
msgstr ""
#: users/serializers/user.py:92

View File

@ -8070,7 +8070,7 @@ msgstr "組織ロール"
#: users/serializers/user.py:90
#, fuzzy
#| msgid "Password prompt"
msgid "Password option"
msgid "Password setting"
msgstr "パスワードプロンプト"
#: users/serializers/user.py:92

View File

@ -7883,7 +7883,7 @@ msgid "Org roles"
msgstr "组织角色"
#: users/serializers/user.py:90
msgid "Password option"
msgid "Password setting"
msgstr "密码选项"
#: users/serializers/user.py:92

View File

@ -47,9 +47,10 @@
"ActiveUsers": "Active Users",
"Activity": "Activities",
"Add": "Add",
"AddAll": "Add all",
"AddAccount": "Add account",
"AddAccountResult": "Second-Level Approver",
"AddAllMembersWarningMsg": "Are you sure you want to add all members?",
"AddAllMembersWarningMsg": "Are you sure add all user to this group ?",
"AddAsset": "Add Assets",
"AddAssetToNode": "Add Assets to Node",
"AddAssetToThisPermission": "Add Assets",
@ -391,9 +392,9 @@
"Download": "Download",
"DownloadCenter": "Download Center",
"DownloadFTPFileTip": "The current action does not record files, or the file size exceeds the threshold (default 100M), or it has not yet been saved to the corresponding storage",
"DownloadImportTemplateMsg": "Download Creation Template",
"DownloadImportTemplateMsg": "Download creation template",
"DownloadReplay": "Download Recording",
"DownloadUpdateTemplateMsg": "Download Update Template",
"DownloadUpdateTemplateMsg": "Download update template",
"DragUploadFileInfo": "Drag files here, or click here to upload",
"DuplicateFileExists": "Uploading a file with the same name is not allowed, please delete the file with the same name",
"Duration": "Duration",
@ -440,7 +441,7 @@
"Expire": "Expired",
"Expired": "Expiration Date",
"Export": "Export",
"ExportAll": "Export All",
"ExportAll": "Export all",
"ExportOnlyFiltered": "Export filtered items",
"ExportOnlySelectedItems": "Export selected items",
"ExportRange": "Export Range",
@ -953,7 +954,7 @@
"Security": "Security",
"Select": "Select",
"SelectAdhoc": "Select Command",
"SelectAll": "Select All",
"SelectAll": "Select all",
"SelectAtLeastOneAssetOrNodeErrMsg": "Select at Least One Asset or Node",
"SelectAttrs": "Select Attributes",
"SelectByAttr": "Attribute Filter",
@ -1039,7 +1040,7 @@
"StrategyHelpTips": "Identify the unique attributes of assets (such as platforms) based on priority of strategies; when an asset's attribute (like nodes) can be configured to multiple, all Actions of the strategies will be executed.",
"StrategyList": "Policy List",
"StrategyUpdate": "Update the Policy",
"SuEnabled": "Enable su",
"SuEnabled": "Enable switch",
"SuFrom": "Switch From",
"Submit": "Submit",
"Success": "Success",
@ -1099,8 +1100,8 @@
"TerminateTaskSendSuccessMsg": "Task termination has been issued, please refresh and check later",
"TermsAndConditions": "Terms and Conditions",
"Test": "Test",
"TestAccountConnective": "Test Account Connectivity",
"TestAssetsConnective": "Test Asset Connectivity",
"TestAccountConnective": "Test Connectivity",
"TestAssetsConnective": "Test Connectivity",
"TestConnection": "Test Connection",
"TestGatewayHelpMessage": "If NAT port mapping is used, please set it to the real port listened to by SSH",
"TestGatewayTestConnection": "Test Connect to Gateway",

View File

@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='applet',
name='can_concurrent',
field=models.BooleanField(default=False, verbose_name='Can concurrent'),
field=models.BooleanField(default=False, verbose_name='Concurrent'),
),
]

View File

@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
#
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.response import Response
from orgs.mixins.api import OrgBulkModelViewSet
from ..models import UserGroup, User
from ..models import UserGroup
from ..serializers import UserGroupSerializer, UserGroupListSerializer
__all__ = ['UserGroupViewSet']
@ -20,13 +17,3 @@ class UserGroupViewSet(OrgBulkModelViewSet):
'list': UserGroupListSerializer,
}
ordering = ('name',)
rbac_perms = (
("add_all_users", "users.add_usergroup"),
)
@action(methods=['post'], detail=True, url_path='add-all-users')
def add_all_users(self, request, *args, **kwargs):
instance = self.get_object()
users = User.get_org_users().exclude(groups__id=instance.id)
instance.users.add(*users)
return Response(status=status.HTTP_200_OK)

View File

@ -87,7 +87,7 @@ class UserSerializer(RolesSerializerMixin, ResourceLabelsMixin, CommonBulkModelS
default=PasswordStrategy.email,
allow_null=True,
required=False,
label=_("Password option"),
label=_("Password setting"),
)
mfa_enabled = serializers.BooleanField(read_only=True, label=_("MFA enabled"))
mfa_force_enabled = serializers.BooleanField(