Merge "Update restore status in restore page"

This commit is contained in:
Jenkins 2017-02-15 09:54:02 +00:00 committed by Gerrit Code Review
commit e7f4f7ef9d
1 changed files with 36 additions and 1 deletions

View File

@ -12,12 +12,42 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
from horizon import tables
from karbor_dashboard.api import karbor as karborclient
TASK_DISPLAY_CHOICES = (
("fail", pgettext_lazy("Task status of an Restore", u"Fail")),
("in_progress", pgettext_lazy("Task status of an Restore",
u"In Progress")),
("success", pgettext_lazy("Task status of an Restore", u"Success")),
)
class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, obj_id):
restore = karborclient.restore_get(request, obj_id)
checkpoint = karborclient.checkpoint_get(request,
restore.provider_id,
restore.checkpoint_id)
provider = karborclient.provider_get(request,
restore.provider_id)
setattr(restore, "name", checkpoint.protection_plan["name"])
setattr(restore, "provider_name", provider.name)
return restore
class RestoresTable(tables.DataTable):
TASK_STATUS_CHOICES = (
("fail", False),
("success", True),
)
id = tables.Column(
'id',
verbose_name=_('ID'))
@ -26,7 +56,10 @@ class RestoresTable(tables.DataTable):
verbose_name=_('Protection Plan'))
status = tables.Column(
'status',
verbose_name=_('Status'))
verbose_name=_('Status'),
status=True,
status_choices=TASK_STATUS_CHOICES,
display_choices=TASK_DISPLAY_CHOICES)
restore_from_checkpoint = tables.Column(
'checkpoint_id',
verbose_name=_('Restore From Checkpoint'))
@ -40,3 +73,5 @@ class RestoresTable(tables.DataTable):
class Meta(object):
name = 'restores'
verbose_name = _('Restores')
status_columns = ["status", ]
row_class = UpdateRow