Add delete workbook support

Partially implements blueprint mistral-dashboard-crud-operations

Change-Id: Ifde0de4542f01452cf201f785edfae2f63a4cf4d
This commit is contained in:
Zhenguo Niu 2015-07-15 15:46:34 +08:00
parent 9235096427
commit a99d302725
2 changed files with 35 additions and 1 deletions

View File

@ -133,3 +133,12 @@ def workbook_validate(request, workbook_definition):
"""
return mistralclient(request).workbooks.validate(workbook_definition)
def workbook_delete(request, workbook_definition):
"""Delete workbook.
:param workbook_definition: Workbook definition
"""
return mistralclient(request).workbooks.delete(workbook_definition)

View File

@ -15,10 +15,13 @@
# limitations under the License.
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from horizon import tables
from horizon.utils import filters
from mistraldashboard import api
class CreateWorkbook(tables.LinkAction):
name = "create"
@ -28,6 +31,27 @@ class CreateWorkbook(tables.LinkAction):
icon = "plus"
class DeleteWorkbook(tables.DeleteAction):
@staticmethod
def action_present(count):
return ungettext_lazy(
u"Delete Workbook",
u"Delete Workbooks",
count
)
@staticmethod
def action_past(count):
return ungettext_lazy(
u"Deleted Workbook",
u"Deleted Workbooks",
count
)
def delete(self, request, workbook_name):
api.workbook_delete(request, workbook_name)
def tags_to_string(workbook):
return ', '.join(workbook.tags) if workbook.tags else None
@ -62,4 +86,5 @@ class WorkbooksTable(tables.DataTable):
class Meta:
name = "workbooks"
verbose_name = _("Workbooks")
table_actions = (CreateWorkbook,)
table_actions = (CreateWorkbook, DeleteWorkbook)
row_actions = (DeleteWorkbook,)