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
This commit is contained in:
parent
6c78f8066e
commit
b2f4f3a3e2
|
@ -120,7 +120,7 @@ horizon.datatables = {
|
|||
},
|
||||
|
||||
update_actions: function() {
|
||||
var $actions_to_update = $('.btn-launch.ajax-update');
|
||||
var $actions_to_update = $('.btn-launch.ajax-update, .btn-create.ajax-update');
|
||||
$actions_to_update.each(function(index, action) {
|
||||
var $action = $(this);
|
||||
horizon.ajax.queue({
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in New Issue