From 9481f0551e32670ce0ea13c04189735683f2c4d7 Mon Sep 17 00:00:00 2001 From: David TARDIVEL Date: Mon, 19 Sep 2016 14:48:39 +0200 Subject: [PATCH] Update table's actions I updated audit template, action plan and audit tables by adding new possible actions. Checking of policies for audit templates has been fixed as well. Change-Id: Idacbfc7099633197089ebbf180d22d099df3d872 Closes-bug: #1623528 --- .../content/action_plans/tables.py | 7 +++--- .../content/audit_templates/tables.py | 22 ++++++++-------- watcher_dashboard/content/audits/tables.py | 25 ++++++++----------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/watcher_dashboard/content/action_plans/tables.py b/watcher_dashboard/content/action_plans/tables.py index 0b712dc..9b87419 100644 --- a/watcher_dashboard/content/action_plans/tables.py +++ b/watcher_dashboard/content/action_plans/tables.py @@ -49,10 +49,9 @@ class ActionPlansFilterAction(horizon.tables.FilterAction): policy_rules = (("infra-optim", "action_plan:detail"),) -class ArchiveActionPlan(horizon.tables.BatchAction): - name = "archive_action_plans" +class ArchiveActionPlan(horizon.tables.DeleteAction): + verbose_name = _("Archive Action Plans") policy_rules = (("infra-optim", "action_plan:delete"),) - help_text = _("Archive an action plan.") @staticmethod def action_present(count): @@ -170,6 +169,8 @@ class ActionPlansTable(horizon.tables.DataTable): table_actions = ( # CancelActionPlan, ActionPlansFilterAction, + StartActionPlan, + ArchiveActionPlan, ) row_actions = ( StartActionPlan, diff --git a/watcher_dashboard/content/audit_templates/tables.py b/watcher_dashboard/content/audit_templates/tables.py index 29b0161..2012394 100644 --- a/watcher_dashboard/content/audit_templates/tables.py +++ b/watcher_dashboard/content/audit_templates/tables.py @@ -30,7 +30,7 @@ class CreateAuditTemplates(horizon.tables.LinkAction): verbose_name = _("Create Template") url = "horizon:admin:audit_templates:create" classes = ("ajax-modal", "btn-launch") - policy_rules = (("infra-optim", "audit_templates:create"),) + policy_rules = (("infra-optim", "audit_template:create"),) class AuditTemplatesFilterAction(horizon.tables.FilterAction): @@ -39,7 +39,7 @@ class AuditTemplatesFilterAction(horizon.tables.FilterAction): ('goal', _("Goal ="), True), ('strategy', _("Strategy ="), True), ) - policy_rules = (("infra-optim", "audit_templates:detail"),) + policy_rules = (("infra-optim", "audit_template:detail"),) class LaunchAudit(horizon.tables.BatchAction): @@ -73,23 +73,23 @@ class LaunchAudit(horizon.tables.BatchAction): watcher.Audit.create(request, **params) -class DeleteAuditTemplates(horizon.tables.DeleteAction): - verbose_name = _("Delete Templates") +class ArchiveAuditTemplates(horizon.tables.DeleteAction): + verbose_name = _("Archive Templates") policy_rules = (("infra-optim", "audit_template:delete"),) @staticmethod def action_present(count): return ungettext_lazy( - "Delete Template", - "Delete Templates", + "Archive Template", + "Archive Templates", count ) @staticmethod def action_past(count): return ungettext_lazy( - "Deleted Template", - "Deleted Templates", + "Archived Template", + "Archived Templates", count ) @@ -118,12 +118,14 @@ class AuditTemplatesTable(horizon.tables.DataTable): class Meta(object): name = "audit_templates" - verbose_name = _("Available") + verbose_name = _("Audit Templates") table_actions = ( CreateAuditTemplates, - DeleteAuditTemplates, AuditTemplatesFilterAction, + LaunchAudit, + ArchiveAuditTemplates, ) row_actions = ( LaunchAudit, + ArchiveAuditTemplates, ) diff --git a/watcher_dashboard/content/audits/tables.py b/watcher_dashboard/content/audits/tables.py index 9c3b150..b5bfce4 100644 --- a/watcher_dashboard/content/audits/tables.py +++ b/watcher_dashboard/content/audits/tables.py @@ -52,8 +52,8 @@ class AuditsFilterAction(horizon.tables.FilterAction): class CreateAudit(horizon.tables.LinkAction): - name = "launch_audit" - verbose_name = _("Launch Audit") + name = "create_audit" + verbose_name = _("Create Audit") url = "horizon:admin:audits:create" classes = ("ajax-modal", "btn-launch") policy_rules = (("infra-optim", "audit:create"),) @@ -84,22 +84,23 @@ class GoToActionPlan(horizon.tables.Action): args=[action_plans[0].uuid])) -class DeleteAudits(horizon.tables.DeleteAction): - verbose_name = _("Delete Audits") +class ArchiveAudits(horizon.tables.DeleteAction): + verbose_name = _("Archive Audits") + policy_rules = (("infra-optim", "audit:delete"),) @staticmethod def action_present(count): return ungettext_lazy( - "Delete Audit", - "Delete Audits", + "Archive Audit", + "Archive Audits", count ) @staticmethod def action_past(count): return ungettext_lazy( - "Deleted Audit", - "Deleted Audits", + "Archived Audit", + "Archived Audits", count ) @@ -132,16 +133,12 @@ class AuditsTable(horizon.tables.DataTable): verbose_name = _("Audits") launch_actions = (CreateAudit,) table_actions = launch_actions + ( - # CancelAudit, AuditsFilterAction, - # ArchiveAudits, + ArchiveAudits, ) row_actions = ( GoToActionPlan, - # CreateAudits, - # ArchiveAudits, - # CreateAudits, - DeleteAudits, + ArchiveAudits, )