Fixed Catch errors in horizon tables

When an action is performed from a table, errors are not being catched

Closes-bug: 1593355
Change-Id: I5bdb19dcc1079f2fceeb88e49c644048c60254ce
This commit is contained in:
Memo Garcia 2016-06-16 18:43:25 +01:00
parent 6ec918bc63
commit d246ec11e7
3 changed files with 11 additions and 0 deletions

View File

@ -19,6 +19,7 @@ from horizon import tables
from django.core.urlresolvers import reverse
import disaster_recovery.api.api as freezer_api
from disaster_recovery.utils import shield
LOG = logging.getLogger(__name__)
@ -51,6 +52,7 @@ class DeleteClient(tables.DeleteAction):
count
)
@shield("Unable to delete client", redirect="clients:index")
def delete(self, request, client_id):
return freezer_api.Client(request).delete(client_id)

View File

@ -23,6 +23,7 @@ from horizon import messages
from django.core.urlresolvers import reverse
import disaster_recovery.api.api as freezer_api
from disaster_recovery.utils import shield
LOG = logging.getLogger(__name__)
@ -69,6 +70,7 @@ class DeleteJob(tables.DeleteAction):
count
)
@shield("Unable to delete job", redirect="jobs:index")
def delete(self, request, job_id):
return freezer_api.Job(request).delete(job_id)
@ -82,6 +84,7 @@ class CloneJob(tables.Action):
verbose_name = _("Clone Job")
help_text = _("Clone and edit a job file")
@shield("Unable to clone job", redirect="jobs:index")
def single(self, table, request, job_id):
freezer_api.Job(request).clone(job_id)
return shortcuts.redirect('horizon:disaster_recovery:jobs:index')
@ -113,6 +116,7 @@ class StartJob(tables.Action):
name = "start_job"
verbose_name = _("Start Job")
@shield("Unable to start job", redirect="jobs:index")
def single(self, table, request, job_id):
freezer_api.Job(request).start(job_id)
messages.success(request, _("Job has started"))
@ -126,6 +130,7 @@ class StopJob(tables.Action):
name = "stop_job"
verbose_name = _("Stop Job")
@shield("Unable to stop job", redirect="jobs:index")
def single(self, table, request, job_id):
freezer_api.Job(request).stop(job_id)
messages.success(request, _("Job has stopped"))
@ -211,6 +216,7 @@ class DeleteAction(tables.DeleteAction):
count
)
@shield("Unable to delete action", redirect="jobs:index")
def delete(self, request, obj_id):
freezer_api.Job(request).delete_action(obj_id)
return reverse("horizon:disaster_recovery:jobs:index")

View File

@ -22,6 +22,7 @@ from horizon import tables
from django.core.urlresolvers import reverse
import disaster_recovery.api.api as freezer_api
from disaster_recovery.utils import shield
LOG = logging.getLogger(__name__)
@ -67,6 +68,7 @@ class DeleteSession(tables.DeleteAction):
count
)
@shield("Unable to delete session", redirect="sessions:index")
def delete(self, request, session_id):
return freezer_api.Session(request).delete(session_id)
@ -108,6 +110,7 @@ class DeleteJobFromSession(tables.DeleteAction):
count
)
@shield("Unable to delete session", redirect="sessions:index")
def delete(self, request, session):
job_id, session_id = session.split('===')
return freezer_api.Session(request).remove_job(session_id, job_id)