Commit 6282576e by Kálmán Viktor

dashboard: add instance count to mass ops

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