Commit 006dcfa1 by Őry Máté

one: add full Meta class to all models

fixes #118
parent 1191cf0b
...@@ -188,6 +188,11 @@ class Share(models.Model): ...@@ -188,6 +188,11 @@ class Share(models.Model):
'user.')) 'user.'))
owner = models.ForeignKey(User, null=True, blank=True, related_name='share_set') owner = models.ForeignKey(User, null=True, blank=True, related_name='share_set')
class Meta:
ordering = ['group', 'template', 'owner', ]
verbose_name = _('share')
verbose_name_plural = _('shares')
def get_type(self): def get_type(self):
t = TYPES[self.type] t = TYPES[self.type]
t['deletex'] = (datetime.now() + td(seconds=1) + t['delete'] t['deletex'] = (datetime.now() + td(seconds=1) + t['delete']
...@@ -210,9 +215,14 @@ class Share(models.Model): ...@@ -210,9 +215,14 @@ class Share(models.Model):
return running.filter(owner=user).count() return running.filter(owner=user).count()
else: else:
return running.count() return running.count()
def get_instance_pc(self): def get_instance_pc(self):
return float(self.get_running()) / self.instance_limit * 100 return float(self.get_running()) / self.instance_limit * 100
def __unicode__(self):
return u"%(group)s: %(tpl)s %(owner)s" % {
'group': self.group, 'tpl': self.template, 'owner': self.owner}
class Disk(models.Model): class Disk(models.Model):
"""Virtual disks automatically synchronized with OpenNebula.""" """Virtual disks automatically synchronized with OpenNebula."""
name = models.CharField(max_length=100, unique=True, name = models.CharField(max_length=100, unique=True,
...@@ -220,6 +230,8 @@ class Disk(models.Model): ...@@ -220,6 +230,8 @@ class Disk(models.Model):
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
verbose_name = _('disk')
verbose_name_plural = _('disks')
def __unicode__(self): def __unicode__(self):
return u"%s (#%d)" % (self.name, self.id) return u"%s (#%d)" % (self.name, self.id)
...@@ -259,6 +271,9 @@ class Network(models.Model): ...@@ -259,6 +271,9 @@ class Network(models.Model):
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
verbose_name = _('network')
verbose_name_plural = _('networks')
def __unicode__(self): def __unicode__(self):
return self.name return self.name
...@@ -298,6 +313,8 @@ class InstanceType(models.Model): ...@@ -298,6 +313,8 @@ class InstanceType(models.Model):
class Meta: class Meta:
ordering = ['credit'] ordering = ['credit']
verbose_name = _('instance type')
verbose_name_plural = _('instance types')
def __unicode__(self): def __unicode__(self):
return u"%s" % self.name return u"%s" % self.name
...@@ -332,6 +349,8 @@ class Template(models.Model): ...@@ -332,6 +349,8 @@ class Template(models.Model):
class Meta: class Meta:
verbose_name = _('template') verbose_name = _('template')
verbose_name_plural = _('templates') verbose_name_plural = _('templates')
ordering = ['name', ]
def __unicode__(self): def __unicode__(self):
return self.name return self.name
...@@ -396,6 +415,7 @@ class Instance(models.Model): ...@@ -396,6 +415,7 @@ class Instance(models.Model):
class Meta: class Meta:
verbose_name = _('instance') verbose_name = _('instance')
verbose_name_plural = _('instances') verbose_name_plural = _('instances')
ordering = ['pk', ]
def __unicode__(self): def __unicode__(self):
return self.name return self.name
......
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