From c6e0e9a79a08139c9c9338afafb9d3ac61cbfdc2 Mon Sep 17 00:00:00 2001 From: xinwen <coderWen@126.com> Date: Sat, 9 May 2020 14:50:22 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E9=87=8D=E5=BB=BA=20ops=200018=20?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/serializers.py | 5 +- apps/locale/zh/LC_MESSAGES/django.po | 82 +++++++++---------- ...508_2105.py => 0018_auto_20200509_1434.py} | 19 +---- apps/ops/models/command.py | 6 +- 4 files changed, 49 insertions(+), 63 deletions(-) rename apps/ops/migrations/{0018_auto_20200508_2105.py => 0018_auto_20200509_1434.py} (54%) diff --git a/apps/audits/serializers.py b/apps/audits/serializers.py index 75ec9b634..a23efe534 100644 --- a/apps/audits/serializers.py +++ b/apps/audits/serializers.py @@ -62,6 +62,9 @@ class CommandExecutionSerializer(serializers.ModelSerializer): 'date_start', 'result', 'is_success' ) extra_kwargs = { - 'result': {'label': _('Result')}, + 'result': {'label': _('Result')}, # model 上的方法,只能在这修改 'is_success': {'label': _('Is success')}, + 'hosts': {'label': _('Hosts')}, # 外键,会生成 sql。不在 model 上修改 + 'run_as': {'label': _('Run as')}, + 'user': {'label': _('User')}, } diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index b875be379..1ff08d362 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: JumpServer 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-08 18:40+0800\n" +"POT-Creation-Date: 2020-05-09 14:47+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: ibuler <ibuler@qq.com>\n" "Language-Team: JumpServer team<ibuler@qq.com>\n" @@ -1177,13 +1177,12 @@ msgstr "默认资产组" #: assets/models/label.py:15 assets/templates/assets/system_user_users.html:63 #: audits/models.py:18 audits/models.py:38 audits/models.py:51 -#: audits/templates/audits/ftp_log_list.html:37 +#: audits/serializers.py:69 audits/templates/audits/ftp_log_list.html:37 #: audits/templates/audits/ftp_log_list.html:74 #: audits/templates/audits/operate_log_list.html:37 #: audits/templates/audits/password_change_log_list.html:37 #: audits/templates/audits/password_change_log_list.html:54 -#: authentication/models.py:43 ops/models/command.py:25 -#: ops/templates/ops/command_execution_list.html:41 +#: authentication/models.py:43 ops/templates/ops/command_execution_list.html:41 #: ops/templates/ops/command_execution_list.html:66 #: perms/forms/asset_permission.py:83 perms/forms/database_app_permission.py:38 #: perms/forms/remote_app_permission.py:40 perms/models/base.py:49 @@ -1643,8 +1642,8 @@ msgstr "获取认证信息错误" msgid "Close" msgstr "关闭" -#: assets/templates/assets/_asset_user_list.html:24 -#: audits/templates/audits/operate_log_list.html:75 +#: assets/templates/assets/_asset_user_list.html:24 audits/models.py:43 +#: audits/models.py:54 audits/templates/audits/operate_log_list.html:75 #: audits/templates/audits/password_change_log_list.html:57 #: ops/templates/ops/task_adhoc.html:61 #: terminal/templates/terminal/command_list.html:34 @@ -2344,6 +2343,19 @@ msgstr "文件名" msgid "Success" msgstr "成功" +#: audits/models.py:25 audits/templates/audits/ftp_log_list.html:81 +#: ops/models/command.py:28 ops/templates/ops/adhoc_history.html:50 +#: ops/templates/ops/adhoc_history_detail.html:59 +#: ops/templates/ops/command_execution_list.html:72 +#: ops/templates/ops/task_history.html:56 perms/models/base.py:52 +#: perms/templates/perms/asset_permission_detail.html:81 +#: perms/templates/perms/database_app_permission_detail.html:77 +#: perms/templates/perms/remote_app_permission_detail.html:73 +#: terminal/models.py:199 terminal/templates/terminal/session_detail.html:72 +#: terminal/templates/terminal/session_list.html:32 +msgid "Date start" +msgstr "开始日期" + #: audits/models.py:33 #: authentication/templates/authentication/_access_key_modal.html:22 msgid "Create" @@ -2420,18 +2432,29 @@ msgstr "状态" msgid "Date login" msgstr "登录日期" -#: audits/templates/audits/ftp_log_list.html:81 ops/models/command.py:28 -#: ops/templates/ops/adhoc_history.html:50 -#: ops/templates/ops/adhoc_history_detail.html:59 -#: ops/templates/ops/command_execution_list.html:72 -#: ops/templates/ops/task_history.html:56 perms/models/base.py:52 -#: perms/templates/perms/asset_permission_detail.html:81 -#: perms/templates/perms/database_app_permission_detail.html:77 -#: perms/templates/perms/remote_app_permission_detail.html:73 -#: terminal/models.py:199 terminal/templates/terminal/session_detail.html:72 -#: terminal/templates/terminal/session_list.html:32 -msgid "Date start" -msgstr "开始日期" +#: audits/serializers.py:65 ops/models/command.py:24 +msgid "Result" +msgstr "结果" + +#: audits/serializers.py:66 ops/models/adhoc.py:240 +#: ops/templates/ops/adhoc_history.html:54 +#: ops/templates/ops/task_history.html:60 +msgid "Is success" +msgstr "是否成功" + +#: audits/serializers.py:67 ops/templates/ops/adhoc_detail.html:51 +#: ops/templates/ops/command_execution_list.html:65 +#: ops/templates/ops/task_adhoc.html:57 ops/templates/ops/task_list.html:13 +#: terminal/forms/storage.py:151 +msgid "Hosts" +msgstr "主机" + +#: audits/serializers.py:68 ops/templates/ops/adhoc_detail.html:70 +#: ops/templates/ops/adhoc_detail.html:75 +#: ops/templates/ops/command_execution_list.html:68 +#: ops/templates/ops/task_adhoc.html:59 +msgid "Run as" +msgstr "运行用户" #: audits/templates/audits/login_log_list.html:34 #: perms/templates/perms/asset_permission_user.html:74 @@ -2974,11 +2997,6 @@ msgstr "时间" msgid "Is finished" msgstr "是否完成" -#: ops/models/adhoc.py:240 ops/templates/ops/adhoc_history.html:54 -#: ops/templates/ops/task_history.html:60 -msgid "Is success" -msgstr "是否成功" - #: ops/models/adhoc.py:241 msgid "Adhoc raw result" msgstr "结果" @@ -2995,24 +3013,6 @@ msgstr "{} 任务开始: {}" msgid "{} Task finish" msgstr "{} 任务结束" -#: ops/models/command.py:21 ops/templates/ops/adhoc_detail.html:51 -#: ops/templates/ops/command_execution_list.html:65 -#: ops/templates/ops/task_adhoc.html:57 ops/templates/ops/task_list.html:13 -#: terminal/forms/storage.py:151 -msgid "Hosts" -msgstr "主机" - -#: ops/models/command.py:22 ops/templates/ops/adhoc_detail.html:70 -#: ops/templates/ops/adhoc_detail.html:75 -#: ops/templates/ops/command_execution_list.html:68 -#: ops/templates/ops/task_adhoc.html:59 -msgid "Run as" -msgstr "运行用户" - -#: ops/models/command.py:24 -msgid "Result" -msgstr "结果" - #: ops/models/command.py:29 msgid "Date finished" msgstr "结束日期" diff --git a/apps/ops/migrations/0018_auto_20200508_2105.py b/apps/ops/migrations/0018_auto_20200509_1434.py similarity index 54% rename from apps/ops/migrations/0018_auto_20200508_2105.py rename to apps/ops/migrations/0018_auto_20200509_1434.py index 52c95646e..5bbf87610 100644 --- a/apps/ops/migrations/0018_auto_20200508_2105.py +++ b/apps/ops/migrations/0018_auto_20200509_1434.py @@ -1,8 +1,6 @@ -# Generated by Django 2.2.10 on 2020-05-08 13:05 +# Generated by Django 2.2.10 on 2020-05-09 06:34 -from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): @@ -27,24 +25,9 @@ class Migration(migrations.Migration): name='date_start', field=models.DateTimeField(null=True, verbose_name='Date start'), ), - migrations.AlterField( - model_name='commandexecution', - name='hosts', - field=models.ManyToManyField(to='assets.Asset', verbose_name='Hosts'), - ), migrations.AlterField( model_name='commandexecution', name='is_finished', field=models.BooleanField(default=False, verbose_name='Is finished'), ), - migrations.AlterField( - model_name='commandexecution', - name='run_as', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.SystemUser', verbose_name='Run as'), - ), - migrations.AlterField( - model_name='commandexecution', - name='user', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User'), - ), ] diff --git a/apps/ops/models/command.py b/apps/ops/models/command.py index 6c3339513..fb6642f85 100644 --- a/apps/ops/models/command.py +++ b/apps/ops/models/command.py @@ -18,11 +18,11 @@ from ..inventory import JMSInventory class CommandExecution(OrgModelMixin): id = models.UUIDField(default=uuid.uuid4, primary_key=True) - hosts = models.ManyToManyField('assets.Asset', verbose_name=_('Hosts')) - run_as = models.ForeignKey('assets.SystemUser', on_delete=models.CASCADE, verbose_name=_('Run as')) + hosts = models.ManyToManyField('assets.Asset') + run_as = models.ForeignKey('assets.SystemUser', on_delete=models.CASCADE) command = models.TextField(verbose_name=_("Command")) _result = models.TextField(blank=True, null=True, verbose_name=_('Result')) - user = models.ForeignKey('users.User', on_delete=models.CASCADE, null=True, verbose_name=_('User')) + user = models.ForeignKey('users.User', on_delete=models.CASCADE, null=True) is_finished = models.BooleanField(default=False, verbose_name=_('Is finished')) date_created = models.DateTimeField(auto_now_add=True, verbose_name=_('Date created')) date_start = models.DateTimeField(null=True, verbose_name=_('Date start'))