perf: Remove push account extra api

pull/14635/head
feng 2024-12-10 19:30:23 +08:00 committed by feng626
parent a904e59252
commit 792b552e25
4 changed files with 18 additions and 25 deletions

View File

@ -2,19 +2,17 @@
#
from accounts import serializers
from accounts.const import AutomationTypes
from accounts.models import PushAccountAutomation, ChangeSecretRecord
from accounts.models import PushAccountAutomation
from orgs.mixins.api import OrgBulkModelViewSet
from .base import (
AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi,
AutomationNodeAddRemoveApi, AutomationExecutionViewSet
)
from .change_secret import ChangeSecretRecordViewSet
__all__ = [
'PushAccountAutomationViewSet', 'PushAccountAssetsListApi', 'PushAccountRemoveAssetApi',
'PushAccountAddAssetApi', 'PushAccountNodeAddRemoveApi', 'PushAccountExecutionViewSet',
'PushAccountRecordViewSet'
]
@ -41,23 +39,6 @@ class PushAccountExecutionViewSet(AutomationExecutionViewSet):
return queryset
class PushAccountRecordViewSet(ChangeSecretRecordViewSet):
serializer_class = serializers.ChangeSecretRecordSerializer
tp = AutomationTypes.push_account
rbac_perms = {
'list': 'accounts.view_pushsecretrecord',
'execute': 'accounts.add_pushsecretexecution',
'secret': 'accounts.view_pushsecretrecord',
}
def get_queryset(self):
qs = ChangeSecretRecord.get_valid_records()
return qs.filter(
execution__automation__type=self.tp
)
class PushAccountAssetsListApi(AutomationAssetsListApi):
model = PushAccountAutomation

View File

@ -0,0 +1,17 @@
# Generated by Django 4.1.13 on 2024-12-10 11:29
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('accounts', '0022_alter_changesecretrecord_options_and_more'),
]
operations = [
migrations.AlterModelOptions(
name='changesecretrecord',
options={'verbose_name': 'Change secret record'},
),
]

View File

@ -46,10 +46,6 @@ class ChangeSecretRecord(JMSBaseModel):
class Meta:
verbose_name = _("Change secret record")
permissions = [
('view_pushsecretrecord', _('Can view change secret execution')),
('add_pushsecretexecution', _('Can add change secret execution')),
]
def __str__(self):
return f'{self.account.username}@{self.asset}'

View File

@ -23,7 +23,6 @@ router.register(r'gather-account-automations', api.GatherAccountsAutomationViewS
router.register(r'gather-account-executions', api.GatherAccountsExecutionViewSet, 'gather-account-execution')
router.register(r'push-account-automations', api.PushAccountAutomationViewSet, 'push-account-automation')
router.register(r'push-account-executions', api.PushAccountExecutionViewSet, 'push-account-execution')
router.register(r'push-account-records', api.PushAccountRecordViewSet, 'push-account-record')
router.register(r'check-account-automations', api.CheckAccountAutomationViewSet, 'check-account-automation')
router.register(r'check-account-executions', api.CheckAccountExecutionViewSet, 'check-account-execution')
router.register(r'account-check-engines', api.CheckAccountEngineViewSet, 'account-check-engine')