Commit 41aea907 by Kálmán Viktor

dashboard: fix vm search

parent 566e74c4
...@@ -96,7 +96,8 @@ class IndexView(LoginRequiredMixin, TemplateView): ...@@ -96,7 +96,8 @@ class IndexView(LoginRequiredMixin, TemplateView):
}) })
running = [i for i in instances if i.state == 'RUNNING'] running = [i for i in instances if i.state == 'RUNNING']
stopped = [i for i in instances if i.state not in ['RUNNING', 'NOSTATE']] stopped = [i for i in instances if i.state not in ['RUNNING',
'NOSTATE']]
context.update({ context.update({
'running_vms': running, 'running_vms': running,
'running_vm_num': len(running), 'running_vm_num': len(running),
...@@ -666,9 +667,12 @@ class VmList(LoginRequiredMixin, SingleTableView): ...@@ -666,9 +667,12 @@ class VmList(LoginRequiredMixin, SingleTableView):
favourite__user=self.request.user).values_list('pk', flat=True) favourite__user=self.request.user).values_list('pk', flat=True)
instances = Instance.get_objects_with_level( instances = Instance.get_objects_with_level(
'user', self.request.user).filter( 'user', self.request.user).filter(
destroyed=None).values('pk', 'name', 'state') destroyed=None).all()
for i in instances: instances = [{
i['fav'] = True if i['pk'] in favs else False 'pk': i.pk,
'name': i.name,
'state': i.state,
'fav': i.pk in favs} for i in instances]
return HttpResponse( return HttpResponse(
json.dumps(list(instances)), # instances is ValuesQuerySet json.dumps(list(instances)), # instances is ValuesQuerySet
content_type="application/json", content_type="application/json",
......
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