Commit 6282576e by Kálmán Viktor

dashboard: add instance count to mass ops

parent 4387a950
......@@ -3,8 +3,10 @@
{% block question %}
<p>
{% blocktrans with op=op.name %}
Do you want to perform the following operation: <strong>{{op}}</strong>?
{% blocktrans with op=op.name count count=vm_count %}
Do you want to perform the <strong>{{op}}</strong> operation on the following instance?
{% plural %}
Do you want to perform the <strong>{{op}}</strong> operation on the following {{ count }} instances?
{% endblocktrans %}
</p>
<p class="text-info">{{op.description}}</p>
......
......@@ -1020,7 +1020,8 @@ class MassOperationView(OperationView):
ctx = super(MassOperationView, self).get_context_data(**kwargs)
instances = self.request.GET.getlist("vm")
instances = Instance.objects.filter(pk__in=instances)
ctx['instances'] = self._check_instances(instances, self.request.user)
ctx['instances'], ctx['vm_count'] = self._check_instances(
instances, self.request.user)
return ctx
......@@ -1032,6 +1033,7 @@ class MassOperationView(OperationView):
def _check_instances(self, instances, user):
vms = []
ok_vm_count = 0
for i in instances:
try:
self._op_checks(i, user)
......@@ -1043,8 +1045,10 @@ class MassOperationView(OperationView):
setattr(i, "disabled", _("Permission denied"))
except Exception:
raise
else:
ok_vm_count += 1
vms.append(i)
return vms
return vms, ok_vm_count
def post(self, request, extra=None, *args, **kwargs):
if extra is None:
......@@ -1109,6 +1113,7 @@ class MassMigrationView(MassOperationView):
return super(MassMigrationView, self).post(request, extra, *args,
**kwargs)
vm_mass_ops = OrderedDict([
('deploy', MassOperationView.factory(vm_ops['deploy'])),
('wake_up', MassOperationView.factory(vm_ops['wake_up'])),
......
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