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:
parent
f44da40ea5
commit
d5e3a8399a
@ -48,6 +48,7 @@ class TenantsTable(tables.DataTable):
|
|||||||
id = tables.Column(
|
id = tables.Column(
|
||||||
"id",
|
"id",
|
||||||
verbose_name=_("Project ID"),
|
verbose_name=_("Project ID"),
|
||||||
|
link="horizon:kingbird:quota_management:detail"
|
||||||
)
|
)
|
||||||
enabled = tables.Column(
|
enabled = tables.Column(
|
||||||
"enabled",
|
"enabled",
|
||||||
@ -61,3 +62,26 @@ class TenantsTable(tables.DataTable):
|
|||||||
name = "tenant_set"
|
name = "tenant_set"
|
||||||
verbose_name = _("Quota Management")
|
verbose_name = _("Quota Management")
|
||||||
row_actions = (UpdateQuota, QuotaSync, DeleteQuota)
|
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")
|
||||||
|
@ -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 %}
|
||||||
|
|
@ -25,4 +25,6 @@ urlpatterns = [
|
|||||||
url(PROJECT_ID % 'sync', views.SyncQuotaView.as_view(), name='sync'),
|
url(PROJECT_ID % 'sync', views.SyncQuotaView.as_view(), name='sync'),
|
||||||
url(PROJECT_ID % 'delete', views.DeleteQuotaView.as_view(),
|
url(PROJECT_ID % 'delete', views.DeleteQuotaView.as_view(),
|
||||||
name='delete'),
|
name='delete'),
|
||||||
|
url(PROJECT_ID % 'detail', views.DetailQuotaView.as_view(),
|
||||||
|
name='detail'),
|
||||||
]
|
]
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ from horizon import forms
|
|||||||
from horizon import messages
|
from horizon import messages
|
||||||
from horizon import tables
|
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 forms as kb_forms
|
||||||
from kingbird_dashboard.quota_management import tables as kb_tables
|
from kingbird_dashboard.quota_management import tables as kb_tables
|
||||||
|
|
||||||
@ -142,3 +144,19 @@ class DeleteQuotaView(forms.ModalFormView):
|
|||||||
|
|
||||||
def get_initial(self, **kwargs):
|
def get_initial(self, **kwargs):
|
||||||
return {'project_id': self.kwargs['project_id']}
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user