fix audit delete failure: add allow func to filter audit

audits in ("ONGOING", "PENDING") cannot be deleted,
audits in other status can be deleted. This patch adds this func
to filter audits.

Depends-On: https://review.openstack.org/#/c/586754/

Change-Id: Idf64e5f0ef9e02e62a769ff80a70f05dade8d332
This commit is contained in:
Yumeng Bao 2018-07-30 15:05:52 +08:00 committed by YumengBao
parent 79fcf55752
commit 4ba319142c
1 changed files with 3 additions and 1 deletions

View File

@ -83,6 +83,9 @@ class ArchiveAudits(horizon.tables.DeleteAction):
verbose_name = _("Archive Audits")
policy_rules = (("infra-optim", "audit:delete"),)
def allowed(self, request, audit):
return audit or audit.state not in ("ONGOING", "PENDING")
@staticmethod
def action_present(count):
return ungettext_lazy(
@ -139,7 +142,6 @@ class AuditsTable(horizon.tables.DataTable):
launch_actions = (CreateAudit,)
table_actions = launch_actions + (
AuditsFilterAction,
ArchiveAudits,
)
row_actions = (
GoToActionPlan,