Add delete function in Scheduled Operations
Change-Id: I0ca29bc1eb1bb905adb6af8f8890e9f71ce36f03 Closes-Bug: #1646668
This commit is contained in:
parent
1d320b8a72
commit
897059fe8e
|
@ -13,9 +13,12 @@
|
|||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import tables
|
||||
|
||||
from karbor_dashboard.api import karbor as karborclient
|
||||
|
||||
|
||||
class ScheduledOperationFilterAction(tables.FilterAction):
|
||||
def filter(self, table, scheduledoperations, filter_string):
|
||||
|
@ -26,6 +29,26 @@ class ScheduledOperationFilterAction(tables.FilterAction):
|
|||
if query in scheduledoperation.name.lower()]
|
||||
|
||||
|
||||
class DeleteScheduledOperationsAction(tables.DeleteAction):
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(u"Delete ScheduledOperation",
|
||||
u"Delete ScheduledOperations",
|
||||
count)
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(u"Deleted ScheduledOperation",
|
||||
u"Deleted ScheduledOperations",
|
||||
count)
|
||||
|
||||
def allowed(self, request, scheduledoperation):
|
||||
return True
|
||||
|
||||
def delete(self, request, obj_id):
|
||||
karborclient.scheduled_operation_delete(request, obj_id)
|
||||
|
||||
|
||||
class ScheduledOperationsTable(tables.DataTable):
|
||||
id = tables.Column(
|
||||
'id',
|
||||
|
@ -49,4 +72,6 @@ class ScheduledOperationsTable(tables.DataTable):
|
|||
class Meta(object):
|
||||
name = 'scheduledoperations'
|
||||
verbose_name = _('Scheduled Operations')
|
||||
table_actions = (ScheduledOperationFilterAction, )
|
||||
row_actions = (DeleteScheduledOperationsAction,)
|
||||
table_actions = (ScheduledOperationFilterAction,
|
||||
DeleteScheduledOperationsAction)
|
||||
|
|
Loading…
Reference in New Issue