Commit 359099ed by Kálmán Viktor

network: bootbox for bootstrap 3

parent 02e4350c
......@@ -3,23 +3,30 @@
$('i[class="icon-remove"]').click(function() {
href = $(this).parent('a').attr('href');
csrf = getCookie('csrftoken');
var click_this = this;
bootbox.dialog("Are you sure?", [
{
"label": "Cancel",
"class": "btn-info",
"callback": function () {}
},
{
"label": "Remove",
"class": "btn-danger",
"callback": function() {
delete_rule_or_group(click_this);
host = $('.page-header').children('h2').text()
group = $(this).closest('h4').text();
text = gettext('Are you sure you want to remove host group <strong>"%(group)s"</strong> from <strong>"%(host)s"</strong>?');
s = interpolate(text, {'group': group, 'host': host}, true);
bootbox.dialog({
message: s,
buttons: {
cancel: {
'label': "Cancel",
'className': "btn-info",
'callback': function () {}
},
remove: {
'label': "Remove",
'className': "btn-danger",
'callback': function() {
delete_rule_or_group(click_this);
}
}
}
]);
});
return false;
});
......
......@@ -82,6 +82,7 @@
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="{% url network.js_catalog %}"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="{% static "js/bootbox.min.js" %}"></script>
<!--<script src="{% static "js/select2-3.4.0/select2.min.js" %}"></script>-->
<script src="{% static "js/network.js" %}"></script>
<script>
......
......@@ -7,7 +7,7 @@
<h1>Remove <small></small></h1>
</div>
<form action="" method="post">{% csrf_token %}
<p>Are you sure you want to remove hostgroup <strong>"{{ group }}"</strong>
<p>Are you sure you want to remove host group <strong>"{{ group }}"</strong>
from <strong>"{{ host }}"</strong>?</p>
<input type="hidden" value="{{ request.GET.from }}" name="next" />
<a href="{{ request.GET.from }}" class="btn btn-info">Back</a>
......
......@@ -618,11 +618,12 @@ def remove_host_group(request, **kwargs):
# for post we actually remove the group from the host
elif request.method == "POST":
host.groups.remove(group)
messages.success(request, _("Successfully removed %(host)s from "
"%(group)s group!" % {
'host': host,
'group': group
}))
if not request.is_ajax():
messages.success(request, _("Successfully removed %(host)s from "
"%(group)s group!" % {
'host': host,
'group': group
}))
return redirect(reverse_lazy('network.host',
kwargs={'pk': kwargs['pk']}))
......@@ -633,9 +634,10 @@ def add_host_group(request, **kwargs):
host = Host.objects.get(pk=kwargs['pk'])
group = Group.objects.get(pk=group_pk)
host.groups.add(group)
messages.success(request, _("Successfully added %(host)s to group "
"%(group)s!" % {
'host': host,
'group': group
}))
if not request.is_ajax():
messages.success(request, _("Successfully added %(host)s to group"
" %(group)s!" % {
'host': host,
'group': group
}))
return redirect(reverse_lazy('network.host', kwargs=kwargs))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment