python3: use @python_2_unicode_compatible on classes
This commit is contained in:
parent
1a6cf82f70
commit
b6d91a1520
|
@ -8,6 +8,7 @@ import threading
|
|||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.text import slugify
|
||||
from django.utils.http import urlquote
|
||||
|
@ -20,6 +21,7 @@ from jsonfield import JSONField
|
|||
from . import utils, managers
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Origin(models.Model):
|
||||
label = models.CharField(_('Label'), max_length=80)
|
||||
slug = models.SlugField(_('Slug'))
|
||||
|
@ -29,10 +31,11 @@ class Origin(models.Model):
|
|||
self.slug = slugify(self.label)
|
||||
return super(Origin, self).save(*args, **kwargs)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class UserDocument(models.Model):
|
||||
'''Document uploaded by an user or an agent'''
|
||||
user = models.ForeignKey(
|
||||
|
@ -77,7 +80,7 @@ class UserDocument(models.Model):
|
|||
def filename_encoded(self):
|
||||
return urlquote(self.filename, safe='')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.title or self.filename
|
||||
|
||||
def get_download_url(self):
|
||||
|
@ -97,6 +100,7 @@ class UserDocument(models.Model):
|
|||
re.sub('[/\.+-]', '-', self.document.mime_type))
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Validation(models.Model):
|
||||
'''Validation of a document as special kind for an user,
|
||||
the data field contains metadata extracted from the document.
|
||||
|
@ -153,7 +157,7 @@ class Validation(models.Model):
|
|||
except UserDocument.DoesNotExist:
|
||||
pass
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.display()
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ from django.conf import settings
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import URLValidator
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils.timezone import now
|
||||
|
@ -46,6 +47,7 @@ def validate_https_url(data):
|
|||
raise ValidationError(errors)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class OAuth2Client(models.Model):
|
||||
client_secret = models.CharField(max_length=255, default=generate_uuid)
|
||||
client_id = models.CharField(max_length=255, default=generate_uuid)
|
||||
|
@ -63,7 +65,7 @@ class OAuth2Client(models.Model):
|
|||
def check_redirect_uri(self, redirect_uri):
|
||||
return redirect_uri in self.redirect_uris.strip().split()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.client_name
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue