plans: add provider name to plans table

Change-Id: I68763f5e7ae9993d48ffbd04af27deab084c1b6b
This commit is contained in:
Yuval Brik 2017-01-24 11:43:45 +02:00
parent bd1c573a9f
commit 22ec1940fc
2 changed files with 21 additions and 0 deletions

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
@ -109,11 +110,20 @@ class ProtectionPlanFilterAction(tables.FilterAction):
if query in protectionplan.name.lower()]
def provider_link(plan):
return reverse('horizon:karbor:protectionproviders:detail',
args=(plan.provider_id, ))
class ProtectionPlansTable(tables.DataTable):
name = tables.Column('name',
link="horizon:karbor:protectionplans:detail",
verbose_name=_('Name'))
provider = tables.Column('provider_name',
link=provider_link,
verbose_name=_('Protection Provider'))
status = tables.Column('status',
verbose_name=_('Status'))

View File

@ -67,6 +67,17 @@ class IndexView(horizon_tables.DataTableView):
self._more = False
exceptions.handle(self.request,
_('Unable to retrieve protection plans list.'))
providers = {}
try:
providers = {provider.id: provider.name
for provider in karborclient.provider_list(request)}
except Exception:
pass
for plan in plans:
provider_id = plan.provider_id
plan.provider_name = providers.get(provider_id, provider_id)
return plans