diff --git a/apps/assets/templates/assets/user_asset_list.html b/apps/assets/templates/assets/user_asset_list.html index 3c5cdc4a1..2a8c8cf64 100644 --- a/apps/assets/templates/assets/user_asset_list.html +++ b/apps/assets/templates/assets/user_asset_list.html @@ -76,7 +76,7 @@ $(document).ready(function () { 'ip': "{% trans 'IP' %}", 'protocols': "{% trans 'Protocols' %}", 'platform': "{% trans 'Platform' %}", - 'system_users_join': "{% trans 'System user' %}", + {#'system_users_join': "{% trans 'System user' %}",#} 'domain': "{% trans 'Domain' %}", 'comment': "{% trans 'Comment' %}", }; diff --git a/apps/authentication/templates/authentication/_access_key_modal.html b/apps/authentication/templates/authentication/_access_key_modal.html index f0b34cf30..71b1f67f5 100644 --- a/apps/authentication/templates/authentication/_access_key_modal.html +++ b/apps/authentication/templates/authentication/_access_key_modal.html @@ -135,6 +135,19 @@ $(document).ready(function () { } }; requestApi(data) +}).on('click', '.btn-api-keydel', function (){ + var url = "{% url "api-auth:access-key-detail" pk=DEFAULT_PK %}"; + url = url.replace("{{ DEFAULT_PK }}", $(this).data("id")) ; + var data = { + url: url, + method: "DELETE", + success: function () { + ak_table.ajax.reload(); + }, + success_message: "{% trans 'Delete success' %}" + + }; + requestApi(data) }) {% endblock %} diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index acc82a355..8ce97ff57 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 5ad5d3edc..562154404 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -1671,7 +1671,7 @@ msgstr "定期测试系统用户可连接性: {}" #: assets/tasks/utils.py:17 msgid "Asset has been disabled, skipped: {}" -msgstr "资产或许不支持ansible, 跳过: {}" +msgstr "资产已经被禁用, 跳过: {}" #: assets/tasks/utils.py:21 msgid "Asset may not be support ansible, skipped: {}" diff --git a/apps/ops/serializers/adhoc.py b/apps/ops/serializers/adhoc.py index afdd659fc..8d9e18e24 100644 --- a/apps/ops/serializers/adhoc.py +++ b/apps/ops/serializers/adhoc.py @@ -19,10 +19,13 @@ class AdHocExecutionSerializer(serializers.ModelSerializer): @staticmethod def get_stat(obj): + count_failed_hosts = len(obj.failed_hosts) + count_success_hosts = len(obj.success_hosts) + count_total = count_success_hosts + count_failed_hosts return { - "total": obj.hosts_amount, - "success": len(obj.summary.get("contacted", [])), - "failed": len(obj.summary.get("dark", [])), + "total": count_total, + "success": count_success_hosts, + "failed": count_failed_hosts } def get_field_names(self, declared_fields, info): diff --git a/apps/perms/apps.py b/apps/perms/apps.py index d40373e08..5bb7420bb 100644 --- a/apps/perms/apps.py +++ b/apps/perms/apps.py @@ -5,3 +5,7 @@ from django.apps import AppConfig class PermsConfig(AppConfig): name = 'perms' + + def ready(self): + super().ready() + from . import signals_handler diff --git a/apps/perms/templates/perms/asset_permission_user.html b/apps/perms/templates/perms/asset_permission_user.html index bb9ca375a..088d80c75 100644 --- a/apps/perms/templates/perms/asset_permission_user.html +++ b/apps/perms/templates/perms/asset_permission_user.html @@ -218,7 +218,7 @@ function addGroups(groupsId) { } function removeGroup(groupId) { - var theUrl = "{% url 'api-perms:asset-permissions-user-groups-relation-list' %}?assetpermission={{ object.id }}"; + var theUrl = "{% url 'api-perms:asset-permissions-user-groups-relation-list' %}?assetpermission={{ object.id }}&usergroup=groupId"; theUrl = theUrl.replace("groupId", groupId); var success = function(data) { location.reload(); diff --git a/apps/perms/templates/perms/database_app_permission_user.html b/apps/perms/templates/perms/database_app_permission_user.html index 603f60a6e..8b109fa1a 100644 --- a/apps/perms/templates/perms/database_app_permission_user.html +++ b/apps/perms/templates/perms/database_app_permission_user.html @@ -218,7 +218,7 @@ function addGroups(groupsId) { } function removeGroup(groupId) { - var theUrl = "{% url 'api-perms:database-app-permissions-user-groups-relation-list' %}?databaseapppermission={{ object.id }}"; + var theUrl = "{% url 'api-perms:database-app-permissions-user-groups-relation-list' %}?databaseapppermission={{ object.id }}&usergroup=groupId"; theUrl = theUrl.replace("groupId", groupId); var success = function(data) { location.reload(); diff --git a/apps/perms/templates/perms/remote_app_permission_user.html b/apps/perms/templates/perms/remote_app_permission_user.html index d222dfb7c..9fa623585 100644 --- a/apps/perms/templates/perms/remote_app_permission_user.html +++ b/apps/perms/templates/perms/remote_app_permission_user.html @@ -179,9 +179,13 @@ var body = { user_groups: groups }; + var success = function(data) { + location.reload(); + }; requestApi({ url: the_url, - body: JSON.stringify(body) + body: JSON.stringify(body), + success: success }); } $(document).ready(function () { diff --git a/apps/users/views/profile/otp.py b/apps/users/views/profile/otp.py index 2d823f5ab..83918114e 100644 --- a/apps/users/views/profile/otp.py +++ b/apps/users/views/profile/otp.py @@ -83,26 +83,12 @@ class UserOtpEnableBindView(TemplateView, FormView): return super().get_context_data(**kwargs) -class UserVerifyMFAView(FormView): +class UserDisableMFAView(FormView): template_name = 'users/user_verify_mfa.html' form_class = forms.UserCheckOtpCodeForm success_url = reverse_lazy('users:user-otp-settings-success') permission_classes = [IsValidUser] - def form_valid(self, form): - user = self.request.user - otp_code = form.cleaned_data.get('otp_code') - - valid = user.check_mfa(otp_code) - if valid: - return super().form_valid(form) - else: - error = _('MFA code invalid, or ntp sync server time') - form.add_error('otp_code', error) - return super().form_invalid(form) - - -class UserDisableMFAView(UserVerifyMFAView): def form_valid(self, form): user = self.request.user otp_code = form.cleaned_data.get('otp_code') @@ -118,8 +104,23 @@ class UserDisableMFAView(UserVerifyMFAView): return super().form_invalid(form) -class UserOtpUpdateView(UserVerifyMFAView): +class UserOtpUpdateView(FormView): + template_name = 'users/user_verify_mfa.html' + form_class = forms.UserCheckOtpCodeForm success_url = reverse_lazy('users:user-otp-enable-bind') + permission_classes = [IsValidUser] + + def form_valid(self, form): + user = self.request.user + otp_code = form.cleaned_data.get('otp_code') + + valid = user.check_mfa(otp_code) + if valid: + return super().form_valid(form) + else: + error = _('MFA code invalid, or ntp sync server time') + form.add_error('otp_code', error) + return super().form_invalid(form) class UserOtpSettingsSuccessView(TemplateView): diff --git a/apps/users/views/profile/password.py b/apps/users/views/profile/password.py index c9bb97f38..bb7caa9a1 100644 --- a/apps/users/views/profile/password.py +++ b/apps/users/views/profile/password.py @@ -67,7 +67,7 @@ class UserVerifyPasswordView(FormView): def form_valid(self, form): user = get_user_or_pre_auth_user(self.request) password = form.cleaned_data.get('password') - user = authenticate(username=user.username, password=password) + user = authenticate(request=self.request, username=user.username, password=password) if not user: form.add_error("password", _("Password invalid")) return self.form_invalid(form)