Add Quota Detail feature to QuotaManagement Panel.

This commit is to add the Quota Detail feature to
QuotaManagement panel.This feature is used to get the
quota details of a tenant.

Depends-On: <I44de3b61e336e0ecfbfb74b90e791ed4d9a25650>
Change-Id: I74b4d41a84bf53ea50ac141c1d7c8ec856fd986b
This commit is contained in:
mounikasreeram 2018-02-01 18:03:05 +05:30
parent f44da40ea5
commit d5e3a8399a
4 changed files with 52 additions and 0 deletions

View File

@ -48,6 +48,7 @@ class TenantsTable(tables.DataTable):
id = tables.Column(
"id",
verbose_name=_("Project ID"),
link="horizon:kingbird:quota_management:detail"
)
enabled = tables.Column(
"enabled",
@ -61,3 +62,26 @@ class TenantsTable(tables.DataTable):
name = "tenant_set"
verbose_name = _("Quota Management")
row_actions = (UpdateQuota, QuotaSync, DeleteQuota)
class QuotaDetailTable(tables.DataTable):
quota = tables.Column(
"_data",
verbose_name=_("Quota")
)
usage = tables.Column(
"_Usage",
verbose_name=_("Usage")
)
limit = tables.Column(
"_Limit",
verbose_name=_("Limit"),
)
def get_object_id(self, datum):
return datum._data
class Meta(object):
name = "quota_info"
verbose_name = _("Quota Information")

View File

@ -0,0 +1,8 @@
{% extends 'kingbird/default/table.html' %}
{% load i18n %}
{% block title %}{% trans "Quota Details" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Quota Details") %}
{% endblock page_header %}

View File

@ -25,4 +25,6 @@ urlpatterns = [
url(PROJECT_ID % 'sync', views.SyncQuotaView.as_view(), name='sync'),
url(PROJECT_ID % 'delete', views.DeleteQuotaView.as_view(),
name='delete'),
url(PROJECT_ID % 'detail', views.DetailQuotaView.as_view(),
name='detail'),
]

View File

@ -13,6 +13,7 @@
# under the License.
from django.conf import settings
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
@ -21,6 +22,7 @@ from horizon import forms
from horizon import messages
from horizon import tables
from kingbird_dashboard.api import client as kb_client
from kingbird_dashboard.quota_management import forms as kb_forms
from kingbird_dashboard.quota_management import tables as kb_tables
@ -142,3 +144,19 @@ class DeleteQuotaView(forms.ModalFormView):
def get_initial(self, **kwargs):
return {'project_id': self.kwargs['project_id']}
class DetailQuotaView(tables.DataTableView):
table_id = "quota_info"
table_class = kb_tables.QuotaDetailTable
template_name = 'kingbird/quota_management/detail.html'
def get_data(self, **kwargs):
try:
project_id = self.kwargs['project_id']
response = kb_client.detail_quota(self.request, project_id)
return response
except Exception:
msg = _('Unable to get details')
redirect = reverse('horizon:kingbird:quota_management:index')
exceptions.handle(self.request, msg, redirect=redirect)