perf: 修改结构

pull/8873/head
ibuler 2022-09-13 14:06:25 +08:00
parent 3e794ec41a
commit 9a734e7069
8 changed files with 46 additions and 14 deletions

View File

@ -2,11 +2,8 @@ from .mixin import *
from .platform import *
from .asset import *
from .label import *
from .accounts import *
from .account import *
from .node import *
from .domain import *
from .gathered_user import *
from .favorite_asset import *
from .account_template import *
from .account_backup import *
from .account_history import *

View File

@ -0,0 +1,4 @@
from .account import *
from .backup import *
from .history import *
from .template import *

View File

@ -9,9 +9,9 @@ from common.drf.filters import BaseFilterSet, UUIDInFilter
from common.mixins import RecordViewLogMixin
from common.permissions import UserConfirmation
from authentication.const import ConfirmType
from ..tasks.account_connectivity import test_accounts_connectivity_manual
from ..models import Account, Node
from .. import serializers
from assets.tasks.account_connectivity import test_accounts_connectivity_manual
from assets.models import Account, Node
from assets import serializers
__all__ = ['AccountFilterSet', 'AccountViewSet', 'AccountSecretsViewSet', 'AccountTaskCreateAPI']

View File

@ -4,9 +4,9 @@ from rest_framework import status, viewsets
from rest_framework.response import Response
from orgs.mixins.api import OrgBulkModelViewSet
from .. import serializers
from ..tasks import execute_account_backup_plan
from ..models import (
from assets import serializers
from assets.tasks import execute_account_backup_plan
from assets.models import (
AccountBackupPlan, AccountBackupPlanExecution
)

View File

@ -1,9 +1,9 @@
from assets.api.accounts import (
from .account import (
AccountFilterSet, AccountViewSet, AccountSecretsViewSet
)
from common.mixins import RecordViewLogMixin
from .. import serializers
from ..models import Account
from assets import serializers
from assets.models import Account
__all__ = ['AccountHistoryViewSet', 'AccountHistorySecretsViewSet']

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.14 on 2022-09-13 05:11
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assets', '0112_auto_20220909_1907'),
]
operations = [
migrations.AddField(
model_name='account',
name='su_from',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='su_to', to='assets.account', verbose_name='Su from'),
),
migrations.AddField(
model_name='historicalaccount',
name='su_from',
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='assets.account', verbose_name='Su from'),
),
]

View File

@ -10,7 +10,14 @@ __all__ = ['Account', 'AccountTemplate']
class Account(BaseAccount):
asset = models.ForeignKey('assets.Asset', related_name='accounts', on_delete=models.CASCADE, verbose_name=_('Asset'))
asset = models.ForeignKey(
'assets.Asset', related_name='accounts',
on_delete=models.CASCADE, verbose_name=_('Asset')
)
su_from = models.ForeignKey(
'assets.Account', related_name='su_to', null=True,
on_delete=models.SET_NULL, verbose_name=_("Su from")
)
version = models.IntegerField(default=0, verbose_name=_('Version'))
history = HistoricalRecords()