horizon/openstack_dashboard/dashboards/admin/defaults/tabs.py
liyingjun 5f8e370f2d Allow admins to update default quotas
Add update default quotas form to edit the default quotas.

Move the editable default quotas tab to a new panel called
"Defaults".

Implements blueprint edit-default-quota

Change-Id: I6e3806226cd2f699f16b93c25e294bc67883738f
2013-08-29 23:18:08 +08:00

55 lines
1.9 KiB
Python

# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Kylin, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import exceptions
from horizon import tabs
from openstack_dashboard.api import base
from openstack_dashboard.usage import quotas
from openstack_dashboard.dashboards.admin.defaults import tables
class DefaultQuotasTab(tabs.TableTab):
table_classes = (tables.QuotasTable,)
name = _("Default Quotas")
slug = "quotas"
template_name = ("horizon/common/_detail_table.html")
def get_quotas_data(self):
request = self.tab_group.request
try:
quota_set = quotas.get_default_quota_data(request)
data = quota_set.items
# There is no API to get the default system quotas in
# Neutron (cf. LP#1204956). Remove the network-related
# quotas from the list for now to avoid confusion
if base.is_service_enabled(self.request, 'network'):
data = [quota for quota in data
if quota.name not in ['floating_ips', 'fixed_ips']]
except Exception:
data = []
exceptions.handle(self.request, _('Unable to get quota info.'))
return data
class DefaultsTabs(tabs.TabGroup):
slug = "defaults"
tabs = (DefaultQuotasTab,)
sticky = True