Commit 1df0e6ed by Kálmán Viktor

dashboard: add model manager for active instances

parent dd05833f
......@@ -206,7 +206,7 @@ class TemplateDetail(DetailView):
class VmList(SingleTableView):
template_name = "dashboard/vm-list.html"
model = Instance
queryset = Instance.active.all()
table_class = VmListTable
table_pagination = False
......
......@@ -9,7 +9,7 @@ from django.contrib.auth.models import User
from django.core import signing
from django.db.models import (Model, ForeignKey, ManyToManyField, IntegerField,
DateTimeField, BooleanField, TextField,
CharField, permalink)
CharField, permalink, Manager)
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
......@@ -34,6 +34,12 @@ ARCHITECTURES = (('x86_64', 'x86-64 (64 bit)'),
VNC_PORT_RANGE = (2000, 65536) # inclusive start, exclusive end
class InstanceActiveManager(Manager):
def get_query_set(self):
return super(InstanceActiveManager,
self).get_query_set().filter(destroyed=None)
class BaseResourceConfigModel(Model):
"""Abstract base for models with base resource configuration parameters.
......@@ -413,6 +419,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
destroyed = DateTimeField(blank=True, null=True,
help_text=_("The virtual machine's time of "
"destruction."))
objects = Manager()
active = InstanceActiveManager()
class Meta:
ordering = ['pk', ]
......
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