From 07adf638eb57b3c6b81ef5180c956a1750013aa7 Mon Sep 17 00:00:00 2001 From: Gabriel Hurley Date: Tue, 6 Mar 2012 19:34:20 -0800 Subject: [PATCH] Makes sure ajax-updated rows still get correct actions allowed. Also moved some logic that pertained to BatchAction from BaseAction to BatchAction where it belonged. Fixes bug 944853. Change-Id: I24f590f0b4320a0cc58d954398673a8fa75a49b6 --- horizon/tables/actions.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py index 0cd8b37b3..850862b41 100644 --- a/horizon/tables/actions.py +++ b/horizon/tables/actions.py @@ -53,9 +53,6 @@ class BaseAction(html.HTMLElement): return True def _allowed(self, request, datum): - """ Default allowed checks for certain actions """ - if isinstance(self, BatchAction) and not self.table.data: - return False return self.allowed(request, datum) def update(self, request, datum): @@ -427,6 +424,13 @@ class BatchAction(Action): self._conjugate('plural')) super(BatchAction, self).__init__() + def _allowed(self, request, datum=None): + # Override the default internal action method to prevent batch + # actions from appearing on tables with no data. + if not self.table.data and not datum: + return False + return super(BatchAction, self)._allowed(request, datum) + def _conjugate(self, items=None, past=False): """ Builds combinations like 'Delete Object' and 'Deleted