1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 07:35:22 +00:00

Replaced __unicode__ with __str__ for models

This commit is contained in:
Real-Gecko 2020-06-15 12:57:17 +06:00
parent cfd739778c
commit 9a75ceb0e5
5 changed files with 14 additions and 12 deletions

View file

@ -1,3 +1,4 @@
from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.validators import MinValueValidator from django.core.validators import MinValueValidator
from django.db import models from django.db import models
@ -13,7 +14,7 @@ class UserInstance(models.Model):
is_delete = models.BooleanField(default=False) is_delete = models.BooleanField(default=False)
is_vnc = models.BooleanField(default=False) is_vnc = models.BooleanField(default=False)
def __unicode__(self): def __str__(self):
return self.instance.name return self.instance.name
@ -22,7 +23,7 @@ class UserSSHKey(models.Model):
keyname = models.CharField(_('key name'), max_length=25) keyname = models.CharField(_('key name'), max_length=25)
keypublic = models.CharField(_('public key'), max_length=500) keypublic = models.CharField(_('public key'), max_length=500)
def __unicode__(self): def __str__(self):
return self.keyname return self.keyname
@ -76,7 +77,7 @@ class UserAttributes(models.Model):
UserAttributes.create_missing_userattributes(user) UserAttributes.create_missing_userattributes(user)
UserAttributes.add_default_instances(user) UserAttributes.add_default_instances(user)
def __unicode__(self): def __str__(self):
return self.user.username return self.user.username

View file

@ -1,6 +1,7 @@
from django.db.models import Model, CharField, IntegerField from django.db.models import Model, CharField, IntegerField
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
class Compute(Model): class Compute(Model):
name = CharField(_('name'), max_length=64, unique=True) name = CharField(_('name'), max_length=64, unique=True)
hostname = CharField(_('hostname'), max_length=64) hostname = CharField(_('hostname'), max_length=64)
@ -9,5 +10,5 @@ class Compute(Model):
details = CharField(_('details'), max_length=64, null=True, blank=True) details = CharField(_('details'), max_length=64, null=True, blank=True)
type = IntegerField() type = IntegerField()
def __unicode__(self): def __str__(self):
return self.hostname return self.hostname

View file

@ -1,11 +1,12 @@
from django.db.models import Model, CharField, IntegerField from django.db.models import Model, CharField, IntegerField
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
class Flavor(Model): class Flavor(Model):
label = CharField(_('label'), max_length=12) label = CharField(_('label'), max_length=12)
memory = IntegerField(_('memory')) memory = IntegerField(_('memory'))
vcpu = IntegerField(_('vcpu')) vcpu = IntegerField(_('vcpu'))
disk = IntegerField(_('disk')) disk = IntegerField(_('disk'))
def __unicode__(self): def __str__(self):
return self.name return self.name

View file

@ -1,5 +1,4 @@
from django.db.models import (CASCADE, BooleanField, CharField, DateField, from django.db.models import (CASCADE, BooleanField, CharField, DateField, ForeignKey, Model)
ForeignKey, Model)
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from computes.models import Compute from computes.models import Compute
@ -12,17 +11,16 @@ class Instance(Model):
is_template = BooleanField(_('is template'), default=False) is_template = BooleanField(_('is template'), default=False)
created = DateField(_('created'), auto_now_add=True) created = DateField(_('created'), auto_now_add=True)
def __unicode__(self): def __str__(self):
return self.name return self.name
class PermissionSet(Model): class PermissionSet(Model):
""" """
Dummy model for holding set of permissions we need to be automatically added by Django Dummy model for holding set of permissions we need to be automatically added by Django
""" """
class Meta: class Meta:
default_permissions = () default_permissions = ()
permissions = ( permissions = (('clone_instances', _('Can clone instances')), )
('clone_instances', _('Can clone instances')),
)
managed = False managed = False

View file

@ -1,11 +1,12 @@
from django.db.models import Model, CharField, DateTimeField from django.db.models import Model, CharField, DateTimeField
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
class Logs(Model): class Logs(Model):
user = CharField(_('user'), max_length=50) user = CharField(_('user'), max_length=50)
instance = CharField(_('instance'), max_length=50) instance = CharField(_('instance'), max_length=50)
message = CharField(_('message'), max_length=255) message = CharField(_('message'), max_length=255)
date = DateTimeField(_('date'), auto_now=True) date = DateTimeField(_('date'), auto_now=True)
def __unicode__(self): def __str__(self):
return self.instance return self.instance