From d5e3a8399a5522ded452b88ab36998f2a0d0eb3e Mon Sep 17 00:00:00 2001 From: mounikasreeram Date: Thu, 1 Feb 2018 18:03:05 +0530 Subject: [PATCH] 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: Change-Id: I74b4d41a84bf53ea50ac141c1d7c8ec856fd986b --- kingbird_dashboard/quota_management/tables.py | 24 +++++++++++++++++++ .../templates/quota_management/detail.html | 8 +++++++ kingbird_dashboard/quota_management/urls.py | 2 ++ kingbird_dashboard/quota_management/views.py | 18 ++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 kingbird_dashboard/quota_management/templates/quota_management/detail.html diff --git a/kingbird_dashboard/quota_management/tables.py b/kingbird_dashboard/quota_management/tables.py index df12a5c..d70916e 100644 --- a/kingbird_dashboard/quota_management/tables.py +++ b/kingbird_dashboard/quota_management/tables.py @@ -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") diff --git a/kingbird_dashboard/quota_management/templates/quota_management/detail.html b/kingbird_dashboard/quota_management/templates/quota_management/detail.html new file mode 100644 index 0000000..1778b63 --- /dev/null +++ b/kingbird_dashboard/quota_management/templates/quota_management/detail.html @@ -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 %} + diff --git a/kingbird_dashboard/quota_management/urls.py b/kingbird_dashboard/quota_management/urls.py index 4a33729..da5af12 100644 --- a/kingbird_dashboard/quota_management/urls.py +++ b/kingbird_dashboard/quota_management/urls.py @@ -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'), ] diff --git a/kingbird_dashboard/quota_management/views.py b/kingbird_dashboard/quota_management/views.py index 327e67a..a8c070c 100644 --- a/kingbird_dashboard/quota_management/views.py +++ b/kingbird_dashboard/quota_management/views.py @@ -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)