From a7815dc9e510831e236717882b4e687e831e9a41 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 20 Dec 2022 18:12:35 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20job=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0017_auto_20221220_1757.py | 23 ++++++++++++++++ apps/audits/models.py | 6 ++--- apps/audits/serializers.py | 26 +++++++------------ 3 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 apps/audits/migrations/0017_auto_20221220_1757.py diff --git a/apps/audits/migrations/0017_auto_20221220_1757.py b/apps/audits/migrations/0017_auto_20221220_1757.py new file mode 100644 index 000000000..b879648e8 --- /dev/null +++ b/apps/audits/migrations/0017_auto_20221220_1757.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.14 on 2022-12-20 09:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('audits', '0016_auto_20221111_1919'), + ] + + operations = [ + migrations.RenameField( + model_name='ftplog', + old_name='system_user', + new_name='account', + ), + migrations.AlterField( + model_name='ftplog', + name='account', + field=models.CharField(default='', max_length=128, verbose_name='Account'), + preserve_default=False, + ), + ] diff --git a/apps/audits/models.py b/apps/audits/models.py index 1e65ea233..5f11fca9f 100644 --- a/apps/audits/models.py +++ b/apps/audits/models.py @@ -2,11 +2,11 @@ import uuid from django.db import models from django.db.models import Q -from django.utils.translation import gettext, ugettext_lazy as _ from django.utils import timezone +from django.utils.translation import gettext, ugettext_lazy as _ -from common.utils import lazyproperty from common.db.encoder import ModelJSONFieldEncoder +from common.utils import lazyproperty from orgs.mixins.models import OrgModelMixin, Organization from orgs.utils import current_org from .const import ( @@ -32,7 +32,7 @@ class FTPLog(OrgModelMixin): max_length=128, verbose_name=_("Remote addr"), blank=True, null=True ) asset = models.CharField(max_length=1024, verbose_name=_("Asset")) - system_user = models.CharField(max_length=128, verbose_name=_("System user")) + account = models.CharField(max_length=128, verbose_name=_("Account")) operate = models.CharField( max_length=16, verbose_name=_("Operate"), choices=OperateChoices.choices ) diff --git a/apps/audits/serializers.py b/apps/audits/serializers.py index 5e74e0aad..fd803184c 100644 --- a/apps/audits/serializers.py +++ b/apps/audits/serializers.py @@ -9,10 +9,8 @@ from ops.serializers.job import JobExecutionSerializer from terminal.models import Session from . import models from .const import ( - ActionChoices, - OperateChoices, - MFAChoices, - LoginStatusChoices, + ActionChoices, OperateChoices, + MFAChoices, LoginStatusChoices, LoginTypeChoices, ) @@ -20,11 +18,11 @@ from .const import ( class JobAuditLogSerializer(JobExecutionSerializer): class Meta: model = JobAuditLog - read_only_fields = ["id", "material", "timedelta", "time_cost", 'is_finished', 'date_start', - 'date_finished', - 'date_created', - 'is_success', - 'creator_name'] + read_only_fields = [ + "id", "material", "time_cost", + 'date_start', 'date_finished', 'date_created', + 'is_finished', 'is_success', 'creator_by' + ] fields = read_only_fields + [] @@ -35,14 +33,8 @@ class FTPLogSerializer(serializers.ModelSerializer): model = models.FTPLog fields_mini = ["id"] fields_small = fields_mini + [ - "user", - "remote_addr", - "asset", - "system_user", - "org_id", - "operate", - "filename", - "is_success", + "user", "remote_addr", "asset", "account", + "org_id", "operate", "filename", "is_success", "date_start", ] fields = fields_small