Add the @python_2_unicode_compatible to all models. Closes issue #67
This commit is contained in:
@@ -5,6 +5,7 @@ import logging
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _, ugettext
|
||||
|
||||
from solo.models import SingletonModel
|
||||
@@ -18,6 +19,7 @@ from .managers import AccessEntryManager, DefaultAccessEntryManager
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class AccessEntry(models.Model):
|
||||
"""
|
||||
Model that hold the permission, object, actor relationship
|
||||
@@ -51,10 +53,11 @@ class AccessEntry(models.Model):
|
||||
verbose_name = _('Access entry')
|
||||
verbose_name_plural = _('Access entries')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '%s: %s' % (self.content_type, self.content_object)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DefaultAccessEntry(models.Model):
|
||||
"""
|
||||
Model that holds the permission, class, actor relationship, that will
|
||||
@@ -88,7 +91,7 @@ class DefaultAccessEntry(models.Model):
|
||||
verbose_name = _('Default access entry')
|
||||
verbose_name_plural = _('Default access entries')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '%s: %s' % (self.content_type, self.content_object)
|
||||
|
||||
|
||||
@@ -101,10 +104,11 @@ class CreatorSingletonManager(models.Manager):
|
||||
return holder
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CreatorSingleton(SingletonModel):
|
||||
objects = CreatorSingletonManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return ugettext('Creator')
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -5,6 +5,7 @@ import logging
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import Document
|
||||
@@ -16,6 +17,7 @@ from .managers import DocumentCheckoutManager
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentCheckout(models.Model):
|
||||
"""
|
||||
Model to store the state and information of a document checkout
|
||||
@@ -37,7 +39,7 @@ class DocumentCheckout(models.Model):
|
||||
|
||||
objects = DocumentCheckoutManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return unicode(self.document)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
@@ -5,8 +5,8 @@ from pytz import common_timezones
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _, ugettext
|
||||
|
||||
from solo.models import SingletonModel
|
||||
|
||||
@@ -21,10 +21,11 @@ def upload_to(instance, filename):
|
||||
return '/'.join([SHARED_UPLOADED_FILE_PATH, filename])
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class AnonymousUserSingleton(SingletonModel):
|
||||
objects = AnonymousUserSingletonManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return ugettext('Anonymous user')
|
||||
|
||||
class Meta:
|
||||
@@ -40,6 +41,7 @@ class AutoAdminSingleton(SingletonModel):
|
||||
verbose_name = verbose_name_plural = _('Auto admin properties')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SharedUploadedFile(models.Model):
|
||||
file = models.FileField(upload_to=upload_to, storage=shared_storage_backend, verbose_name=_('File'))
|
||||
filename = models.CharField(max_length=255, verbose_name=_('Filename'))
|
||||
@@ -49,7 +51,7 @@ class SharedUploadedFile(models.Model):
|
||||
verbose_name = _('Shared uploaded file')
|
||||
verbose_name_plural = _('Shared uploaded files')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.filename
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
@@ -57,13 +59,14 @@ class SharedUploadedFile(models.Model):
|
||||
return super(SharedUploadedFile, self).delete(*args, **kwargs)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class UserLocaleProfile(models.Model):
|
||||
user = models.OneToOneField(User, related_name='locale_profile', verbose_name=_('User'))
|
||||
|
||||
timezone = models.CharField(choices=zip(common_timezones, common_timezones), max_length=48, verbose_name=_('Timezone'))
|
||||
language = models.CharField(choices=settings.LANGUAGES, max_length=8, verbose_name=_('Language'))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return unicode(self.user)
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
|
||||
from mptt.fields import TreeForeignKey
|
||||
@@ -11,6 +12,7 @@ from documents.models import Document, DocumentType
|
||||
from .managers import IndexManager
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Index(models.Model):
|
||||
name = models.CharField(unique=True, max_length=64, verbose_name=_('Name'), help_text=_('Internal name used to reference this index.'))
|
||||
# TODO: normalize 'title' to 'label'
|
||||
@@ -28,7 +30,7 @@ class Index(models.Model):
|
||||
def instance_root(self):
|
||||
return self.template_root.node_instance.get()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
@models.permalink
|
||||
@@ -60,6 +62,7 @@ class Index(models.Model):
|
||||
verbose_name_plural = _('Indexes')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class IndexTemplateNode(MPTTModel):
|
||||
parent = TreeForeignKey('self', null=True, blank=True)
|
||||
index = models.ForeignKey(Index, verbose_name=_('Index'), related_name='node_templates')
|
||||
@@ -67,7 +70,7 @@ class IndexTemplateNode(MPTTModel):
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'), help_text=_('Causes this node to be visible and updated when document data changes.'))
|
||||
link_documents = models.BooleanField(default=False, verbose_name=_('Link documents'), help_text=_('Check this option to have this node act as a container for documents and not as a parent for further nodes.'))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
if self.is_root_node():
|
||||
return ugettext('<%s Root>') % self.index
|
||||
else:
|
||||
@@ -78,13 +81,14 @@ class IndexTemplateNode(MPTTModel):
|
||||
verbose_name_plural = _('Indexes node template')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class IndexInstanceNode(MPTTModel):
|
||||
parent = TreeForeignKey('self', null=True, blank=True)
|
||||
index_template_node = models.ForeignKey(IndexTemplateNode, related_name='node_instance', verbose_name=_('Index template node'))
|
||||
value = models.CharField(max_length=128, blank=True, verbose_name=_('Value'))
|
||||
documents = models.ManyToManyField(Document, related_name='node_instances', verbose_name=_('Documents'))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def index(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ import uuid
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls.utils import apply_default_acls
|
||||
@@ -46,6 +46,7 @@ def UUID_FUNCTION(*args, **kwargs):
|
||||
return unicode(uuid.uuid4())
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentType(models.Model):
|
||||
"""
|
||||
Define document types or classes to which a specific set of
|
||||
@@ -58,7 +59,7 @@ class DocumentType(models.Model):
|
||||
|
||||
objects = DocumentTypeManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def natural_key(self):
|
||||
@@ -70,6 +71,7 @@ class DocumentType(models.Model):
|
||||
ordering = ['name']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Document(models.Model):
|
||||
"""
|
||||
Defines a single document with it's fields and properties
|
||||
@@ -104,7 +106,7 @@ class Document(models.Model):
|
||||
if os.path.isfile(file_path):
|
||||
os.unlink(file_path)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
@models.permalink
|
||||
@@ -272,6 +274,7 @@ class Document(models.Model):
|
||||
return self.save_to_file(temporary_path, buffer_size)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentVersion(models.Model):
|
||||
"""
|
||||
Model that describes a document version and its properties
|
||||
@@ -302,7 +305,7 @@ class DocumentVersion(models.Model):
|
||||
verbose_name = _('Document version')
|
||||
verbose_name_plural = _('Document version')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '{0} - {1}'.format(self.document, self.timestamp)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
@@ -355,7 +358,7 @@ class DocumentVersion(models.Model):
|
||||
# If converter backend doesn't understand the format,
|
||||
# use 1 as the total page count
|
||||
detected_pages = 1
|
||||
self.description = ugettext('This document\'s file format is not known, the page count has therefore defaulted to 1.')
|
||||
self.description = _('This document\'s file format is not known, the page count has therefore defaulted to 1.')
|
||||
self.save()
|
||||
try:
|
||||
os.remove(filepath)
|
||||
@@ -468,6 +471,7 @@ class DocumentVersion(models.Model):
|
||||
return self.pages.count()
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentTypeFilename(models.Model):
|
||||
"""
|
||||
List of filenames available to a specific document type for the
|
||||
@@ -477,7 +481,7 @@ class DocumentTypeFilename(models.Model):
|
||||
filename = models.CharField(max_length=128, verbose_name=_('Filename'), db_index=True)
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.filename
|
||||
|
||||
class Meta:
|
||||
@@ -487,6 +491,7 @@ class DocumentTypeFilename(models.Model):
|
||||
verbose_name_plural = _('Document types quick rename filenames')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentPage(models.Model):
|
||||
"""
|
||||
Model that describes a document version page including it's content
|
||||
@@ -496,7 +501,7 @@ class DocumentPage(models.Model):
|
||||
page_label = models.CharField(max_length=40, blank=True, null=True, verbose_name=_('Page label'))
|
||||
page_number = models.PositiveIntegerField(default=1, editable=False, verbose_name=_('Page number'), db_index=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return _('Page %(page_num)d out of %(total_pages)d of %(document)s') % {
|
||||
'document': unicode(self.document),
|
||||
'page_num': self.page_number,
|
||||
@@ -533,6 +538,7 @@ def argument_validator(value):
|
||||
raise ValidationError(_('Enter a valid value.'), code='invalid')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentPageTransformation(models.Model):
|
||||
"""
|
||||
Model that stores the transformation and transformation arguments
|
||||
@@ -544,7 +550,7 @@ class DocumentPageTransformation(models.Model):
|
||||
arguments = models.TextField(blank=True, null=True, verbose_name=_('Arguments'), help_text=_('Use dictionaries to indentify arguments, example: {\'degrees\':90}'), validators=[argument_validator])
|
||||
objects = DocumentPageTransformationManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.get_transformation_display()
|
||||
|
||||
class Meta:
|
||||
@@ -553,6 +559,7 @@ class DocumentPageTransformation(models.Model):
|
||||
verbose_name_plural = _('Document page transformations')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class RecentDocument(models.Model):
|
||||
"""
|
||||
Keeps a list of the n most recent accessed or created document for
|
||||
@@ -564,7 +571,7 @@ class RecentDocument(models.Model):
|
||||
|
||||
objects = RecentDocumentManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return unicode(self.document)
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -6,12 +6,13 @@ import urlparse
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.utils.encoding import smart_str, smart_unicode
|
||||
from django.utils.encoding import python_2_unicode_compatible, smart_str, smart_unicode
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .managers import RecentSearchManager
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class RecentSearch(models.Model):
|
||||
"""
|
||||
Keeps a list of the n most recent search keywords for a given user
|
||||
@@ -28,7 +29,7 @@ class RecentSearch(models.Model):
|
||||
|
||||
objects = RecentSearchManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
# TODO: Fix this hack, store the search model name in the recent search entry
|
||||
from .classes import SearchModel
|
||||
document_search = SearchModel.get('documents.Document')
|
||||
|
||||
@@ -2,18 +2,20 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import Document
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Folder(models.Model):
|
||||
title = models.CharField(max_length=128, verbose_name=_('Title'), db_index=True)
|
||||
user = models.ForeignKey(User, verbose_name=_('User'))
|
||||
datetime_created = models.DateTimeField(verbose_name=_('Datetime created'), auto_now_add=True)
|
||||
documents = models.ManyToManyField(Document, related_name='folders', verbose_name=_('Documents'))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
@models.permalink
|
||||
|
||||
@@ -2,15 +2,18 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import Document, DocumentType
|
||||
|
||||
from .literals import (INCLUSION_AND, INCLUSION_CHOICES, INCLUSION_OR,
|
||||
OPERATOR_CHOICES)
|
||||
from .literals import (
|
||||
INCLUSION_AND, INCLUSION_CHOICES, INCLUSION_OR, OPERATOR_CHOICES
|
||||
)
|
||||
from .managers import SmartLinkManager
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SmartLink(models.Model):
|
||||
title = models.CharField(max_length=96, verbose_name=_('Title'))
|
||||
dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_('Dynamic title'), help_text=_('This expression will be evaluated against the current selected document.'))
|
||||
@@ -19,7 +22,7 @@ class SmartLink(models.Model):
|
||||
|
||||
objects = SmartLinkManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def get_dynamic_title(self, document):
|
||||
@@ -59,6 +62,7 @@ class SmartLink(models.Model):
|
||||
verbose_name_plural = _('Smart links')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SmartLinkCondition(models.Model):
|
||||
smart_link = models.ForeignKey(SmartLink, related_name='conditions', verbose_name=_('Smart link'))
|
||||
inclusion = models.CharField(default=INCLUSION_AND, max_length=16, choices=INCLUSION_CHOICES, help_text=_('The inclusion is ignored for the first item.'))
|
||||
@@ -68,7 +72,7 @@ class SmartLinkCondition(models.Model):
|
||||
negated = models.BooleanField(default=False, verbose_name=_('Negated'), help_text=_('Inverts the logic of the operator.'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '%s foreign %s %s %s %s' % (self.get_inclusion_display(), self.foreign_document_data, _('not') if self.negated else '', self.get_operator_display(), self.expression)
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .managers import LockManager
|
||||
from .settings import DEFAULT_LOCK_TIMEOUT
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Lock(models.Model):
|
||||
creation_datetime = models.DateTimeField(verbose_name=_('Creation datetime'), auto_now_add=True)
|
||||
timeout = models.IntegerField(default=DEFAULT_LOCK_TIMEOUT, verbose_name=_('Timeout'))
|
||||
@@ -14,7 +16,7 @@ class Lock(models.Model):
|
||||
|
||||
objects = LockManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import Document, DocumentType
|
||||
@@ -10,6 +11,7 @@ from .managers import MetadataTypeManager
|
||||
from .settings import AVAILABLE_VALIDATORS
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MetadataType(models.Model):
|
||||
"""
|
||||
Define a type of metadata
|
||||
@@ -30,7 +32,7 @@ class MetadataType(models.Model):
|
||||
# available now that we removed these from the help_text
|
||||
objects = MetadataTypeManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def natural_key(self):
|
||||
@@ -42,6 +44,7 @@ class MetadataType(models.Model):
|
||||
verbose_name_plural = _('Metadata types')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentMetadata(models.Model):
|
||||
"""
|
||||
Link a document to a specific instance of a metadata type with it's
|
||||
@@ -51,7 +54,7 @@ class DocumentMetadata(models.Model):
|
||||
metadata_type = models.ForeignKey(MetadataType, verbose_name=_('Type'))
|
||||
value = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('Value'), db_index=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return unicode(self.metadata_type)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
@@ -72,12 +75,13 @@ class DocumentMetadata(models.Model):
|
||||
verbose_name_plural = _('Document metadata')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DocumentTypeMetadataType(models.Model):
|
||||
document_type = models.ForeignKey(DocumentType, related_name='metadata', verbose_name=_('Document type'))
|
||||
metadata_type = models.ForeignKey(MetadataType, verbose_name=_('Metadata type'))
|
||||
required = models.BooleanField(default=False, verbose_name=_('Required'))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return unicode(self.metadata_type)
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -7,6 +7,7 @@ from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -122,6 +123,7 @@ Permission.objects = PermissionManager(Permission)
|
||||
Permission._default_manager = Permission.objects
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class StoredPermission(models.Model):
|
||||
namespace = models.CharField(max_length=64, verbose_name=_('Namespace'))
|
||||
name = models.CharField(max_length=64, verbose_name=_('Name'))
|
||||
@@ -143,7 +145,7 @@ class StoredPermission(models.Model):
|
||||
# longer used in the current code
|
||||
pass
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return unicode(getattr(self, 'volatile_permission', self.name))
|
||||
|
||||
def get_holders(self):
|
||||
@@ -192,6 +194,7 @@ class StoredPermission(models.Model):
|
||||
return True
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class PermissionHolder(models.Model):
|
||||
permission = models.ForeignKey(StoredPermission, verbose_name=_('Permission'))
|
||||
holder_type = models.ForeignKey(ContentType,
|
||||
@@ -204,10 +207,11 @@ class PermissionHolder(models.Model):
|
||||
verbose_name = _('Permission holder')
|
||||
verbose_name_plural = _('Permission holders')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '%s: %s' % (self.holder_type, self.holder_object)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Role(models.Model):
|
||||
name = models.CharField(max_length=64, unique=True)
|
||||
label = models.CharField(max_length=64, unique=True, verbose_name=_('Label'))
|
||||
@@ -217,7 +221,7 @@ class Role(models.Model):
|
||||
verbose_name = _('Role')
|
||||
verbose_name_plural = _('Roles')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
@models.permalink
|
||||
@@ -244,6 +248,7 @@ class Role(models.Model):
|
||||
return (member.member_object for member in self.rolemember_set.filter(**filter_dict))
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class RoleMember(models.Model):
|
||||
role = models.ForeignKey(Role, verbose_name=_('Role'))
|
||||
member_type = models.ForeignKey(
|
||||
@@ -264,5 +269,5 @@ class RoleMember(models.Model):
|
||||
verbose_name = _('Role member')
|
||||
verbose_name_plural = _('Role members')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return unicode(self.member_object)
|
||||
|
||||
@@ -14,6 +14,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files import File
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from model_utils.managers import InheritanceManager
|
||||
@@ -37,6 +38,7 @@ from .managers import SourceTransformationManager
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Source(models.Model):
|
||||
title = models.CharField(max_length=64, verbose_name=_('Title'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'))
|
||||
@@ -47,7 +49,7 @@ class Source(models.Model):
|
||||
def class_fullname(cls):
|
||||
return unicode(dict(SOURCE_CHOICES).get(cls.source_type))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '%s' % self.title
|
||||
|
||||
def fullname(self):
|
||||
@@ -364,6 +366,7 @@ def argument_validator(value):
|
||||
raise ValidationError(_('Enter a valid value.'), code='invalid')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SourceTransformation(models.Model):
|
||||
"""
|
||||
Model that stores the transformation and transformation arguments
|
||||
@@ -379,7 +382,7 @@ class SourceTransformation(models.Model):
|
||||
objects = models.Manager()
|
||||
transformations = SourceTransformationManager()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.get_transformation_display()
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import Document
|
||||
@@ -8,6 +9,7 @@ from documents.models import Document
|
||||
from .literals import COLOR_CHOICES, COLOR_CODES
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Tag(models.Model):
|
||||
label = models.CharField(max_length=128, verbose_name=_('Label'), unique=True, db_index=True)
|
||||
color = models.CharField(max_length=3, choices=COLOR_CHOICES, verbose_name=_('Color'))
|
||||
@@ -17,7 +19,7 @@ class Tag(models.Model):
|
||||
verbose_name = _('Tag')
|
||||
verbose_name_plural = _('Tags')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
def get_color_code(self):
|
||||
|
||||
Reference in New Issue
Block a user