Actions for a job no longer shows irrelevant actions for specific cases

Resolves bug: 1546195
Change-Id: I6234a1d7bdbd2c5366fcf95290c60500b0625d1c
This commit is contained in:
Memo García 2016-02-16 14:37:53 +00:00
parent 4c5ee4ca57
commit 7dbb52e2b3
3 changed files with 23 additions and 0 deletions

View File

@ -87,6 +87,10 @@ def get_link(action):
kwargs={'action_id': action.id})
class UpdateRow(tables.Row):
ajax = True
class ActionsTable(tables.DataTable):
backup_name = tables.Column('backup_name',
@ -104,3 +108,4 @@ class ActionsTable(tables.DataTable):
row_actions = (EditAction, DeleteAction,)
table_actions = (BackupFilter, CreateAction, DeleteMultipleActions)
multi_select = True
row_class = UpdateRow

View File

@ -118,6 +118,9 @@ class StartJob(tables.Action):
messages.success(request, _("Job has started"))
return shortcuts.redirect('horizon:disaster_recovery:jobs:index')
def allowed(self, request, job=None):
return True
class StopJob(tables.Action):
name = "stop_job"
@ -128,6 +131,11 @@ class StopJob(tables.Action):
messages.success(request, _("Job has stopped"))
return shortcuts.redirect('horizon:disaster_recovery:jobs:index')
def allowed(self, request, job=None):
if job.event == 'stop':
return False
return True
def get_link(row):
return reverse('horizon:disaster_recovery:jobs:index',
@ -142,6 +150,10 @@ class CreateJob(tables.LinkAction):
icon = "plus"
class UpdateRow(tables.Row):
ajax = True
class JobsTable(tables.DataTable):
job_name = tables.Column("description",
link=get_link,
@ -174,6 +186,7 @@ class JobsTable(tables.DataTable):
DeleteJob)
footer = False
multi_select = True
row_class = UpdateRow
class DeleteAction(tables.DeleteAction):

View File

@ -137,6 +137,10 @@ class JobsTable(tables.DataTable):
multi_select = True
class UpdateRow(tables.Row):
ajax = True
class SessionsTable(tables.DataTable):
description = tables.Column('description',
link=get_link,
@ -155,3 +159,4 @@ class SessionsTable(tables.DataTable):
DeleteSession,)
footer = False
multi_select = True
row_class = UpdateRow