diff --git a/apps/assets/serializers/domain.py b/apps/assets/serializers/domain.py index 0d9c4a6f5..5d8d0e8d8 100644 --- a/apps/assets/serializers/domain.py +++ b/apps/assets/serializers/domain.py @@ -59,7 +59,7 @@ class GatewaySerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer): 'created_by', 'comment', ] fields_fk = ['domain'] - fields = fields_small + fields_fk + fields = fields_small + fields_fk extra_kwargs = { 'password': {'write_only': True, 'validators': [NoSpecialChars()]}, 'private_key': {"write_only": True}, @@ -78,12 +78,12 @@ class GatewaySerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer): class GatewayWithAuthSerializer(GatewaySerializer): - def get_field_names(self, declared_fields, info): - fields = super().get_field_names(declared_fields, info) - fields.extend( - ['password', 'private_key'] - ) - return fields + class Meta(GatewaySerializer.Meta): + extra_kwargs = { + 'password': {'write_only': False, 'validators': [NoSpecialChars()]}, + 'private_key': {"write_only": False}, + 'public_key': {"write_only": False}, + } class DomainWithGatewaySerializer(BulkOrgResourceModelSerializer): diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index 7bb8dd095..68be2776b 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -279,7 +279,7 @@ class Config(dict): 'WINDOWS_SSH_DEFAULT_SHELL': 'cmd', 'FLOWER_URL': "127.0.0.1:5555", 'DEFAULT_ORG_SHOW_ALL_USERS': True, - 'PERIOD_TASK_ENABLE': True, + 'PERIOD_TASK_ENABLED': True, 'FORCE_SCRIPT_NAME': '', 'LOGIN_CONFIRM_ENABLE': False, 'WINDOWS_SKIP_ALL_MANUAL_PASSWORD': False, diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index 231c4df8c..b3bde6600 100644 Binary files a/apps/locale/zh/LC_MESSAGES/django.mo and b/apps/locale/zh/LC_MESSAGES/django.mo differ diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index 8cf941acb..a64dde7cd 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: JumpServer 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-20 14:56+0800\n" +"POT-Creation-Date: 2021-05-21 11:08+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -184,7 +184,7 @@ msgstr "格式为逗号分隔的字符串, * 表示匹配所有. " #: users/templates/users/_select_user_modal.html:14 #: xpack/plugins/change_auth_plan/models.py:47 #: xpack/plugins/change_auth_plan/models.py:278 -#: xpack/plugins/cloud/serializers.py:71 +#: xpack/plugins/cloud/serializers.py:65 msgid "Username" msgstr "用户名" @@ -285,7 +285,7 @@ msgid "Cluster" msgstr "集群" #: applications/serializers/attrs/application_category/db.py:11 -#: ops/models/adhoc.py:146 xpack/plugins/cloud/serializers.py:69 +#: ops/models/adhoc.py:146 xpack/plugins/cloud/serializers.py:63 msgid "Host" msgstr "主机" @@ -295,7 +295,7 @@ msgstr "主机" #: applications/serializers/attrs/application_type/oracle.py:11 #: applications/serializers/attrs/application_type/pgsql.py:11 #: assets/models/asset.py:188 assets/models/domain.py:53 -#: xpack/plugins/cloud/serializers.py:70 +#: xpack/plugins/cloud/serializers.py:64 msgid "Port" msgstr "端口" @@ -325,7 +325,7 @@ msgstr "目标URL" #: xpack/plugins/change_auth_plan/models.py:68 #: xpack/plugins/change_auth_plan/models.py:190 #: xpack/plugins/change_auth_plan/models.py:285 -#: xpack/plugins/cloud/serializers.py:73 +#: xpack/plugins/cloud/serializers.py:67 msgid "Password" msgstr "密码" @@ -407,7 +407,7 @@ msgstr "激活" #: assets/models/asset.py:196 assets/models/cluster.py:19 #: assets/models/user.py:66 templates/_nav.html:44 -#: xpack/plugins/cloud/models.py:92 xpack/plugins/cloud/serializers.py:166 +#: xpack/plugins/cloud/models.py:92 xpack/plugins/cloud/serializers.py:160 msgid "Admin user" msgstr "管理用户" @@ -678,7 +678,7 @@ msgstr "ssh私钥" #: users/templates/users/user_asset_permission.html:41 #: users/templates/users/user_asset_permission.html:73 #: users/templates/users/user_asset_permission.html:158 -#: xpack/plugins/cloud/models.py:89 xpack/plugins/cloud/serializers.py:167 +#: xpack/plugins/cloud/models.py:89 xpack/plugins/cloud/serializers.py:161 msgid "Node" msgstr "节点" @@ -3999,7 +3999,7 @@ msgid "Security token validation" msgstr "安全令牌验证" #: users/templates/users/_base_otp.html:14 xpack/plugins/cloud/models.py:78 -#: xpack/plugins/cloud/serializers.py:165 +#: xpack/plugins/cloud/serializers.py:159 msgid "Account" msgstr "账户" @@ -4740,7 +4740,7 @@ msgstr "云服务商" msgid "Cloud account" msgstr "云账号" -#: xpack/plugins/cloud/models.py:81 xpack/plugins/cloud/serializers.py:146 +#: xpack/plugins/cloud/models.py:81 xpack/plugins/cloud/serializers.py:140 msgid "Regions" msgstr "地域" @@ -4748,7 +4748,7 @@ msgstr "地域" msgid "Hostname strategy" msgstr "主机名策略" -#: xpack/plugins/cloud/models.py:95 xpack/plugins/cloud/serializers.py:169 +#: xpack/plugins/cloud/models.py:95 xpack/plugins/cloud/serializers.py:163 msgid "Always update" msgstr "总是更新" @@ -4940,19 +4940,19 @@ msgstr "" msgid "Subscription ID" msgstr "" -#: xpack/plugins/cloud/serializers.py:55 -msgid "{} is required" -msgstr "{} 字段是必填项" +#: xpack/plugins/cloud/serializers.py:49 +msgid "This field is required" +msgstr "这个字段是必填项" -#: xpack/plugins/cloud/serializers.py:144 +#: xpack/plugins/cloud/serializers.py:138 msgid "History count" msgstr "执行次数" -#: xpack/plugins/cloud/serializers.py:145 +#: xpack/plugins/cloud/serializers.py:139 msgid "Instance count" msgstr "实例个数" -#: xpack/plugins/cloud/serializers.py:168 +#: xpack/plugins/cloud/serializers.py:162 #: xpack/plugins/gathered_user/serializers.py:20 msgid "Periodic display" msgstr "定时执行" @@ -5045,6 +5045,9 @@ msgstr "旗舰版" msgid "Community edition" msgstr "社区版" +#~ msgid "{} is required" +#~ msgstr "{} 字段是必填项" + #~ msgid "AppSecret is required" #~ msgstr "AppSecret 是必须的" diff --git a/apps/orgs/caches.py b/apps/orgs/caches.py index 8b5a61b51..5ca445479 100644 --- a/apps/orgs/caches.py +++ b/apps/orgs/caches.py @@ -78,12 +78,12 @@ class OrgResourceStatisticsCache(OrgRelatedCache): return self.org def compute_users_amount(self): - if self.org.is_root(): - users_amount = User.objects.exclude(role='App').count() - else: - users_amount = OrganizationMember.objects.values( - 'user_id' - ).filter(org_id=self.org.id).distinct().count() + users = User.objects.exclude(role='App') + + if not self.org.is_root(): + users = users.filter(m2m_org_members__org_id=self.org.id) + + users_amount = users.values('id').distinct().count() return users_amount def compute_assets_amount(self): diff --git a/config_example.yml b/config_example.yml index c3e2ce0f5..9fa4c1814 100644 --- a/config_example.yml +++ b/config_example.yml @@ -122,7 +122,7 @@ REDIS_PORT: 6379 # USER_LOGIN_SINGLE_MACHINE_ENABLED: False # # 启用定时任务 -# PERIOD_TASK_ENABLE: True +# PERIOD_TASK_ENABLED: True # # 启用二次复合认证配置 # LOGIN_CONFIRM_ENABLE: False