Replace all instances of unicode only handling to use force_text.
Replace all __unicode__ methods to __str__ and the @python_2_unicode_compatible decorator. Replace all instance of smart_str, smart_unicode, force_uncode with force_text. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import logging
|
|||||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from permissions.models import Role, StoredPermission
|
from permissions.models import Role, StoredPermission
|
||||||
@@ -68,7 +68,7 @@ class AccessControlList(models.Model):
|
|||||||
|
|
||||||
def get_permission_titles(self):
|
def get_permission_titles(self):
|
||||||
result = ', '.join(
|
result = ', '.join(
|
||||||
[unicode(permission) for permission in self.permissions.all()]
|
[force_text(permission) for permission in self.permissions.all()]
|
||||||
)
|
)
|
||||||
|
|
||||||
return result or _('None')
|
return result or _('None')
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import Http404, HttpResponseRedirect
|
from django.http import Http404, HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from common.views import (
|
from common.views import (
|
||||||
@@ -156,7 +157,7 @@ class ACLPermissionsView(AssignRemoveView):
|
|||||||
|
|
||||||
for namespace, permissions in itertools.groupby(entries, lambda entry: entry.namespace):
|
for namespace, permissions in itertools.groupby(entries, lambda entry: entry.namespace):
|
||||||
permission_options = [
|
permission_options = [
|
||||||
(unicode(permission.pk), permission) for permission in permissions
|
(force_text(permission.pk), permission) for permission in permissions
|
||||||
]
|
]
|
||||||
results.append(
|
results.append(
|
||||||
(PermissionNamespace.get(namespace), permission_options)
|
(PermissionNamespace.get(namespace), permission_options)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from rest_framework import generics, status
|
from rest_framework import generics, status
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
@@ -76,7 +77,7 @@ class APICheckedoutDocumentListView(generics.ListCreateAPIView):
|
|||||||
)
|
)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
return Response(
|
return Response(
|
||||||
data={'exception': unicode(exception)},
|
data={'exception': force_text(exception)},
|
||||||
status=status.HTTP_400_BAD_REQUEST
|
status=status.HTTP_400_BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext
|
||||||
|
|
||||||
|
|
||||||
@@ -17,11 +18,12 @@ class DocumentNotCheckedOut(DocumentCheckoutError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class DocumentAlreadyCheckedOut(DocumentCheckoutError):
|
class DocumentAlreadyCheckedOut(DocumentCheckoutError):
|
||||||
"""
|
"""
|
||||||
Raised when trying to checkout an already checkedout document
|
Raised when trying to checkout an already checkedout document
|
||||||
"""
|
"""
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return ugettext('Document already checked out.')
|
return ugettext('Document already checked out.')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from django.conf import settings
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ class DocumentCheckout(models.Model):
|
|||||||
objects = DocumentCheckoutManager()
|
objects = DocumentCheckoutManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.document)
|
return force_text(self.document)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if self.expiration_datetime < now():
|
if self.expiration_datetime < now():
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ from __future__ import unicode_literals
|
|||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Collection(object):
|
class Collection(object):
|
||||||
_registry = []
|
_registry = []
|
||||||
|
|
||||||
@@ -22,8 +24,8 @@ class Collection(object):
|
|||||||
self._order = order or 99
|
self._order = order or 99
|
||||||
self.__class__._registry.append(self)
|
self.__class__._registry.append(self)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
def resolve(self):
|
def resolve(self):
|
||||||
self.children = self._get_children()
|
self.children = self._get_children()
|
||||||
@@ -61,6 +63,7 @@ class DashboardWidget(object):
|
|||||||
self.__class__._registry.append(self)
|
self.__class__._registry.append(self)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class ModelAttribute(object):
|
class ModelAttribute(object):
|
||||||
__registry = {}
|
__registry = {}
|
||||||
|
|
||||||
@@ -98,7 +101,7 @@ class ModelAttribute(object):
|
|||||||
for count, attribute in enumerate(cls.get_for(model, type_names), 1):
|
for count, attribute in enumerate(cls.get_for(model, type_names), 1):
|
||||||
result.append(
|
result.append(
|
||||||
'{}) {}'.format(
|
'{}) {}'.format(
|
||||||
count, unicode(attribute.get_display(show_name=True))
|
count, force_text(attribute.get_display(show_name=True))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -112,9 +115,9 @@ class ModelAttribute(object):
|
|||||||
self.name if show_name else self.label, self.description
|
self.name if show_name else self.label, self.description
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return unicode(self.name if show_name else self.label)
|
return force_text(self.name if show_name else self.label)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.get_display()
|
return self.get_display()
|
||||||
|
|
||||||
def __init__(self, model, name, label=None, description=None, type_name=None):
|
def __init__(self, model, name, label=None, description=None, type_name=None):
|
||||||
@@ -154,6 +157,7 @@ class MissingItem(object):
|
|||||||
self.__class__._registry.append(self)
|
self.__class__._registry.append(self)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Filter(object):
|
class Filter(object):
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
@@ -175,8 +179,8 @@ class Filter(object):
|
|||||||
|
|
||||||
self.__class__._registry[self.slug] = self
|
self.__class__._registry[self.slug] = self
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
def get_queryset(self, user):
|
def get_queryset(self, user):
|
||||||
AccessControlList = apps.get_model(
|
AccessControlList = apps.get_model(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from django.conf import settings
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.views.generic import (
|
from django.views.generic import (
|
||||||
FormView as DjangoFormView, DetailView, TemplateView
|
FormView as DjangoFormView, DetailView, TemplateView
|
||||||
@@ -56,7 +57,7 @@ class AssignRemoveView(ExtraContextMixin, ViewPermissionCheckMixin, ObjectPermis
|
|||||||
results = []
|
results = []
|
||||||
for choice in choices:
|
for choice in choices:
|
||||||
ct = ContentType.objects.get_for_model(choice)
|
ct = ContentType.objects.get_for_model(choice)
|
||||||
label = unicode(choice)
|
label = force_text(choice)
|
||||||
|
|
||||||
results.append(('%s,%s' % (ct.model, choice.pk), '%s' % (label)))
|
results.append(('%s,%s' % (ct.model, choice.pk), '%s' % (label)))
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from pytz import common_timezones
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from .runtime import shared_storage_backend
|
from .runtime import shared_storage_backend
|
||||||
@@ -35,7 +35,7 @@ class SharedUploadedFile(models.Model):
|
|||||||
return self.filename
|
return self.filename
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
self.filename = unicode(self.file)
|
self.filename = force_text(self.file)
|
||||||
super(SharedUploadedFile, self).save(*args, **kwargs)
|
super(SharedUploadedFile, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
@@ -61,7 +61,7 @@ class UserLocaleProfile(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.user)
|
return force_text(self.user)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('User locale profile')
|
verbose_name = _('User locale profile')
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import sh
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template import Context, Library
|
from django.template import Context, Library
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
import mayan
|
import mayan
|
||||||
|
|
||||||
@@ -101,4 +102,4 @@ def build():
|
|||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def get_type(value):
|
def get_type(value):
|
||||||
return unicode(type(value))
|
return force_text(type(value))
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from django.conf import settings
|
|||||||
from django.core.urlresolvers import resolve as django_resolve
|
from django.core.urlresolvers import resolve as django_resolve
|
||||||
from django.urls.base import get_script_prefix
|
from django.urls.base import get_script_prefix
|
||||||
from django.utils.datastructures import MultiValueDict
|
from django.utils.datastructures import MultiValueDict
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.http import urlquote as django_urlquote
|
from django.utils.http import urlquote as django_urlquote
|
||||||
from django.utils.http import urlencode as django_urlencode
|
from django.utils.http import urlencode as django_urlencode
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ def return_attrib(obj, attrib, arguments=None):
|
|||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
return 'Attribute error: %s; %s' % (attrib, exception)
|
return 'Attribute error: %s; %s' % (attrib, exception)
|
||||||
else:
|
else:
|
||||||
return unicode(exception)
|
return force_text(exception)
|
||||||
|
|
||||||
|
|
||||||
def urlquote(link=None, get=None):
|
def urlquote(link=None, get=None):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.forms.utils import flatatt
|
from django.forms.utils import flatatt
|
||||||
from django.utils.encoding import force_unicode, force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import conditional_escape, format_html
|
from django.utils.html import conditional_escape, format_html
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@@ -122,7 +122,7 @@ class TextAreaDiv(forms.widgets.Widget):
|
|||||||
value = ''
|
value = ''
|
||||||
|
|
||||||
flat_attrs = flatatt(self.build_attrs(attrs, name=name))
|
flat_attrs = flatatt(self.build_attrs(attrs, name=name))
|
||||||
content = conditional_escape(force_unicode(value))
|
content = conditional_escape(force_text(value))
|
||||||
result = '<pre%s>%s</pre>' % (flat_attrs, content)
|
result = '<pre%s>%s</pre>' % (flat_attrs, content)
|
||||||
return mark_safe(result)
|
return mark_safe(result)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from common import MayanAppConfig, menu_object, menu_sidebar
|
from common import MayanAppConfig, menu_object, menu_sidebar
|
||||||
@@ -26,7 +27,7 @@ class ConverterApp(MayanAppConfig):
|
|||||||
SourceColumn(source=Transformation, label=_('Order'), attribute='order')
|
SourceColumn(source=Transformation, label=_('Order'), attribute='order')
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=Transformation, label=_('Transformation'),
|
source=Transformation, label=_('Transformation'),
|
||||||
func=lambda context: unicode(context['object'])
|
func=lambda context: force_text(context['object'])
|
||||||
)
|
)
|
||||||
SourceColumn(
|
SourceColumn(
|
||||||
source=Transformation, label=_('Arguments'), attribute='arguments'
|
source=Transformation, label=_('Arguments'), attribute='arguments'
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from common.classes import ModelAttribute
|
from common.classes import ModelAttribute
|
||||||
@@ -27,7 +28,7 @@ class IndexTemplateNodeForm(forms.ModelForm):
|
|||||||
self.fields['parent'].widget = forms.widgets.HiddenInput()
|
self.fields['parent'].widget = forms.widgets.HiddenInput()
|
||||||
self.fields['expression'].help_text = ' '.join(
|
self.fields['expression'].help_text = ' '.join(
|
||||||
[
|
[
|
||||||
unicode(self.fields['expression'].help_text),
|
force_text(self.fields['expression'].help_text),
|
||||||
ModelAttribute.help_text_for(
|
ModelAttribute.help_text_for(
|
||||||
Document, type_names=['indexing']
|
Document, type_names=['indexing']
|
||||||
).replace('\n', '<br>')
|
).replace('\n', '<br>')
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import logging
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.template import Context, Template
|
from django.template import Context, Template
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||||
|
|
||||||
from mptt.fields import TreeForeignKey
|
from mptt.fields import TreeForeignKey
|
||||||
@@ -81,7 +81,7 @@ class Index(models.Model):
|
|||||||
def get_document_types_names(self):
|
def get_document_types_names(self):
|
||||||
return ', '.join(
|
return ', '.join(
|
||||||
[
|
[
|
||||||
unicode(document_type) for document_type in self.document_types.all()
|
force_text(document_type) for document_type in self.document_types.all()
|
||||||
] or ['None']
|
] or ['None']
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -314,9 +314,9 @@ class IndexInstanceNode(MPTTModel):
|
|||||||
result = []
|
result = []
|
||||||
for node in self.get_ancestors(include_self=True):
|
for node in self.get_ancestors(include_self=True):
|
||||||
if node.is_root_node():
|
if node.is_root_node():
|
||||||
result.append(unicode(self.index()))
|
result.append(force_text(self.index()))
|
||||||
else:
|
else:
|
||||||
result.append(unicode(node))
|
result.append(force_text(node))
|
||||||
|
|
||||||
return ' / '.join(result)
|
return ' / '.join(result)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import mark_safe, escape
|
from django.utils.html import mark_safe, escape
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ def node_level(node):
|
|||||||
[
|
[
|
||||||
' ' * node.get_level(),
|
' ' * node.get_level(),
|
||||||
'' if node.is_root_node() else '<i class="fa fa-level-up fa-rotate-90"></i> ',
|
'' if node.is_root_node() else '<i class="fa fa-level-up fa-rotate-90"></i> ',
|
||||||
unicode(node)
|
force_text(node)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import uuid
|
|||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from model_utils.managers import InheritanceManager
|
from model_utils.managers import InheritanceManager
|
||||||
@@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def upload_to(*args, **kwargs):
|
def upload_to(*args, **kwargs):
|
||||||
return unicode(uuid.uuid4())
|
return force_text(uuid.uuid4())
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from django.core.files import File
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from acls.models import AccessControlList
|
from acls.models import AccessControlList
|
||||||
@@ -284,7 +285,7 @@ class DocumentVersionSignatureDownloadView(SingleObjectDownloadView):
|
|||||||
signature = self.get_object()
|
signature = self.get_object()
|
||||||
|
|
||||||
return DocumentVersionSignatureDownloadView.VirtualFile(
|
return DocumentVersionSignatureDownloadView.VirtualFile(
|
||||||
signature.signature_file, name=unicode(signature)
|
signature.signature_file, name=force_text(signature)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from django.conf import settings
|
|||||||
from django.core.exceptions import PermissionDenied, ValidationError
|
from django.core.exceptions import PermissionDenied, ValidationError
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import IntegrityError, models
|
from django.db import IntegrityError, models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from acls.models import AccessControlList
|
from acls.models import AccessControlList
|
||||||
@@ -159,7 +159,7 @@ class WorkflowInstance(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.workflow)
|
return force_text(self.workflow)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse(
|
return reverse(
|
||||||
@@ -277,7 +277,7 @@ class WorkflowInstanceLogEntry(models.Model):
|
|||||||
comment = models.TextField(blank=True, verbose_name=_('Comment'))
|
comment = models.TextField(blank=True, verbose_name=_('Comment'))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.transition)
|
return force_text(self.transition)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Workflow instance log entry')
|
verbose_name = _('Workflow instance log entry')
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import logging
|
|||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from django_downloadview import DownloadMixin, VirtualFile
|
from django_downloadview import DownloadMixin, VirtualFile
|
||||||
from rest_framework import generics, status
|
from rest_framework import generics, status
|
||||||
@@ -198,7 +199,7 @@ class APIDocumentVersionDownloadView(DownloadMixin, generics.RetrieveAPIView):
|
|||||||
|
|
||||||
def get_file(self):
|
def get_file(self):
|
||||||
instance = self.get_object()
|
instance = self.get_object()
|
||||||
return VirtualFile(instance.file, name=unicode(instance))
|
return VirtualFile(instance.file, name=force_text(instance))
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from django.conf import settings
|
|||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ def HASH_FUNCTION(data):
|
|||||||
|
|
||||||
|
|
||||||
def UUID_FUNCTION(*args, **kwargs):
|
def UUID_FUNCTION(*args, **kwargs):
|
||||||
return unicode(uuid.uuid4())
|
return force_text(uuid.uuid4())
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
@@ -433,7 +433,7 @@ class DocumentVersion(models.Model):
|
|||||||
|
|
||||||
self.document.is_stub = False
|
self.document.is_stub = False
|
||||||
if not self.document.label:
|
if not self.document.label:
|
||||||
self.document.label = unicode(self.file)
|
self.document.label = force_text(self.file)
|
||||||
|
|
||||||
self.document.save()
|
self.document.save()
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
@@ -584,7 +584,7 @@ class DocumentVersion(models.Model):
|
|||||||
"""
|
"""
|
||||||
if self.exists():
|
if self.exists():
|
||||||
source = self.open()
|
source = self.open()
|
||||||
self.checksum = unicode(HASH_FUNCTION(source.read()))
|
self.checksum = force_text(HASH_FUNCTION(source.read()))
|
||||||
source.close()
|
source.close()
|
||||||
if save:
|
if save:
|
||||||
self.save()
|
self.save()
|
||||||
@@ -682,7 +682,7 @@ class DocumentPage(models.Model):
|
|||||||
return _(
|
return _(
|
||||||
'Page %(page_num)d out of %(total_pages)d of %(document)s'
|
'Page %(page_num)d out of %(total_pages)d of %(document)s'
|
||||||
) % {
|
) % {
|
||||||
'document': unicode(self.document),
|
'document': force_text(self.document),
|
||||||
'page_num': self.page_number,
|
'page_num': self.page_number,
|
||||||
'total_pages': self.document_version.pages.count()
|
'total_pages': self.document_version.pages.count()
|
||||||
}
|
}
|
||||||
@@ -881,7 +881,7 @@ class RecentDocument(models.Model):
|
|||||||
objects = RecentDocumentManager()
|
objects = RecentDocumentManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.document)
|
return force_text(self.document)
|
||||||
|
|
||||||
def natural_key(self):
|
def natural_key(self):
|
||||||
return self.document.natural_key() + self.user.natural_key()
|
return self.document.natural_key() + self.user.natural_key()
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
@@ -281,7 +283,7 @@ class NewDocumentSerializer(serializers.ModelSerializer):
|
|||||||
description=self.validated_data.get('description', ''),
|
description=self.validated_data.get('description', ''),
|
||||||
document_type=self.validated_data['document_type'],
|
document_type=self.validated_data['document_type'],
|
||||||
label=self.validated_data.get(
|
label=self.validated_data.get(
|
||||||
'label', unicode(self.validated_data['file'])
|
'label', force_text(self.validated_data['file'])
|
||||||
),
|
),
|
||||||
language=self.validated_data.get(
|
language=self.validated_data.get(
|
||||||
'language', setting_language.value
|
'language', setting_language.value
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import override_settings
|
from django.test import override_settings
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from common.tests.test_views import GenericViewTestCase
|
from common.tests.test_views import GenericViewTestCase
|
||||||
from converter.models import Transformation
|
from converter.models import Transformation
|
||||||
@@ -482,7 +483,7 @@ class DocumentsViewsTestCase(GenericDocumentViewTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertContains(
|
self.assertContains(
|
||||||
response, unicode(self.document.pages.first()), status_code=200
|
response, force_text(self.document.pages.first()), status_code=200
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from django.core.exceptions import PermissionDenied
|
|||||||
from django.core.urlresolvers import reverse, reverse_lazy
|
from django.core.urlresolvers import reverse, reverse_lazy
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.utils.translation import ugettext_lazy as _, ungettext
|
from django.utils.translation import ugettext_lazy as _, ungettext
|
||||||
|
|
||||||
@@ -454,7 +455,7 @@ class DocumentDownloadView(SingleObjectDownloadView):
|
|||||||
if isinstance(item, Document):
|
if isinstance(item, Document):
|
||||||
return item.label
|
return item.label
|
||||||
else:
|
else:
|
||||||
return unicode(item)
|
return force_text(item)
|
||||||
|
|
||||||
def get_document_queryset(self):
|
def get_document_queryset(self):
|
||||||
id_list = self.request.GET.get(
|
id_list = self.request.GET.get(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import strip_tags
|
from django.utils.html import strip_tags
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
@@ -308,7 +309,7 @@ class DocumentThumbnailWidget(BaseDocumentThumbnailWidget):
|
|||||||
|
|
||||||
class DocumentPageThumbnailWidget(BaseDocumentThumbnailWidget):
|
class DocumentPageThumbnailWidget(BaseDocumentThumbnailWidget):
|
||||||
def get_title(self, instance):
|
def get_title(self, instance):
|
||||||
return unicode(instance)
|
return force_text(instance)
|
||||||
|
|
||||||
|
|
||||||
class InteractiveDocumentPageWidget(BaseDocumentThumbnailWidget):
|
class InteractiveDocumentPageWidget(BaseDocumentThumbnailWidget):
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ class APISearchView(SearchModelMixin, generics.ListAPIView):
|
|||||||
query_string=self.request.GET, user=self.request.user
|
query_string=self.request.GET, user=self.request.user
|
||||||
)
|
)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
raise ParseError(unicode(exception))
|
raise ParseError(force_text(exception))
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
@@ -83,7 +85,7 @@ class APIAdvancedSearchView(SearchModelMixin, generics.ListAPIView):
|
|||||||
global_and_search=global_and_search
|
global_and_search=global_and_search
|
||||||
)
|
)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
raise ParseError(unicode(exception))
|
raise ParseError(force_text(exception))
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import re
|
|||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
@@ -220,7 +221,7 @@ class SearchModel(object):
|
|||||||
|
|
||||||
result_set = result_set | model_result_set
|
result_set = result_set | model_result_set
|
||||||
|
|
||||||
elapsed_time = unicode(
|
elapsed_time = force_text(
|
||||||
datetime.datetime.now() - start_time
|
datetime.datetime.now() - start_time
|
||||||
).split(':')[2]
|
).split(':')[2]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from .classes import SearchModel
|
from .classes import SearchModel
|
||||||
|
|
||||||
@@ -10,4 +11,4 @@ class SearchModelMixin(object):
|
|||||||
try:
|
try:
|
||||||
return SearchModel.get(self.kwargs['search_model'])
|
return SearchModel.get(self.kwargs['search_model'])
|
||||||
except KeyError as exception:
|
except KeyError as exception:
|
||||||
raise Http404(unicode(exception))
|
raise Http404(force_text(exception))
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from actstream import action
|
from actstream import action
|
||||||
@@ -27,7 +28,7 @@ class Event(object):
|
|||||||
try:
|
try:
|
||||||
return cls.get(name=name).label
|
return cls.get(name=name).label
|
||||||
except KeyError as exception:
|
except KeyError as exception:
|
||||||
return unicode(exception)
|
return force_text(exception)
|
||||||
|
|
||||||
def __init__(self, name, label):
|
def __init__(self, name, label):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from common.classes import ModelAttribute
|
from common.classes import ModelAttribute
|
||||||
@@ -14,7 +15,7 @@ class SmartLinkForm(forms.ModelForm):
|
|||||||
super(SmartLinkForm, self).__init__(*args, **kwargs)
|
super(SmartLinkForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['dynamic_label'].help_text = ' '.join(
|
self.fields['dynamic_label'].help_text = ' '.join(
|
||||||
[
|
[
|
||||||
unicode(self.fields['dynamic_label'].help_text),
|
force_text(self.fields['dynamic_label'].help_text),
|
||||||
ModelAttribute.help_text_for(
|
ModelAttribute.help_text_for(
|
||||||
Document, type_names=['field', 'related', 'property']
|
Document, type_names=['field', 'related', 'property']
|
||||||
).replace('\n', '<br>')
|
).replace('\n', '<br>')
|
||||||
@@ -36,7 +37,7 @@ class SmartLinkConditionForm(forms.ModelForm):
|
|||||||
)
|
)
|
||||||
self.fields['expression'].help_text = ' '.join(
|
self.fields['expression'].help_text = ' '.join(
|
||||||
[
|
[
|
||||||
unicode(self.fields['expression'].help_text),
|
force_text(self.fields['expression'].help_text),
|
||||||
ModelAttribute.help_text_for(
|
ModelAttribute.help_text_for(
|
||||||
Document, type_names=['field', 'related', 'property']
|
Document, type_names=['field', 'related', 'property']
|
||||||
).replace('\n', '<br>')
|
).replace('\n', '<br>')
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.template import Context, Template
|
from django.template import Context, Template
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from documents.models import Document, DocumentType
|
from documents.models import Document, DocumentType
|
||||||
@@ -43,7 +43,9 @@ class SmartLink(models.Model):
|
|||||||
return template.render(context=context)
|
return template.render(context=context)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
return _(
|
return _(
|
||||||
'Error generating dynamic label; %s' % unicode(exception)
|
'Error generating dynamic label; %s' % force_text(
|
||||||
|
exception
|
||||||
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class DocumentMetadata(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.metadata_type)
|
return force_text(self.metadata_type)
|
||||||
|
|
||||||
def delete(self, enforce_required=True, *args, **kwargs):
|
def delete(self, enforce_required=True, *args, **kwargs):
|
||||||
if enforce_required and self.metadata_type.pk in self.document.document_type.metadata.filter(required=True).values_list('metadata_type', flat=True):
|
if enforce_required and self.metadata_type.pk in self.document.document_type.metadata.filter(required=True).values_list('metadata_type', flat=True):
|
||||||
@@ -209,7 +209,7 @@ class DocumentTypeMetadataType(models.Model):
|
|||||||
required = models.BooleanField(default=False, verbose_name=_('Required'))
|
required = models.BooleanField(default=False, verbose_name=_('Required'))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.metadata_type)
|
return force_text(self.metadata_type)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('document_type', 'metadata_type')
|
unique_together = ('document_type', 'metadata_type')
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ class DocumentMetadataEditView(MultipleObjectFormActionView):
|
|||||||
if isinstance(error, ValidationError):
|
if isinstance(error, ValidationError):
|
||||||
exception_message = ', '.join(error.messages)
|
exception_message = ', '.join(error.messages)
|
||||||
else:
|
else:
|
||||||
exception_message = unicode(error)
|
exception_message = force_text(error)
|
||||||
|
|
||||||
messages.error(
|
messages.error(
|
||||||
self.request, _(
|
self.request, _(
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from django.core.exceptions import PermissionDenied
|
|||||||
from django.core.urlresolvers import resolve, reverse
|
from django.core.urlresolvers import resolve, reverse
|
||||||
from django.template import VariableDoesNotExist, Variable
|
from django.template import VariableDoesNotExist, Variable
|
||||||
from django.template.defaulttags import URLNode
|
from django.template.defaulttags import URLNode
|
||||||
from django.utils.encoding import force_text, smart_str, smart_unicode
|
from django.utils.encoding import force_text
|
||||||
from django.utils.http import urlencode, urlquote
|
from django.utils.http import urlencode, urlquote
|
||||||
|
|
||||||
from common.utils import return_attrib
|
from common.utils import return_attrib
|
||||||
@@ -351,11 +351,11 @@ class Link(object):
|
|||||||
# Lets a new link keep the same URL query string of the current URL
|
# Lets a new link keep the same URL query string of the current URL
|
||||||
if self.keep_query:
|
if self.keep_query:
|
||||||
# Sometimes we are required to remove a key from the URL QS
|
# Sometimes we are required to remove a key from the URL QS
|
||||||
previous_path = smart_unicode(
|
previous_path = force_text(
|
||||||
urllib.unquote_plus(
|
urllib.unquote_plus(
|
||||||
smart_str(
|
force_text(
|
||||||
request.get_full_path()
|
request.get_full_path()
|
||||||
) or smart_str(
|
) or force_text(
|
||||||
request.META.get(
|
request.META.get(
|
||||||
'HTTP_REFERER',
|
'HTTP_REFERER',
|
||||||
reverse(settings.LOGIN_REDIRECT_URL)
|
reverse(settings.LOGIN_REDIRECT_URL)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.encoding import force_unicode
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import conditional_escape
|
from django.utils.html import conditional_escape
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import ugettext_lazy as _, ugettext
|
from django.utils.translation import ugettext_lazy as _, ugettext
|
||||||
@@ -33,7 +33,7 @@ class DocumentContentForm(forms.Form):
|
|||||||
except DocumentPageContent.DoesNotExist:
|
except DocumentPageContent.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
content.append(conditional_escape(force_unicode(page_content)))
|
content.append(conditional_escape(force_text(page_content)))
|
||||||
content.append(
|
content.append(
|
||||||
'\n\n\n<hr/><div class="document-page-content-divider">- %s -</div><hr/>\n\n\n' % (
|
'\n\n\n<hr/><div class="document-page-content-divider">- %s -</div><hr/>\n\n\n' % (
|
||||||
ugettext(
|
ugettext(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from documents.models import DocumentPage, DocumentType, DocumentVersion
|
from documents.models import DocumentPage, DocumentType, DocumentVersion
|
||||||
@@ -37,7 +37,7 @@ class DocumentVersionOCRError(models.Model):
|
|||||||
result = models.TextField(blank=True, null=True, verbose_name=_('Result'))
|
result = models.TextField(blank=True, null=True, verbose_name=_('Result'))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.document_version)
|
return force_text(self.document_version)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('datetime_submitted',)
|
ordering = ('datetime_submitted',)
|
||||||
@@ -57,7 +57,7 @@ class DocumentPageContent(models.Model):
|
|||||||
content = models.TextField(blank=True, verbose_name=_('Content'))
|
content = models.TextField(blank=True, verbose_name=_('Content'))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.document_page)
|
return force_text(self.document_page)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Document page content')
|
verbose_name = _('Document page content')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.encoding import force_unicode
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import conditional_escape
|
from django.utils.html import conditional_escape
|
||||||
|
|
||||||
|
|
||||||
@@ -11,4 +11,4 @@ def get_document_ocr_content(document):
|
|||||||
except DocumentPageContent.DoesNotExist:
|
except DocumentPageContent.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
yield conditional_escape(force_unicode(page_content))
|
yield conditional_escape(force_text(page_content))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import logging
|
|||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from .exceptions import InvalidNamespace
|
from .exceptions import InvalidNamespace
|
||||||
@@ -11,6 +12,7 @@ from .exceptions import InvalidNamespace
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class PermissionNamespace(object):
|
class PermissionNamespace(object):
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
@@ -35,8 +37,8 @@ class PermissionNamespace(object):
|
|||||||
self.permissions = []
|
self.permissions = []
|
||||||
self.__class__._registry[name] = self
|
self.__class__._registry[name] = self
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
def add_permission(self, name, label):
|
def add_permission(self, name, label):
|
||||||
permission = Permission(namespace=self, name=name, label=label)
|
permission = Permission(namespace=self, name=name, label=label)
|
||||||
@@ -44,6 +46,7 @@ class PermissionNamespace(object):
|
|||||||
return permission
|
return permission
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Permission(object):
|
class Permission(object):
|
||||||
_permissions = {}
|
_permissions = {}
|
||||||
_stored_permissions_cache = {}
|
_stored_permissions_cache = {}
|
||||||
@@ -105,11 +108,8 @@ class Permission(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.pk
|
return self.pk
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return unicode(self.label)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.__unicode__())
|
return force_text(self.label)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stored_permission(self):
|
def stored_permission(self):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import logging
|
|||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from .classes import Permission
|
from .classes import Permission
|
||||||
@@ -34,7 +34,7 @@ class StoredPermission(models.Model):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(getattr(self, 'volatile_permission', self.name))
|
return force_text(getattr(self, 'volatile_permission', self.name))
|
||||||
|
|
||||||
def natural_key(self):
|
def natural_key(self):
|
||||||
return (self.namespace, self.name)
|
return (self.namespace, self.name)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import itertools
|
|||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from common.views import (
|
from common.views import (
|
||||||
@@ -61,12 +62,12 @@ class SetupRoleMembersView(AssignRemoveView):
|
|||||||
|
|
||||||
def left_list(self):
|
def left_list(self):
|
||||||
return [
|
return [
|
||||||
(unicode(group.pk), group.name) for group in set(Group.objects.all()) - set(self.get_object().groups.all())
|
(force_text(group.pk), group.name) for group in set(Group.objects.all()) - set(self.get_object().groups.all())
|
||||||
]
|
]
|
||||||
|
|
||||||
def right_list(self):
|
def right_list(self):
|
||||||
return [
|
return [
|
||||||
(unicode(group.pk), group.name) for group in self.get_object().groups.all()
|
(force_text(group.pk), group.name) for group in self.get_object().groups.all()
|
||||||
]
|
]
|
||||||
|
|
||||||
def remove(self, item):
|
def remove(self, item):
|
||||||
@@ -102,7 +103,7 @@ class SetupRolePermissionsView(AssignRemoveView):
|
|||||||
|
|
||||||
for namespace, permissions in itertools.groupby(StoredPermission.objects.exclude(id__in=self.get_object().permissions.values_list('pk', flat=True)), lambda entry: entry.namespace):
|
for namespace, permissions in itertools.groupby(StoredPermission.objects.exclude(id__in=self.get_object().permissions.values_list('pk', flat=True)), lambda entry: entry.namespace):
|
||||||
permission_options = [
|
permission_options = [
|
||||||
(unicode(permission.pk), permission) for permission in permissions
|
(force_text(permission.pk), permission) for permission in permissions
|
||||||
]
|
]
|
||||||
results.append(
|
results.append(
|
||||||
(PermissionNamespace.get(namespace), permission_options)
|
(PermissionNamespace.get(namespace), permission_options)
|
||||||
@@ -114,7 +115,7 @@ class SetupRolePermissionsView(AssignRemoveView):
|
|||||||
results = []
|
results = []
|
||||||
for namespace, permissions in itertools.groupby(self.get_object().permissions.all(), lambda entry: entry.namespace):
|
for namespace, permissions in itertools.groupby(self.get_object().permissions.all(), lambda entry: entry.namespace):
|
||||||
permission_options = [
|
permission_options = [
|
||||||
(unicode(permission.pk), permission) for permission in permissions
|
(force_text(permission.pk), permission) for permission in permissions
|
||||||
]
|
]
|
||||||
results.append(
|
results.append(
|
||||||
(PermissionNamespace.get(namespace), permission_options)
|
(PermissionNamespace.get(namespace), permission_options)
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class APIEndPoint(object):
|
class APIEndPoint(object):
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
@@ -16,8 +18,8 @@ class APIEndPoint(object):
|
|||||||
def get(cls, name):
|
def get(cls, name):
|
||||||
return cls._registry[name]
|
return cls._registry[name]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.app.name)
|
return force_text(self.app.name)
|
||||||
|
|
||||||
def __init__(self, app, version_string, name=None):
|
def __init__(self, app, version_string, name=None):
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import yaml
|
|||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.functional import Promise
|
from django.utils.functional import Promise
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Namespace(object):
|
class Namespace(object):
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
@@ -42,8 +43,8 @@ class Namespace(object):
|
|||||||
for namespace in cls.get_all():
|
for namespace in cls.get_all():
|
||||||
namespace.invalidate_cache()
|
namespace.invalidate_cache()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
def __init__(self, name, label):
|
def __init__(self, name, label):
|
||||||
if name in self.__class__._registry:
|
if name in self.__class__._registry:
|
||||||
@@ -63,6 +64,7 @@ class Namespace(object):
|
|||||||
setting.invalidate_cache()
|
setting.invalidate_cache()
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Setting(object):
|
class Setting(object):
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
@@ -89,8 +91,8 @@ class Setting(object):
|
|||||||
namespace.settings.append(self)
|
namespace.settings.append(self)
|
||||||
self.__class__._registry[global_name] = self
|
self.__class__._registry[global_name] = self
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.global_name)
|
return force_text(self.global_name)
|
||||||
|
|
||||||
def cache_value(self):
|
def cache_value(self):
|
||||||
environment_value = os.environ.get('MAYAN_{}'.format(self.global_name))
|
environment_value = os.environ.get('MAYAN_{}'.format(self.global_name))
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ except ImportError:
|
|||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
|
|
||||||
from converter import TransformationResize, converter_class
|
from converter import TransformationResize, converter_class
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ class Attachment(File):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class StagingFile(object):
|
class StagingFile(object):
|
||||||
"""
|
"""
|
||||||
Simple class to extend the File class to add preview capabilities
|
Simple class to extend the File class to add preview capabilities
|
||||||
@@ -57,8 +59,8 @@ class StagingFile(object):
|
|||||||
filename.encode('utf8')
|
filename.encode('utf8')
|
||||||
)
|
)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.filename)
|
return force_text(self.filename)
|
||||||
|
|
||||||
def as_file(self):
|
def as_file(self):
|
||||||
return File(
|
return File(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ class StagingUploadForm(UploadBaseForm):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.fields['staging_file_id'].choices = [
|
self.fields['staging_file_id'].choices = [
|
||||||
(staging_file.encoded_filename, unicode(staging_file)) for staging_file in self.source.get_files()
|
(staging_file.encoded_filename, force_text(staging_file)) for staging_file in self.source.get_files()
|
||||||
]
|
]
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
logger.error('exception: %s', exception)
|
logger.error('exception: %s', exception)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from django.core.exceptions import ValidationError
|
|||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ class Source(models.Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def class_fullname(cls):
|
def class_fullname(cls):
|
||||||
return unicode(dict(SOURCE_CHOICES).get(cls.source_type))
|
return force_text(dict(SOURCE_CHOICES).get(cls.source_type))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s' % self.label
|
return '%s' % self.label
|
||||||
@@ -133,7 +133,7 @@ class Source(models.Model):
|
|||||||
try:
|
try:
|
||||||
compressed_file = CompressedFile(file_object)
|
compressed_file = CompressedFile(file_object)
|
||||||
for compressed_file_child in compressed_file.children():
|
for compressed_file_child in compressed_file.children():
|
||||||
kwargs.update({'label': unicode(compressed_file_child)})
|
kwargs.update({'label': force_text(compressed_file_child)})
|
||||||
self.upload_document(
|
self.upload_document(
|
||||||
file_object=File(compressed_file_child), **kwargs
|
file_object=File(compressed_file_child), **kwargs
|
||||||
)
|
)
|
||||||
@@ -315,9 +315,9 @@ class StagingFolderSource(InteractiveSource):
|
|||||||
|
|
||||||
def get_preview_size(self):
|
def get_preview_size(self):
|
||||||
dimensions = []
|
dimensions = []
|
||||||
dimensions.append(unicode(self.preview_width))
|
dimensions.append(force_text(self.preview_width))
|
||||||
if self.preview_height:
|
if self.preview_height:
|
||||||
dimensions.append(unicode(self.preview_height))
|
dimensions.append(force_text(self.preview_height))
|
||||||
|
|
||||||
return DIMENSION_SEPARATOR.join(dimensions)
|
return DIMENSION_SEPARATOR.join(dimensions)
|
||||||
|
|
||||||
@@ -556,7 +556,7 @@ class EmailBaseModel(IntervalBaseModel):
|
|||||||
|
|
||||||
headers = decode_header(header_text)
|
headers = decode_header(header_text)
|
||||||
header_sections = [
|
header_sections = [
|
||||||
unicode(text, charset or default) for text, charset in headers
|
force_text(text, charset or default) for text, charset in headers
|
||||||
]
|
]
|
||||||
return ''.join(header_sections)
|
return ''.join(header_sections)
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ class WatchFolderSource(IntervalBaseModel):
|
|||||||
def check_source(self):
|
def check_source(self):
|
||||||
# Force self.folder_path to unicode to avoid os.listdir returning
|
# Force self.folder_path to unicode to avoid os.listdir returning
|
||||||
# str for non-latin filenames, gh-issue #163
|
# str for non-latin filenames, gh-issue #163
|
||||||
for file_name in os.listdir(unicode(self.folder_path)):
|
for file_name in os.listdir(force_text(self.folder_path)):
|
||||||
full_path = os.path.join(self.folder_path, file_name)
|
full_path = os.path.join(self.folder_path, file_name)
|
||||||
if os.path.isfile(full_path):
|
if os.path.isfile(full_path):
|
||||||
with File(file=open(full_path, mode='rb')) as file_object:
|
with File(file=open(full_path, mode='rb')) as file_object:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from django.apps import apps
|
|||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from django.db import OperationalError
|
from django.db import OperationalError
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from mayan.celery import app
|
from mayan.celery import app
|
||||||
@@ -128,8 +129,10 @@ def task_source_handle_upload(self, document_type_id, shared_uploaded_file_id, s
|
|||||||
for compressed_file_child in compressed_file.children():
|
for compressed_file_child in compressed_file.children():
|
||||||
# TODO: find way to uniquely identify child files
|
# TODO: find way to uniquely identify child files
|
||||||
# Use filename in the mean time.
|
# Use filename in the mean time.
|
||||||
if unicode(compressed_file_child) not in skip_list:
|
if force_text(compressed_file_child) not in skip_list:
|
||||||
kwargs.update({'label': unicode(compressed_file_child)})
|
kwargs.update(
|
||||||
|
{'label': force_text(compressed_file_child)}
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
child_shared_uploaded_file = SharedUploadedFile.objects.create(
|
child_shared_uploaded_file = SharedUploadedFile.objects.create(
|
||||||
@@ -153,7 +156,7 @@ def task_source_handle_upload(self, document_type_id, shared_uploaded_file_id, s
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
skip_list.append(unicode(compressed_file_child))
|
skip_list.append(force_text(compressed_file_child))
|
||||||
task_upload_document.delay(
|
task_upload_document.delay(
|
||||||
shared_uploaded_file_id=child_shared_uploaded_file.pk,
|
shared_uploaded_file_id=child_shared_uploaded_file.pk,
|
||||||
**kwargs
|
**kwargs
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@@ -118,7 +119,7 @@ class DocumentCreateWizard(ViewPermissionCheckMixin, SessionWizardView):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
query_dict['tags'] = ([unicode(tag.pk) for tag in self.get_cleaned_data_for_step(STEP_TAGS)['tags']])
|
query_dict['tags'] = ([force_text(tag.pk) for tag in self.get_cleaned_data_for_step(STEP_TAGS)['tags']])
|
||||||
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ from __future__ import unicode_literals
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||||
|
|
||||||
from celery.schedules import crontab
|
from celery.schedules import crontab
|
||||||
|
|
||||||
from mayan.celery import app
|
from mayan.celery import app
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class StatisticNamespace(object):
|
class StatisticNamespace(object):
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
@@ -26,8 +28,8 @@ class StatisticNamespace(object):
|
|||||||
self._statistics = []
|
self._statistics = []
|
||||||
self.__class__._registry[slug] = self
|
self.__class__._registry[slug] = self
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
def add_statistic(self, *args, **kwargs):
|
def add_statistic(self, *args, **kwargs):
|
||||||
statistic = Statistic(*args, **kwargs)
|
statistic = Statistic(*args, **kwargs)
|
||||||
@@ -39,6 +41,7 @@ class StatisticNamespace(object):
|
|||||||
return self._statistics
|
return self._statistics
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Statistic(object):
|
class Statistic(object):
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
@@ -108,8 +111,8 @@ class Statistic(object):
|
|||||||
|
|
||||||
self.__class__._registry[slug] = self
|
self.__class__._registry[slug] = self
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return unicode(self.label)
|
return force_text(self.label)
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
self.store_results(results=self.func())
|
self.store_results(results=self.func())
|
||||||
|
|||||||
Reference in New Issue
Block a user