diff options
author | Tatiana Ovchinnikova <t.v.ovtchinnikova@gmail.com> | 2014-06-06 15:45:30 +0400 |
---|---|---|
committer | Tatiana Ovchinnikova <t.v.ovtchinnikova@gmail.com> | 2014-06-06 16:30:50 +0400 |
commit | b2f4f3a3e2d750b0cce80f30a72f8f1db5916b02 (patch) | |
tree | 1b3347e039463368fae2e2039e8b000041aea438 /openstack_dashboard/dashboards | |
parent | 6c78f8066edf53eacdc4cf0be87c627b772f8e09 (diff) | |
download | horizon-b2f4f3a3e2d750b0cce80f30a72f8f1db5916b02.tar.gz |
Update 'Create Volume' button with ajax
This patch set makes button 'Create Volume (Quota Exceeded)'
be replaced with enabled button 'Create Volume' after
deleting a volume.
Closes-Bug: #1326589
Change-Id: I10ebc668f99ed3f502be07cb82759052a29654a1
Diffstat (limited to 'openstack_dashboard/dashboards')
-rw-r--r-- | openstack_dashboard/dashboards/project/volumes/volumes/tables.py | 10 | ||||
-rw-r--r-- | openstack_dashboard/dashboards/project/volumes/volumes/tests.py | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/volumes/tables.py index b9be41c32..5e19ff670 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tables.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tables.py @@ -14,6 +14,7 @@ from django.core.urlresolvers import NoReverseMatch # noqa from django.core.urlresolvers import reverse +from django.http import HttpResponse # noqa from django.template import defaultfilters as filters from django.utils import html from django.utils.http import urlencode @@ -89,6 +90,11 @@ class CreateVolume(tables.LinkAction): url = "horizon:project:volumes:volumes:create" classes = ("ajax-modal", "btn-create") policy_rules = (("volume", "volume:create"),) + ajax = True + + def __init__(self, attrs=None, **kwargs): + kwargs['preempt'] = True + super(CreateVolume, self).__init__(attrs, **kwargs) def allowed(self, request, volume=None): usages = quotas.tenant_quota_usages(request) @@ -104,6 +110,10 @@ class CreateVolume(tables.LinkAction): self.classes = classes return True + def single(self, table, request, object_id=None): + self.allowed(request, None) + return HttpResponse(self.render()) + class ExtendVolume(tables.LinkAction): name = "extend" diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py index cbaaba00f..af45fb240 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py @@ -890,8 +890,9 @@ class VolumeViewTests(test.TestCase): link_name = "%s (%s)" % (unicode(create_link.verbose_name), "Quota exceeded") expected_string = "<a href='%s' title='%s' class='%s disabled' "\ - "id='volumes__action_create'>%s</a>" \ - % (url, link_name, " ".join(classes), link_name) + "id='volumes__action_create' data-update-url=" \ + "'/project/volumes/?action=create&table=volumes'>%s</a>" \ + % (url, link_name, " ".join(classes), link_name) self.assertContains(res, expected_string, html=True, msg_prefix="The create button is not disabled") |