perf: 修改 job log

pull/9223/head
ibuler 2022-12-20 18:12:35 +08:00
parent a21cb32245
commit a7815dc9e5
3 changed files with 35 additions and 20 deletions

View File

@ -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,
),
]

View File

@ -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
)

View File

@ -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