Update checkpoint status in checkpoint page
When watching the checkpoint page, update (poll?) the checkpoint status. If a checkpoint is protecting, user shouldn't refresh the page to see it is available. Change-Id: I4dd046a3314219586b83837593ebb16fb1217077 Closes-Bug: #1622594
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.utils.translation import pgettext_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils.translation import ungettext_lazy
|
from django.utils.translation import ungettext_lazy
|
||||||
|
|
||||||
@@ -74,7 +75,42 @@ def get_plan_name(obj):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateRow(tables.Row):
|
||||||
|
ajax = True
|
||||||
|
|
||||||
|
def __init__(self, table, datum=None):
|
||||||
|
super(UpdateRow, self).__init__(table, datum)
|
||||||
|
self.provider_id = getattr(table, 'provider_id')
|
||||||
|
|
||||||
|
def get_data(self, request, obj_id):
|
||||||
|
provider = karborclient.provider_get(request, self.provider_id)
|
||||||
|
checkpoint = karborclient.checkpoint_get(request,
|
||||||
|
self.provider_id,
|
||||||
|
obj_id)
|
||||||
|
setattr(checkpoint, "provider_name", provider.name)
|
||||||
|
setattr(checkpoint, "provider_id", provider.id)
|
||||||
|
return checkpoint
|
||||||
|
|
||||||
|
|
||||||
|
TASK_DISPLAY_CHOICES = (
|
||||||
|
("error", pgettext_lazy("Task status of an Checkpoint", u"Error")),
|
||||||
|
("protecting", pgettext_lazy("Task status of an Checkpoint",
|
||||||
|
u"Protecting")),
|
||||||
|
("available", pgettext_lazy("Task status of an Checkpoint", u"Available")),
|
||||||
|
("deleting", pgettext_lazy("Task status of an Checkpoint", u"Deleting")),
|
||||||
|
("deleted", pgettext_lazy("Task status of an Checkpoint", u"Deleted")),
|
||||||
|
("error-deleting", pgettext_lazy("Task status of an Checkpoint",
|
||||||
|
u"Error Deleting")),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CheckpointsTable(tables.DataTable):
|
class CheckpointsTable(tables.DataTable):
|
||||||
|
TASK_STATUS_CHOICES = (
|
||||||
|
("error", True),
|
||||||
|
("available", True),
|
||||||
|
("deleted", True),
|
||||||
|
("error-deleting", True),
|
||||||
|
)
|
||||||
checkpointId = tables.Column(
|
checkpointId = tables.Column(
|
||||||
"id",
|
"id",
|
||||||
link=get_provider_link,
|
link=get_provider_link,
|
||||||
@@ -87,11 +123,16 @@ class CheckpointsTable(tables.DataTable):
|
|||||||
verbose_name=_('Protection Plan'))
|
verbose_name=_('Protection Plan'))
|
||||||
status = tables.Column(
|
status = tables.Column(
|
||||||
'status',
|
'status',
|
||||||
verbose_name=_('Status'))
|
verbose_name=_('Status'),
|
||||||
|
status=True,
|
||||||
|
status_choices=TASK_STATUS_CHOICES,
|
||||||
|
display_choices=TASK_DISPLAY_CHOICES)
|
||||||
|
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
name = 'checkpoints'
|
name = 'checkpoints'
|
||||||
verbose_name = _('Checkpoints')
|
verbose_name = _('Checkpoints')
|
||||||
|
status_columns = ["status", ]
|
||||||
|
row_class = UpdateRow
|
||||||
row_actions = (RestoreCheckpointLink, DeleteCheckpointsAction)
|
row_actions = (RestoreCheckpointLink, DeleteCheckpointsAction)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class IndexView(horizon_tables.DataTableView):
|
|||||||
context = dict(context, **self.get_filter_list())
|
context = dict(context, **self.get_filter_list())
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@memoized.memoized_method
|
||||||
def get_search_opts(self):
|
def get_search_opts(self):
|
||||||
def _total_days(year, month, num_months):
|
def _total_days(year, month, num_months):
|
||||||
days = 0
|
days = 0
|
||||||
@@ -171,6 +172,12 @@ class IndexView(horizon_tables.DataTableView):
|
|||||||
_('Unable to retrieve checkpoints list.'))
|
_('Unable to retrieve checkpoints list.'))
|
||||||
return checkpoints
|
return checkpoints
|
||||||
|
|
||||||
|
def get_table(self):
|
||||||
|
super(IndexView, self).get_table()
|
||||||
|
provider_id, _ = self.get_search_opts()
|
||||||
|
setattr(self.table, 'provider_id', provider_id)
|
||||||
|
return self.table
|
||||||
|
|
||||||
|
|
||||||
class CheckpointsRestoreView(horizon_forms.ModalFormView):
|
class CheckpointsRestoreView(horizon_forms.ModalFormView):
|
||||||
template_name = 'checkpoints/restore.html'
|
template_name = 'checkpoints/restore.html'
|
||||||
|
|||||||
Reference in New Issue
Block a user