diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-07-16 09:56:43 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-07-16 09:56:43 +0000 |
commit | 03ca4f5a69d5eeab031a16ad5bfa0aa1162efa42 (patch) | |
tree | 3775caa56570f3dfd68ef6d08db3605eda0104f5 /openstack_dashboard | |
parent | cea57aab5eabb00b4f060028b9e442c269ec1e0d (diff) | |
parent | b2f4f3a3e2d750b0cce80f30a72f8f1db5916b02 (diff) | |
download | horizon-03ca4f5a69d5eeab031a16ad5bfa0aa1162efa42.tar.gz |
Merge "Update 'Create Volume' button with ajax"
Diffstat (limited to 'openstack_dashboard')
-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 eaacbe8b0..b582e7d6d 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 6f264c76e..81cf7cd4d 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py @@ -913,8 +913,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") |