From d59ea3ede21938599a8533f2f646ebf5b31adafc Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 19 Jan 2015 04:06:40 -0400 Subject: [PATCH] Add from __future__ import unicode_literals, issue #37 --- mayan/__init__.py | 2 + mayan/apps/acls/__init__.py | 2 +- mayan/apps/acls/admin.py | 9 +- mayan/apps/acls/api.py | 2 +- mayan/apps/acls/classes.py | 18 +- mayan/apps/acls/forms.py | 12 +- mayan/apps/acls/links.py | 26 +- mayan/apps/acls/literals.py | 1 + mayan/apps/acls/managers.py | 6 +- mayan/apps/acls/models.py | 33 ++- mayan/apps/acls/permissions.py | 14 +- .../acls/south_migrations/0001_initial.py | 42 +-- ...uto__del_field_creatorsingleton_lock_id.py | 28 +- mayan/apps/acls/templatetags/acl_tags.py | 26 +- mayan/apps/acls/urls.py | 2 + mayan/apps/acls/utils.py | 2 +- mayan/apps/acls/views.py | 116 ++++---- mayan/apps/acls/widgets.py | 4 +- mayan/apps/checkouts/__init__.py | 2 +- mayan/apps/checkouts/api_views.py | 5 +- mayan/apps/checkouts/events.py | 2 +- mayan/apps/checkouts/exceptions.py | 2 + mayan/apps/checkouts/forms.py | 2 +- mayan/apps/checkouts/links.py | 9 +- mayan/apps/checkouts/literals.py | 6 +- mayan/apps/checkouts/managers.py | 4 +- mayan/apps/checkouts/models.py | 14 +- mayan/apps/checkouts/permissions.py | 12 +- mayan/apps/checkouts/serializers.py | 2 +- mayan/apps/checkouts/tasks.py | 4 +- mayan/apps/checkouts/urls.py | 2 + mayan/apps/checkouts/views.py | 45 ++- mayan/apps/checkouts/widgets.py | 18 +- mayan/apps/common/__init__.py | 7 +- mayan/apps/common/admin.py | 2 +- mayan/apps/common/classes.py | 4 +- mayan/apps/common/compressed_files.py | 2 + mayan/apps/common/forms.py | 18 +- mayan/apps/common/links.py | 18 +- mayan/apps/common/managers.py | 2 + .../middleware/login_required_middleware.py | 2 +- .../middleware/strip_spaces_widdleware.py | 2 + mayan/apps/common/middleware/timezone.py | 2 + mayan/apps/common/models.py | 24 +- mayan/apps/common/runtime.py | 2 - mayan/apps/common/settings.py | 74 ++--- .../common/templatetags/autoadmin_tags.py | 4 +- .../common/templatetags/multiselect_tags.py | 2 - .../apps/common/templatetags/non_breakable.py | 4 +- .../apps/common/templatetags/project_tags.py | 2 +- mayan/apps/common/templatetags/set_var.py | 4 +- mayan/apps/common/templatetags/settings.py | 5 +- .../common/templatetags/subtemplates_tags.py | 2 + .../apps/common/templatetags/variable_tags.py | 2 +- .../apps/common/templatetags/version_tags.py | 4 +- mayan/apps/common/urls.py | 2 + mayan/apps/common/utils.py | 42 +-- mayan/apps/common/views.py | 46 +-- mayan/apps/common/widgets.py | 38 +-- mayan/apps/converter/api.py | 6 +- mayan/apps/converter/backends/__init__.py | 13 +- .../apps/converter/backends/graphicsmagick.py | 32 +-- mayan/apps/converter/backends/imagemagick.py | 26 +- mayan/apps/converter/backends/python.py | 2 +- mayan/apps/converter/exceptions.py | 3 + mayan/apps/converter/literals.py | 44 +-- mayan/apps/converter/office_converter.py | 102 +++---- mayan/apps/converter/settings.py | 20 +- mayan/apps/django_gpg/__init__.py | 2 +- mayan/apps/django_gpg/api.py | 14 +- mayan/apps/django_gpg/forms.py | 6 +- mayan/apps/django_gpg/links.py | 20 +- mayan/apps/django_gpg/permissions.py | 12 +- mayan/apps/django_gpg/settings.py | 17 +- mayan/apps/django_gpg/views.py | 56 ++-- mayan/apps/document_acls/__init__.py | 2 +- mayan/apps/document_acls/links.py | 4 +- mayan/apps/document_acls/urls.py | 2 + mayan/apps/document_acls/views.py | 2 + mayan/apps/document_comments/__init__.py | 14 +- mayan/apps/document_comments/forms.py | 2 + mayan/apps/document_comments/links.py | 2 +- mayan/apps/document_comments/permissions.py | 10 +- mayan/apps/document_comments/urls.py | 2 + mayan/apps/document_comments/views.py | 24 +- mayan/apps/document_indexing/__init__.py | 4 +- mayan/apps/document_indexing/admin.py | 2 +- mayan/apps/document_indexing/api.py | 4 +- mayan/apps/document_indexing/api_views.py | 2 +- mayan/apps/document_indexing/forms.py | 2 +- mayan/apps/document_indexing/links.py | 42 +-- mayan/apps/document_indexing/managers.py | 2 - mayan/apps/document_indexing/models.py | 38 +-- mayan/apps/document_indexing/permissions.py | 16 +- mayan/apps/document_indexing/serializers.py | 2 +- mayan/apps/document_indexing/settings.py | 8 +- mayan/apps/document_indexing/tasks.py | 2 + mayan/apps/document_indexing/tests.py | 14 +- mayan/apps/document_indexing/tools.py | 2 - mayan/apps/document_indexing/urls.py | 2 + mayan/apps/document_indexing/views.py | 78 ++--- mayan/apps/document_indexing/widgets.py | 30 +- mayan/apps/document_signatures/__init__.py | 16 +- mayan/apps/document_signatures/forms.py | 4 +- mayan/apps/document_signatures/links.py | 10 +- mayan/apps/document_signatures/managers.py | 2 + mayan/apps/document_signatures/models.py | 13 +- mayan/apps/document_signatures/permissions.py | 12 +- mayan/apps/document_signatures/tests.py | 2 +- mayan/apps/document_signatures/urls.py | 2 + mayan/apps/document_signatures/views.py | 44 +-- mayan/apps/document_states/admin.py | 2 + mayan/apps/document_states/managers.py | 2 - mayan/apps/document_states/tests.py | 3 - mayan/apps/document_states/urls.py | 2 + mayan/apps/document_states/views.py | 9 +- mayan/apps/documents/__init__.py | 120 ++++---- mayan/apps/documents/admin.py | 2 +- mayan/apps/documents/api_views.py | 2 +- mayan/apps/documents/events.py | 2 +- mayan/apps/documents/exceptions.py | 3 + mayan/apps/documents/forms.py | 37 +-- mayan/apps/documents/links.py | 111 +++---- mayan/apps/documents/literals.py | 8 +- mayan/apps/documents/managers.py | 2 +- mayan/apps/documents/models.py | 94 +++--- mayan/apps/documents/permissions.py | 34 +-- mayan/apps/documents/runtime.py | 2 - mayan/apps/documents/serializers.py | 2 +- mayan/apps/documents/settings.py | 34 +-- mayan/apps/documents/signals.py | 2 + mayan/apps/documents/statistics.py | 20 +- mayan/apps/documents/tasks.py | 8 +- .../documents/templatetags/printing_tags.py | 8 +- mayan/apps/documents/tests.py | 4 +- mayan/apps/documents/urls.py | 2 +- mayan/apps/documents/views.py | 272 +++++++++--------- mayan/apps/documents/widgets.py | 46 +-- mayan/apps/dynamic_search/__init__.py | 2 +- mayan/apps/dynamic_search/admin.py | 2 +- mayan/apps/dynamic_search/api.py | 10 +- mayan/apps/dynamic_search/api_views.py | 2 +- mayan/apps/dynamic_search/classes.py | 4 +- mayan/apps/dynamic_search/forms.py | 4 +- mayan/apps/dynamic_search/links.py | 8 +- mayan/apps/dynamic_search/managers.py | 2 - mayan/apps/dynamic_search/models.py | 20 +- mayan/apps/dynamic_search/serializers.py | 2 +- mayan/apps/dynamic_search/settings.py | 12 +- .../templatetags/search_tags.py | 10 +- mayan/apps/dynamic_search/tests.py | 2 +- mayan/apps/dynamic_search/urls.py | 2 + mayan/apps/dynamic_search/views.py | 14 +- mayan/apps/events/__init__.py | 2 +- mayan/apps/events/admin.py | 2 + mayan/apps/events/classes.py | 2 +- mayan/apps/events/models.py | 2 +- mayan/apps/events/urls.py | 2 + mayan/apps/folders/__init__.py | 43 +-- mayan/apps/folders/admin.py | 2 - mayan/apps/folders/api_views.py | 2 +- mayan/apps/folders/forms.py | 4 +- mayan/apps/folders/links.py | 19 +- mayan/apps/folders/models.py | 12 +- mayan/apps/folders/permissions.py | 16 +- mayan/apps/folders/serializers.py | 2 +- mayan/apps/folders/tests.py | 2 +- mayan/apps/folders/urls.py | 2 + mayan/apps/folders/views.py | 55 ++-- mayan/apps/history/models.py | 2 - mayan/apps/installation/__init__.py | 10 +- mayan/apps/installation/classes.py | 2 +- mayan/apps/installation/links.py | 8 +- mayan/apps/installation/literals.py | 2 + mayan/apps/installation/models.py | 92 +++--- mayan/apps/installation/permissions.py | 6 +- mayan/apps/installation/tasks.py | 3 + mayan/apps/installation/urls.py | 2 + mayan/apps/installation/views.py | 6 +- mayan/apps/linking/__init__.py | 23 +- mayan/apps/linking/admin.py | 2 +- mayan/apps/linking/classes.py | 2 + mayan/apps/linking/forms.py | 2 +- mayan/apps/linking/links.py | 32 +-- mayan/apps/linking/literals.py | 40 +-- mayan/apps/linking/managers.py | 2 - mayan/apps/linking/models.py | 32 +-- mayan/apps/linking/permissions.py | 12 +- mayan/apps/linking/urls.py | 2 + mayan/apps/linking/views.py | 64 ++--- mayan/apps/lock_manager/__init__.py | 2 - mayan/apps/lock_manager/admin.py | 2 - mayan/apps/lock_manager/managers.py | 2 +- mayan/apps/lock_manager/models.py | 12 +- mayan/apps/lock_manager/settings.py | 2 + mayan/apps/lock_manager/tests.py | 2 +- mayan/apps/mailer/__init__.py | 11 +- mayan/apps/mailer/forms.py | 14 +- mayan/apps/mailer/links.py | 4 +- mayan/apps/mailer/permissions.py | 8 +- mayan/apps/mailer/settings.py | 8 +- mayan/apps/mailer/tasks.py | 2 - mayan/apps/mailer/urls.py | 2 + mayan/apps/mailer/views.py | 7 +- mayan/apps/main/__init__.py | 4 +- mayan/apps/main/api.py | 2 + mayan/apps/main/links.py | 6 +- .../main/management/commands/initialsetup.py | 2 + mayan/apps/main/templatetags/styling.py | 14 +- mayan/apps/main/templatetags/theme_tags.py | 2 +- mayan/apps/main/urls.py | 2 + mayan/apps/main/views.py | 8 +- mayan/apps/metadata/__init__.py | 28 +- mayan/apps/metadata/admin.py | 2 +- mayan/apps/metadata/api.py | 9 +- mayan/apps/metadata/api_views.py | 29 +- mayan/apps/metadata/classes.py | 4 +- mayan/apps/metadata/forms.py | 20 +- mayan/apps/metadata/links.py | 44 ++- mayan/apps/metadata/managers.py | 2 - mayan/apps/metadata/models.py | 38 +-- mayan/apps/metadata/permissions.py | 22 +- mayan/apps/metadata/serializers.py | 2 +- mayan/apps/metadata/settings.py | 12 +- mayan/apps/metadata/urls.py | 2 + mayan/apps/metadata/views.py | 107 ++++--- mayan/apps/mimetype/api.py | 2 + mayan/apps/navigation/api.py | 2 + mayan/apps/navigation/classes.py | 6 +- mayan/apps/navigation/forms.py | 4 +- mayan/apps/navigation/links.py | 1 + .../templatetags/navigation_tags.py | 2 +- mayan/apps/navigation/widgets.py | 10 +- mayan/apps/permissions/__init__.py | 2 +- mayan/apps/permissions/admin.py | 2 +- mayan/apps/permissions/api_views.py | 2 + mayan/apps/permissions/forms.py | 2 +- mayan/apps/permissions/links.py | 27 +- mayan/apps/permissions/managers.py | 2 + .../permission_denied_middleware.py | 8 +- mayan/apps/permissions/models.py | 34 +-- mayan/apps/permissions/permissions.py | 16 +- mayan/apps/permissions/serializers.py | 2 + mayan/apps/permissions/settings.py | 9 +- .../templatetags/permission_tags.py | 16 +- mayan/apps/permissions/urls.py | 2 +- mayan/apps/permissions/views.py | 71 ++--- mayan/apps/permissions/widgets.py | 8 +- mayan/apps/project_setup/__init__.py | 2 +- mayan/apps/project_setup/api.py | 2 - mayan/apps/project_setup/links.py | 4 +- mayan/apps/project_setup/urls.py | 2 + mayan/apps/project_setup/views.py | 4 +- mayan/apps/project_tools/__init__.py | 2 +- mayan/apps/project_tools/api.py | 2 - mayan/apps/project_tools/links.py | 4 +- mayan/apps/project_tools/urls.py | 2 + mayan/apps/project_tools/views.py | 4 +- mayan/apps/registration/__init__.py | 2 - mayan/apps/registration/forms.py | 16 +- mayan/apps/registration/links.py | 2 +- mayan/apps/registration/literals.py | 2 + mayan/apps/registration/models.py | 8 +- mayan/apps/registration/tasks.py | 3 + mayan/apps/registration/urls.py | 2 + mayan/apps/registration/views.py | 8 +- mayan/apps/rest_api/__init__.py | 2 +- mayan/apps/rest_api/classes.py | 2 +- mayan/apps/rest_api/filters.py | 2 +- mayan/apps/rest_api/links.py | 6 +- mayan/apps/rest_api/permissions.py | 2 + mayan/apps/rest_api/serializers.py | 2 - mayan/apps/rest_api/urls.py | 2 +- mayan/apps/rest_api/views.py | 3 +- mayan/apps/smart_settings/__init__.py | 2 - mayan/apps/smart_settings/api.py | 6 +- mayan/apps/smart_settings/links.py | 4 +- mayan/apps/smart_settings/urls.py | 2 + mayan/apps/smart_settings/views.py | 8 +- mayan/apps/sources/__init__.py | 25 +- mayan/apps/sources/admin.py | 2 - mayan/apps/sources/api_views.py | 2 +- mayan/apps/sources/classes.py | 4 +- mayan/apps/sources/forms.py | 12 +- mayan/apps/sources/links.py | 56 ++-- mayan/apps/sources/literals.py | 22 +- mayan/apps/sources/managers.py | 2 + mayan/apps/sources/models.py | 78 ++--- mayan/apps/sources/permissions.py | 12 +- mayan/apps/sources/serializers.py | 2 +- mayan/apps/sources/tasks.py | 6 +- mayan/apps/sources/tests.py | 2 + mayan/apps/sources/urls.py | 8 +- mayan/apps/sources/utils.py | 20 +- mayan/apps/sources/views.py | 111 +++---- mayan/apps/sources/widgets.py | 30 +- mayan/apps/sources/wizards.py | 10 +- mayan/apps/statistics/__init__.py | 2 +- mayan/apps/statistics/links.py | 10 +- mayan/apps/statistics/urls.py | 2 + mayan/apps/statistics/views.py | 12 +- .../storage/backends/compressedstorage.py | 2 +- .../apps/storage/backends/filebasedstorage.py | 2 +- mayan/apps/storage/settings.py | 9 +- mayan/apps/tags/__init__.py | 33 ++- mayan/apps/tags/admin.py | 2 - mayan/apps/tags/api_views.py | 2 +- mayan/apps/tags/forms.py | 4 +- mayan/apps/tags/links.py | 33 +-- mayan/apps/tags/literals.py | 62 ++-- mayan/apps/tags/models.py | 10 +- mayan/apps/tags/permissions.py | 16 +- mayan/apps/tags/serializers.py | 2 +- mayan/apps/tags/tests.py | 2 + mayan/apps/tags/urls.py | 8 +- mayan/apps/tags/views.py | 61 ++-- mayan/apps/tags/widgets.py | 18 +- mayan/apps/user_management/__init__.py | 17 +- mayan/apps/user_management/api_views.py | 11 +- mayan/apps/user_management/forms.py | 6 +- mayan/apps/user_management/links.py | 43 +-- mayan/apps/user_management/permissions.py | 20 +- mayan/apps/user_management/serializers.py | 2 +- mayan/apps/user_management/urls.py | 8 +- mayan/apps/user_management/views.py | 87 +++--- mayan/celery.py | 2 +- mayan/settings/__init__.py | 2 - mayan/settings/base.py | 3 +- mayan/settings/development.py | 2 +- mayan/settings/development_ddt.py | 2 +- mayan/settings/production.py | 2 +- mayan/settings/travis/db_mysql.py | 2 +- mayan/settings/travis/db_postgres.py | 2 +- mayan/urls.py | 2 + 334 files changed, 2452 insertions(+), 2268 deletions(-) delete mode 100644 mayan/apps/document_states/tests.py diff --git a/mayan/__init__.py b/mayan/__init__.py index 1a720f95b6..af1250467d 100644 --- a/mayan/__init__.py +++ b/mayan/__init__.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + __title__ = 'Mayan EDMS' __version__ = '1.1.0' __build__ = 0x010100 diff --git a/mayan/apps/acls/__init__.py b/mayan/apps/acls/__init__.py index f6a3048caa..f1e03f56f9 100644 --- a/mayan/apps/acls/__init__.py +++ b/mayan/apps/acls/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.dispatch import receiver diff --git a/mayan/apps/acls/admin.py b/mayan/apps/acls/admin.py index 0416c9f3d9..998c3e4c05 100644 --- a/mayan/apps/acls/admin.py +++ b/mayan/apps/acls/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin @@ -6,12 +6,11 @@ from .models import AccessEntry class AccessEntryAdmin(admin.ModelAdmin): + model = AccessEntry + list_display = ('pk', 'holder_object', 'permission', 'content_object') + list_display_links = ('pk',) related_lookup_fields = { 'generic': [['holder_type', 'holder_id'], ['content_type', 'object_id']], } - # inlines = [PermissionHolderInline] - list_display = ('pk', 'holder_object', 'permission', 'content_object') - list_display_links = ('pk',) - model = AccessEntry admin.site.register(AccessEntry, AccessEntryAdmin) diff --git a/mayan/apps/acls/api.py b/mayan/apps/acls/api.py index bfcdcf1e7b..314eaad0c2 100644 --- a/mayan/apps/acls/api.py +++ b/mayan/apps/acls/api.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.contenttypes.models import ContentType diff --git a/mayan/apps/acls/classes.py b/mayan/apps/acls/classes.py index 4ef806f9ed..f46f44eaf4 100644 --- a/mayan/apps/acls/classes.py +++ b/mayan/apps/acls/classes.py @@ -23,7 +23,7 @@ def get_source_object(obj): class EncapsulatedObject(object): - source_object_name = u'source_object' + source_object_name = 'source_object' @classmethod def object_key(cls, app_label=None, model=None, pk=None): @@ -82,14 +82,14 @@ class EncapsulatedObject(object): try: content_type = ContentType.objects.get(app_label=app_label, model=model) except ContentType.DoesNotExist: - raise ObjectDoesNotExist("%s matching query does not exist." % ContentType._meta.object_name) + raise ObjectDoesNotExist('%s matching query does not exist.' % ContentType._meta.object_name) else: source_object_model_class = content_type.model_class() if pk: try: source_object = content_type.get_object_for_this_type(pk=pk) except source_object_model_class.DoesNotExist: - raise ObjectDoesNotExist("%s matching query does not exist." % source_object_model_class._meta.object_name) + raise ObjectDoesNotExist('%s matching query does not exist.' % source_object_model_class._meta.object_name) else: source_object = source_object_model_class @@ -112,13 +112,13 @@ class EncapsulatedObject(object): if isinstance(self.source_object, ModelBase): return unicode(self.source_object._meta.verbose_name_plural) elif self.ct_fullname == 'auth.user': - return u'%s %s' % (self.source_object._meta.verbose_name, self.source_object.get_full_name()) + return '%s %s' % (self.source_object._meta.verbose_name, self.source_object.get_full_name()) elif self.ct_fullname == 'common.anonymoususersingleton': return unicode(self.source_object) elif self.ct_fullname == 'acls.creatorsingleton': return unicode(self.source_object) else: - return u'%s %s' % (self.source_object._meta.verbose_name, self.source_object) + return '%s %s' % (self.source_object._meta.verbose_name, self.source_object) def __repr__(self): return self.__unicode__() @@ -129,19 +129,19 @@ class EncapsulatedObject(object): class AccessHolder(EncapsulatedObject): - source_object_name = u'holder_object' + source_object_name = 'holder_object' class AccessObject(EncapsulatedObject): - source_object_name = u'obj' + source_object_name = 'obj' class AccessObjectClass(EncapsulatedObject): - source_object_name = u'cls' + source_object_name = 'cls' class ClassAccessHolder(EncapsulatedObject): - source_object_name = u'class_holder' + source_object_name = 'class_holder' if sys.version_info < (2, 5): diff --git a/mayan/apps/acls/forms.py b/mayan/apps/acls/forms.py index e1f3b292d8..0f65fefbc7 100644 --- a/mayan/apps/acls/forms.py +++ b/mayan/apps/acls/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django import forms from django.contrib.auth.models import User, Group @@ -22,7 +22,7 @@ def _as_choice_list(holders): class BaseHolderSelectionForm(forms.Form): holder_gid = forms.ChoiceField( - label=_(u'New holder') + label=_('New holder') ) def __init__(self, *args, **kwargs): @@ -39,16 +39,16 @@ class BaseHolderSelectionForm(forms.Form): non_holder_list = [] if users: - non_holder_list.append((_(u'Users'), _as_choice_list(list(users)))) + non_holder_list.append((_('Users'), _as_choice_list(list(users)))) if groups: - non_holder_list.append((_(u'Groups'), _as_choice_list(list(groups)))) + non_holder_list.append((_('Groups'), _as_choice_list(list(groups)))) if roles: - non_holder_list.append((_(u'Roles'), _as_choice_list(list(roles)))) + non_holder_list.append((_('Roles'), _as_choice_list(list(roles)))) if special: - non_holder_list.append((_(u'Special'), _as_choice_list(list(special)))) + non_holder_list.append((_('Special'), _as_choice_list(list(special)))) super(BaseHolderSelectionForm, self).__init__(*args, **kwargs) self.fields['holder_gid'].choices = non_holder_list diff --git a/mayan/apps/acls/links.py b/mayan/apps/acls/links.py index e6a1f51d59..3991e33789 100644 --- a/mayan/apps/acls/links.py +++ b/mayan/apps/acls/links.py @@ -1,18 +1,20 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ from .permissions import (ACLS_CLASS_EDIT_ACL, ACLS_CLASS_VIEW_ACL, ACLS_EDIT_ACL, ACLS_VIEW_ACL) -acl_list = {'text': _(u'ACLs'), 'view': 'acls:acl_list', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} -acl_detail = {'text': _(u'Details'), 'view': 'acls:acl_detail', 'args': ['access_object.gid', 'object.gid'], 'famfam': 'key_go', 'permissions': [ACLS_VIEW_ACL]} -acl_grant = {'text': _(u'Grant'), 'view': 'acls:acl_multiple_grant', 'famfam': 'key_add', 'permissions': [ACLS_EDIT_ACL]} -acl_revoke = {'text': _(u'Revoke'), 'view': 'acls:acl_multiple_revoke', 'famfam': 'key_delete', 'permissions': [ACLS_EDIT_ACL]} -acl_holder_new = {'text': _(u'New holder'), 'view': 'acls:acl_holder_new', 'args': 'access_object.gid', 'famfam': 'user', 'permissions': [ACLS_EDIT_ACL]} +acl_list = {'text': _('ACLs'), 'view': 'acls:acl_list', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} +acl_detail = {'text': _('Details'), 'view': 'acls:acl_detail', 'args': ['access_object.gid', 'object.gid'], 'famfam': 'key_go', 'permissions': [ACLS_VIEW_ACL]} +acl_grant = {'text': _('Grant'), 'view': 'acls:acl_multiple_grant', 'famfam': 'key_add', 'permissions': [ACLS_EDIT_ACL]} +acl_revoke = {'text': _('Revoke'), 'view': 'acls:acl_multiple_revoke', 'famfam': 'key_delete', 'permissions': [ACLS_EDIT_ACL]} +acl_holder_new = {'text': _('New holder'), 'view': 'acls:acl_holder_new', 'args': 'access_object.gid', 'famfam': 'user', 'permissions': [ACLS_EDIT_ACL]} -acl_setup_valid_classes = {'text': _(u'Default ACLs'), 'view': 'acls:acl_setup_valid_classes', 'icon': 'lock.png', 'permissions': [ACLS_CLASS_VIEW_ACL]} -acl_class_list = {'text': _(u'Classes'), 'view': 'acls:acl_setup_valid_classes', 'famfam': 'package', 'permissions': [ACLS_CLASS_VIEW_ACL]} -acl_class_acl_list = {'text': _(u'ACLs for class'), 'view': 'acls:acl_class_acl_list', 'args': 'object.gid', 'famfam': 'lock_go', 'permissions': [ACLS_CLASS_VIEW_ACL]} -acl_class_acl_detail = {'text': _(u'Details'), 'view': 'acls:acl_class_acl_detail', 'args': ['access_object_class.gid', 'object.gid'], 'famfam': 'key_go', 'permissions': [ACLS_CLASS_VIEW_ACL]} -acl_class_new_holder_for = {'text': _(u'New holder'), 'view': 'acls:acl_class_new_holder_for', 'args': 'object.gid', 'famfam': 'user', 'permissions': [ACLS_CLASS_EDIT_ACL]} -acl_class_grant = {'text': _(u'Grant'), 'view': 'acls:acl_class_multiple_grant', 'famfam': 'key_add', 'permissions': [ACLS_CLASS_EDIT_ACL]} -acl_class_revoke = {'text': _(u'Revoke'), 'view': 'acls:acl_class_multiple_revoke', 'famfam': 'key_delete', 'permissions': [ACLS_CLASS_EDIT_ACL]} +acl_setup_valid_classes = {'text': _('Default ACLs'), 'view': 'acls:acl_setup_valid_classes', 'icon': 'lock.png', 'permissions': [ACLS_CLASS_VIEW_ACL]} +acl_class_list = {'text': _('Classes'), 'view': 'acls:acl_setup_valid_classes', 'famfam': 'package', 'permissions': [ACLS_CLASS_VIEW_ACL]} +acl_class_acl_list = {'text': _('ACLs for class'), 'view': 'acls:acl_class_acl_list', 'args': 'object.gid', 'famfam': 'lock_go', 'permissions': [ACLS_CLASS_VIEW_ACL]} +acl_class_acl_detail = {'text': _('Details'), 'view': 'acls:acl_class_acl_detail', 'args': ['access_object_class.gid', 'object.gid'], 'famfam': 'key_go', 'permissions': [ACLS_CLASS_VIEW_ACL]} +acl_class_new_holder_for = {'text': _('New holder'), 'view': 'acls:acl_class_new_holder_for', 'args': 'object.gid', 'famfam': 'user', 'permissions': [ACLS_CLASS_EDIT_ACL]} +acl_class_grant = {'text': _('Grant'), 'view': 'acls:acl_class_multiple_grant', 'famfam': 'key_add', 'permissions': [ACLS_CLASS_EDIT_ACL]} +acl_class_revoke = {'text': _('Revoke'), 'view': 'acls:acl_class_multiple_revoke', 'famfam': 'key_delete', 'permissions': [ACLS_CLASS_EDIT_ACL]} diff --git a/mayan/apps/acls/literals.py b/mayan/apps/acls/literals.py index d53e8a7db7..232128672a 100644 --- a/mayan/apps/acls/literals.py +++ b/mayan/apps/acls/literals.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals # Content type <-> fam fam icon mapping CONTENT_TYPE_ICON_MAP = { diff --git a/mayan/apps/acls/managers.py b/mayan/apps/acls/managers.py index a8f3b7728c..bb04f301b8 100644 --- a/mayan/apps/acls/managers.py +++ b/mayan/apps/acls/managers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging @@ -115,7 +115,7 @@ class AccessEntryManager(models.Manager): if self.has_access(permission, actor, obj): return True else: - raise PermissionDenied(ugettext(u'Insufficient access.')) + raise PermissionDenied(ugettext('Insufficient access.')) def check_accesses(self, permission_list, actor, obj): """ @@ -127,7 +127,7 @@ class AccessEntryManager(models.Manager): if self.has_access(permission, actor, obj): return True - raise PermissionDenied(ugettext(u'Insufficient access.')) + raise PermissionDenied(ugettext('Insufficient access.')) def get_allowed_class_objects(self, permission, actor, cls, related=None): logger.debug('related: %s', related) diff --git a/mayan/apps/acls/models.py b/mayan/apps/acls/models.py index 4a2e53ef58..34e63dbb34 100644 --- a/mayan/apps/acls/models.py +++ b/mayan/apps/acls/models.py @@ -1,20 +1,19 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging -from django.db import models -from django.utils.translation import ugettext_lazy as _ -from django.utils.translation import ugettext -from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic +from django.contrib.contenttypes.models import ContentType +from django.db import models +from django.utils.translation import ugettext_lazy as _, ugettext from solo.models import SingletonModel from permissions.models import StoredPermission -from .managers import AccessEntryManager, DefaultAccessEntryManager -from .classes import AccessObjectClass from .api import get_classes +from .classes import AccessObjectClass +from .managers import AccessEntryManager, DefaultAccessEntryManager logger = logging.getLogger(__name__) @@ -23,7 +22,7 @@ class AccessEntry(models.Model): """ Model that hold the permission, object, actor relationship """ - permission = models.ForeignKey(StoredPermission, verbose_name=_(u'Permission')) + permission = models.ForeignKey(StoredPermission, verbose_name=_('Permission')) holder_type = models.ForeignKey( ContentType, @@ -49,11 +48,11 @@ class AccessEntry(models.Model): objects = AccessEntryManager() class Meta: - verbose_name = _(u'Access entry') - verbose_name_plural = _(u'Access entries') + verbose_name = _('Access entry') + verbose_name_plural = _('Access entries') def __unicode__(self): - return u'%s: %s' % (self.content_type, self.content_object) + return '%s: %s' % (self.content_type, self.content_object) class DefaultAccessEntry(models.Model): @@ -65,7 +64,7 @@ class DefaultAccessEntry(models.Model): def get_classes(cls): return [AccessObjectClass.encapsulate(cls) for cls in get_classes()] - permission = models.ForeignKey(StoredPermission, verbose_name=_(u'Permission')) + permission = models.ForeignKey(StoredPermission, verbose_name=_('Permission')) holder_type = models.ForeignKey( ContentType, @@ -86,11 +85,11 @@ class DefaultAccessEntry(models.Model): objects = DefaultAccessEntryManager() class Meta: - verbose_name = _(u'Default access entry') - verbose_name_plural = _(u'Default access entries') + verbose_name = _('Default access entry') + verbose_name_plural = _('Default access entries') def __unicode__(self): - return u'%s: %s' % (self.content_type, self.content_object) + return '%s: %s' % (self.content_type, self.content_object) class CreatorSingletonManager(models.Manager): @@ -109,5 +108,5 @@ class CreatorSingleton(SingletonModel): return ugettext('Creator') class Meta: - verbose_name = _(u'Creator') - verbose_name_plural = _(u'Creator') + verbose_name = _('Creator') + verbose_name_plural = _('Creator') diff --git a/mayan/apps/acls/permissions.py b/mayan/apps/acls/permissions.py index 2ab114070a..f0dc2116e3 100644 --- a/mayan/apps/acls/permissions.py +++ b/mayan/apps/acls/permissions.py @@ -1,14 +1,14 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -acls_namespace = PermissionNamespace('acls', _(u'Access control lists')) -acls_setup_namespace = PermissionNamespace('acls_setup', _(u'Access control lists')) +acls_namespace = PermissionNamespace('acls', _('Access control lists')) +acls_setup_namespace = PermissionNamespace('acls_setup', _('Access control lists')) -ACLS_EDIT_ACL = Permission.objects.register(acls_namespace, 'acl_edit', _(u'Edit ACLs')) -ACLS_VIEW_ACL = Permission.objects.register(acls_namespace, 'acl_view', _(u'View ACLs')) +ACLS_EDIT_ACL = Permission.objects.register(acls_namespace, 'acl_edit', _('Edit ACLs')) +ACLS_VIEW_ACL = Permission.objects.register(acls_namespace, 'acl_view', _('View ACLs')) -ACLS_CLASS_EDIT_ACL = Permission.objects.register(acls_setup_namespace, 'acl_class_edit', _(u'Edit class default ACLs')) -ACLS_CLASS_VIEW_ACL = Permission.objects.register(acls_setup_namespace, 'acl_class_view', _(u'View class default ACLs')) +ACLS_CLASS_EDIT_ACL = Permission.objects.register(acls_setup_namespace, 'acl_class_edit', _('Edit class default ACLs')) +ACLS_CLASS_VIEW_ACL = Permission.objects.register(acls_setup_namespace, 'acl_class_view', _('View class default ACLs')) diff --git a/mayan/apps/acls/south_migrations/0001_initial.py b/mayan/apps/acls/south_migrations/0001_initial.py index 0b6a75d23d..1870903d8e 100644 --- a/mayan/apps/acls/south_migrations/0001_initial.py +++ b/mayan/apps/acls/south_migrations/0001_initial.py @@ -11,8 +11,8 @@ class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'AccessEntry' - db.create_table(u'acls_accessentry', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + db.create_table('acls_accessentry', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('permission', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['permissions.StoredPermission'])), ('holder_type', self.gf('django.db.models.fields.related.ForeignKey')(related_name='access_holder', to=orm['contenttypes.ContentType'])), ('holder_id', self.gf('django.db.models.fields.PositiveIntegerField')()), @@ -22,8 +22,8 @@ class Migration(SchemaMigration): db.send_create_signal(u'acls', ['AccessEntry']) # Adding model 'DefaultAccessEntry' - db.create_table(u'acls_defaultaccessentry', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + db.create_table('acls_defaultaccessentry', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('permission', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['permissions.StoredPermission'])), ('holder_type', self.gf('django.db.models.fields.related.ForeignKey')(related_name='default_access_entry_holder', to=orm['contenttypes.ContentType'])), ('holder_id', self.gf('django.db.models.fields.PositiveIntegerField')()), @@ -32,55 +32,55 @@ class Migration(SchemaMigration): db.send_create_signal(u'acls', ['DefaultAccessEntry']) # Adding model 'CreatorSingleton' - db.create_table(u'acls_creatorsingleton', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + db.create_table('acls_creatorsingleton', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('lock_id', self.gf('django.db.models.fields.CharField')(default='1', unique=True, max_length=1)), )) - db.send_create_signal(u'acls', ['CreatorSingleton']) + db.send_create_signal('acls', ['CreatorSingleton']) def backwards(self, orm): # Deleting model 'AccessEntry' - db.delete_table(u'acls_accessentry') + db.delete_table('acls_accessentry') # Deleting model 'DefaultAccessEntry' - db.delete_table(u'acls_defaultaccessentry') + db.delete_table('acls_defaultaccessentry') # Deleting model 'CreatorSingleton' - db.delete_table(u'acls_creatorsingleton') + db.delete_table('acls_creatorsingleton') models = { - u'acls.accessentry': { + 'acls.accessentry': { 'Meta': {'object_name': 'AccessEntry'}, 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'object_content_type'", 'to': u"orm['contenttypes.ContentType']"}), 'holder_id': ('django.db.models.fields.PositiveIntegerField', [], {}), 'holder_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'access_holder'", 'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), 'permission': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['permissions.StoredPermission']"}) }, - u'acls.creatorsingleton': { + 'acls.creatorsingleton': { 'Meta': {'object_name': 'CreatorSingleton'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'lock_id': ('django.db.models.fields.CharField', [], {'default': "'1'", 'unique': 'True', 'max_length': '1'}) }, - u'acls.defaultaccessentry': { + 'acls.defaultaccessentry': { 'Meta': {'object_name': 'DefaultAccessEntry'}, 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'default_access_entry_class'", 'to': u"orm['contenttypes.ContentType']"}), 'holder_id': ('django.db.models.fields.PositiveIntegerField', [], {}), 'holder_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'default_access_entry_holder'", 'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'permission': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['permissions.StoredPermission']"}) + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'permission': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['permissions.StoredPermission']"}) }, - u'contenttypes.contenttype': { + 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, - u'permissions.storedpermission': { + 'permissions.storedpermission': { 'Meta': {'ordering': "('namespace',)", 'unique_together': "(('namespace', 'name'),)", 'object_name': 'StoredPermission'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'namespace': ('django.db.models.fields.CharField', [], {'max_length': '64'}) } diff --git a/mayan/apps/acls/south_migrations/0002_auto__del_field_creatorsingleton_lock_id.py b/mayan/apps/acls/south_migrations/0002_auto__del_field_creatorsingleton_lock_id.py index 35d59bf359..ac7fd8260e 100644 --- a/mayan/apps/acls/south_migrations/0002_auto__del_field_creatorsingleton_lock_id.py +++ b/mayan/apps/acls/south_migrations/0002_auto__del_field_creatorsingleton_lock_id.py @@ -8,46 +8,46 @@ class Migration(SchemaMigration): def forwards(self, orm): # Deleting field 'CreatorSingleton.lock_id' - db.delete_column(u'acls_creatorsingleton', 'lock_id') + db.delete_column('acls_creatorsingleton', 'lock_id') def backwards(self, orm): # Adding field 'CreatorSingleton.lock_id' - db.add_column(u'acls_creatorsingleton', 'lock_id', + db.add_column('acls_creatorsingleton', 'lock_id', self.gf('django.db.models.fields.CharField')(default='1', max_length=1, unique=True), keep_default=False) models = { - u'acls.accessentry': { + 'acls.accessentry': { 'Meta': {'object_name': 'AccessEntry'}, 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'object_content_type'", 'to': u"orm['contenttypes.ContentType']"}), 'holder_id': ('django.db.models.fields.PositiveIntegerField', [], {}), 'holder_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'access_holder'", 'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), - 'permission': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['permissions.StoredPermission']"}) + 'permission': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['permissions.StoredPermission']"}) }, - u'acls.creatorsingleton': { + 'acls.creatorsingleton': { 'Meta': {'object_name': 'CreatorSingleton'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, - u'acls.defaultaccessentry': { + 'acls.defaultaccessentry': { 'Meta': {'object_name': 'DefaultAccessEntry'}, 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'default_access_entry_class'", 'to': u"orm['contenttypes.ContentType']"}), 'holder_id': ('django.db.models.fields.PositiveIntegerField', [], {}), 'holder_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'default_access_entry_holder'", 'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'permission': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['permissions.StoredPermission']"}) + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'permission': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['permissions.StoredPermission']"}) }, - u'contenttypes.contenttype': { + 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, - u'permissions.storedpermission': { + 'permissions.storedpermission': { 'Meta': {'ordering': "('namespace',)", 'unique_together': "(('namespace', 'name'),)", 'object_name': 'StoredPermission'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}), 'namespace': ('django.db.models.fields.CharField', [], {'max_length': '64'}) } diff --git a/mayan/apps/acls/templatetags/acl_tags.py b/mayan/apps/acls/templatetags/acl_tags.py index a635e361b6..8d3a07825d 100644 --- a/mayan/apps/acls/templatetags/acl_tags.py +++ b/mayan/apps/acls/templatetags/acl_tags.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import logging from django.core.exceptions import PermissionDenied @@ -18,7 +20,7 @@ class CheckAccessNode(Node): def render(self, context): permission_list = Variable(self.permission_list).resolve(context) - logger.debug('permission_list: %s', u','.join([unicode(p) for p in permission_list])) + logger.debug('permission_list: %s', ','.join([unicode(p) for p in permission_list])) try: # Check access_object, useful for document_page views @@ -29,15 +31,15 @@ class CheckAccessNode(Node): obj = Variable(self.obj).resolve(context) logger.debug('obj: %s', obj) except VariableDoesNotExist: - context[u'access'] = False + context['access'] = False logger.debug('no obj, access False') - return u'' + return '' if not permission_list: # There is no permissions list to check against which means # this link is available for all - context[u'access'] = True - return u'' + context['access'] = True + return '' requester = Variable(self.requester).resolve(context) logger.debug('requester: %s', requester) @@ -46,17 +48,17 @@ class CheckAccessNode(Node): try: AccessEntry.objects.check_accesses(permission_list, requester, obj) except PermissionDenied: - context[u'access'] = False + context['access'] = False logger.debug('access: False') - return u'' + return '' else: - context[u'access'] = True + context['access'] = True logger.debug('access: True') - return u'' + return '' else: - context[u'access'] = False + context['access'] = False logger.debug('No object, access: False') - return u'' + return '' @register.tag @@ -65,6 +67,6 @@ def check_access(parser, token): # Splitting by None == splitting by spaces. tag_name, args = token.contents.split(None, 1) except ValueError: - raise TemplateSyntaxError(u'%r tag requires arguments' % token.contents.split()[0]) + raise TemplateSyntaxError('%r tag requires arguments' % token.contents.split()[0]) return CheckAccessNode(*args.split()) diff --git a/mayan/apps/acls/urls.py b/mayan/apps/acls/urls.py index 572eb5fe80..5a96c21f4b 100644 --- a/mayan/apps/acls/urls.py +++ b/mayan/apps/acls/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('acls.views', diff --git a/mayan/apps/acls/utils.py b/mayan/apps/acls/utils.py index 25d40e04c7..2e66429e30 100644 --- a/mayan/apps/acls/utils.py +++ b/mayan/apps/acls/utils.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging diff --git a/mayan/apps/acls/views.py b/mayan/apps/acls/views.py index 2b6d0e52e9..08bfa0683e 100644 --- a/mayan/apps/acls/views.py +++ b/mayan/apps/acls/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging from json import loads @@ -30,7 +30,7 @@ logger = logging.getLogger(__name__) def _permission_titles(permission_list): - return u', '.join([unicode(permission) for permission in permission_list]) + return ', '.join([unicode(permission) for permission in permission_list]) def acl_list_for(request, obj, extra_context=None): @@ -43,10 +43,10 @@ def acl_list_for(request, obj, extra_context=None): context = { 'object_list': AccessEntry.objects.get_holders_for(obj), - 'title': _(u'Access control lists for: %s' % obj), + 'title': _('Access control lists for: %s' % obj), 'extra_columns': [ - {'name': _(u'Holder'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))}, - {'name': _(u'Permissions'), 'attribute': encapsulate(lambda x: _permission_titles(AccessEntry.objects.get_holder_permissions_for(obj, x.source_object, db_only=True)))}, + {'name': _('Holder'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))}, + {'name': _('Permissions'), 'attribute': encapsulate(lambda x: _permission_titles(AccessEntry.objects.get_holder_permissions_for(obj, x.source_object, db_only=True)))}, ], 'hide_object': True, 'access_object': AccessObject.encapsulate(obj), @@ -91,19 +91,19 @@ def acl_detail_for(request, actor, obj): # TODO : get all globally assigned permission, new function get_permissions_for_holder (roles aware) subtemplates_list = [ { - 'name': u'main/generic_list_subtemplate.html', + 'name': 'main/generic_list_subtemplate.html', 'context': { - 'title': _(u'Permissions available to: %(actor)s for %(obj)s' % { + 'title': _('Permissions available to: %(actor)s for %(obj)s' % { 'actor': actor, 'obj': obj } ), 'object_list': permission_list, 'extra_columns': [ - {'name': _(u'Namespace'), 'attribute': 'namespace'}, - {'name': _(u'Label'), 'attribute': 'label'}, + {'name': _('Namespace'), 'attribute': 'namespace'}, + {'name': _('Label'), 'attribute': 'label'}, { - 'name': _(u'Has permission'), + 'name': _('Has permission'), 'attribute': encapsulate(lambda permission: two_state_template(AccessEntry.objects.has_access(permission, actor, obj, db_only=True))) }, ], @@ -176,27 +176,27 @@ def acl_grant(request): for requester, obj_ps in items.items(): for obj, ps in obj_ps.items(): - title_suffix.append(_(u', ').join([u'"%s"' % unicode(p) for p in ps])) - title_suffix.append(_(u' for %s') % obj) - title_suffix.append(_(u' to %s') % requester) + title_suffix.append(_(', ').join(['"%s"' % unicode(p) for p in ps])) + title_suffix.append(_(' for %s') % obj) + title_suffix.append(_(' to %s') % requester) if len(items_property_list) == 1: - title_prefix = _(u'Are you sure you wish to grant the permission %(title_suffix)s?') + title_prefix = _('Are you sure you wish to grant the permission %(title_suffix)s?') else: - title_prefix = _(u'Are you sure you wish to grant the permissions %(title_suffix)s?') + title_prefix = _('Are you sure you wish to grant the permissions %(title_suffix)s?') if request.method == 'POST': for requester, object_permissions in items.items(): for obj, permissions in object_permissions.items(): for permission in permissions: if AccessEntry.objects.grant(permission, requester.source_object, obj.source_object): - messages.success(request, _(u'Permission "%(permission)s" granted to %(actor)s for %(object)s.') % { + messages.success(request, _('Permission "%(permission)s" granted to %(actor)s for %(object)s.') % { 'permission': permission, 'actor': requester, 'object': obj }) else: - messages.warning(request, _(u'%(actor)s, already had the permission "%(permission)s" granted for %(object)s.') % { + messages.warning(request, _('%(actor)s, already had the permission "%(permission)s" granted for %(object)s.') % { 'actor': requester, 'permission': permission, 'object': obj, @@ -211,7 +211,7 @@ def acl_grant(request): } context['title'] = title_prefix % { - 'title_suffix': u''.join(title_suffix), + 'title_suffix': ''.join(title_suffix), } logger.debug('navigation_object_count: %d', navigation_object_count) @@ -268,27 +268,27 @@ def acl_revoke(request): for requester, obj_ps in items.items(): for obj, ps in obj_ps.items(): - title_suffix.append(_(u', ').join([u'"%s"' % unicode(p) for p in ps])) - title_suffix.append(_(u' for %s') % obj) - title_suffix.append(_(u' from %s') % requester) + title_suffix.append(_(', ').join(['"%s"' % unicode(p) for p in ps])) + title_suffix.append(_(' for %s') % obj) + title_suffix.append(_(' from %s') % requester) if len(items_property_list) == 1: - title_prefix = _(u'Are you sure you wish to revoke the permission %(title_suffix)s?') + title_prefix = _('Are you sure you wish to revoke the permission %(title_suffix)s?') else: - title_prefix = _(u'Are you sure you wish to revoke the permissions %(title_suffix)s?') + title_prefix = _('Are you sure you wish to revoke the permissions %(title_suffix)s?') if request.method == 'POST': for requester, object_permissions in items.items(): for obj, permissions in object_permissions.items(): for permission in permissions: if AccessEntry.objects.revoke(permission, requester.source_object, obj.source_object): - messages.success(request, _(u'Permission "%(permission)s" revoked of %(actor)s for %(object)s.') % { + messages.success(request, _('Permission "%(permission)s" revoked of %(actor)s for %(object)s.') % { 'permission': permission, 'actor': requester, 'object': obj }) else: - messages.warning(request, _(u'%(actor)s, didn\'t had the permission "%(permission)s" for %(object)s.') % { + messages.warning(request, _('%(actor)s, didn\'t had the permission "%(permission)s" for %(object)s.') % { 'actor': requester, 'permission': permission, 'object': obj, @@ -303,7 +303,7 @@ def acl_revoke(request): } context['title'] = title_prefix % { - 'title_suffix': u''.join(title_suffix), + 'title_suffix': ''.join(title_suffix), } logger.debug('navigation_object_count: %d', navigation_object_count) @@ -328,10 +328,10 @@ def acl_new_holder_for(request, obj, extra_context=None, navigation_object=None) access_object = AccessObject.encapsulate(obj) access_holder = AccessHolder.get(form.cleaned_data['holder_gid']) - query_string = {u'navigation_object': navigation_object} + query_string = {'navigation_object': navigation_object} return HttpResponseRedirect( - u'%s?%s' % ( + '%s?%s' % ( reverse('acls:acl_detail', args=[access_object.gid, access_holder.gid]), urlencode(query_string) ) @@ -343,8 +343,8 @@ def acl_new_holder_for(request, obj, extra_context=None, navigation_object=None) context = { 'form': form, - 'title': _(u'Add new holder for: %s') % obj, - 'submit_label': _(u'Select'), + 'title': _('Add new holder for: %s') % obj, + 'submit_label': _('Select'), 'submit_icon_famfam': 'tick', 'object': obj, 'access_object': AccessObject.encapsulate(obj), @@ -376,9 +376,9 @@ def acl_setup_valid_classes(request): context = { 'object_list': DefaultAccessEntry.get_classes(), - 'title': _(u'Classes'), + 'title': _('Classes'), 'extra_columns': [ - {'name': _(u'Class'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))}, + {'name': _('Class'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))}, ], 'hide_object': True, } @@ -397,10 +397,10 @@ def acl_class_acl_list(request, access_object_class_gid): context = { 'object_list': DefaultAccessEntry.objects.get_holders_for(access_object_class.source_object), - 'title': _(u'Default access control lists for class: %s') % access_object_class, + 'title': _('Default access control lists for class: %s') % access_object_class, 'extra_columns': [ - {'name': _(u'Holder'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))}, - {'name': _(u'Permissions'), 'attribute': encapsulate(lambda x: _permission_titles(DefaultAccessEntry.objects.get_holder_permissions_for(access_object_class.source_object, x.source_object)))}, + {'name': _('Holder'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))}, + {'name': _('Permissions'), 'attribute': encapsulate(lambda x: _permission_titles(DefaultAccessEntry.objects.get_holder_permissions_for(access_object_class.source_object, x.source_object)))}, ], 'hide_object': True, 'access_object_class': access_object_class, @@ -423,18 +423,18 @@ def acl_class_acl_detail(request, access_object_class_gid, holder_object_gid): # TODO : get all globally assigned permission, new function get_permissions_for_holder (roles aware) subtemplates_list = [ { - 'name': u'main/generic_list_subtemplate.html', + 'name': 'main/generic_list_subtemplate.html', 'context': { - 'title': _(u'Permissions available to: %(actor)s for class %(class)s' % { + 'title': _('Permissions available to: %(actor)s for class %(class)s' % { 'actor': actor, 'class': access_object_class }), 'object_list': permission_list, 'extra_columns': [ - {'name': _(u'Namespace'), 'attribute': 'namespace'}, - {'name': _(u'Label'), 'attribute': 'label'}, + {'name': _('Namespace'), 'attribute': 'namespace'}, + {'name': _('Label'), 'attribute': 'label'}, { - 'name': _(u'Has permission'), + 'name': _('Has permission'), 'attribute': encapsulate(lambda x: two_state_template(DefaultAccessEntry.objects.has_access(x, actor.source_object, access_object_class.source_object))) }, ], @@ -472,9 +472,9 @@ def acl_class_new_holder_for(request, access_object_class_gid): context = { 'form': form, - 'title': _(u'Add new holder for class: %s') % unicode(access_object_class), + 'title': _('Add new holder for class: %s') % unicode(access_object_class), 'object': access_object_class, - 'submit_label': _(u'Select'), + 'submit_label': _('Select'), 'submit_icon_famfam': 'tick' } @@ -513,27 +513,27 @@ def acl_class_multiple_grant(request): for requester, obj_ps in items.items(): for obj, ps in obj_ps.items(): - title_suffix.append(_(u', ').join([u'"%s"' % unicode(p) for p in ps])) - title_suffix.append(_(u' for %s') % obj) - title_suffix.append(_(u' to %s') % requester) + title_suffix.append(_(', ').join(['"%s"' % unicode(p) for p in ps])) + title_suffix.append(_(' for %s') % obj) + title_suffix.append(_(' to %s') % requester) if len(items_property_list) == 1: - title_prefix = _(u'Are you sure you wish to grant the permission %(title_suffix)s?') + title_prefix = _('Are you sure you wish to grant the permission %(title_suffix)s?') else: - title_prefix = _(u'Are you sure you wish to grant the permissions %(title_suffix)s?') + title_prefix = _('Are you sure you wish to grant the permissions %(title_suffix)s?') if request.method == 'POST': for requester, object_permissions in items.items(): for obj, permissions in object_permissions.items(): for permission in permissions: if DefaultAccessEntry.objects.grant(permission, requester.source_object, obj.source_object): - messages.success(request, _(u'Permission "%(permission)s" granted to %(actor)s for %(object)s.') % { + messages.success(request, _('Permission "%(permission)s" granted to %(actor)s for %(object)s.') % { 'permission': permission, 'actor': requester, 'object': obj }) else: - messages.warning(request, _(u'%(actor)s, already had the permission "%(permission)s" granted for %(object)s.') % { + messages.warning(request, _('%(actor)s, already had the permission "%(permission)s" granted for %(object)s.') % { 'actor': requester, 'permission': permission, 'object': obj, @@ -548,7 +548,7 @@ def acl_class_multiple_grant(request): } context['title'] = title_prefix % { - 'title_suffix': u''.join(title_suffix), + 'title_suffix': ''.join(title_suffix), } logger.debug('navigation_object_count: %d', navigation_object_count) @@ -591,27 +591,27 @@ def acl_class_multiple_revoke(request): for requester, obj_ps in items.items(): for obj, ps in obj_ps.items(): - title_suffix.append(_(u', ').join([u'"%s"' % unicode(p) for p in ps])) - title_suffix.append(_(u' for %s') % obj) - title_suffix.append(_(u' from %s') % requester) + title_suffix.append(_(', ').join(['"%s"' % unicode(p) for p in ps])) + title_suffix.append(_(' for %s') % obj) + title_suffix.append(_(' from %s') % requester) if len(items_property_list) == 1: - title_prefix = _(u'Are you sure you wish to revoke the permission %(title_suffix)s?') + title_prefix = _('Are you sure you wish to revoke the permission %(title_suffix)s?') else: - title_prefix = _(u'Are you sure you wish to revoke the permissions %(title_suffix)s?') + title_prefix = _('Are you sure you wish to revoke the permissions %(title_suffix)s?') if request.method == 'POST': for requester, object_permissions in items.items(): for obj, permissions in object_permissions.items(): for permission in permissions: if DefaultAccessEntry.objects.revoke(permission, requester.source_object, obj.source_object): - messages.success(request, _(u'Permission "%(permission)s" revoked of %(actor)s for %(object)s.') % { + messages.success(request, _('Permission "%(permission)s" revoked of %(actor)s for %(object)s.') % { 'permission': permission, 'actor': requester, 'object': obj }) else: - messages.warning(request, _(u'%(actor)s, didn\'t had the permission "%(permission)s" for %(object)s.') % { + messages.warning(request, _('%(actor)s, didn\'t had the permission "%(permission)s" for %(object)s.') % { 'actor': requester, 'permission': permission, 'object': obj, @@ -626,7 +626,7 @@ def acl_class_multiple_revoke(request): } context['title'] = title_prefix % { - 'title_suffix': u''.join(title_suffix), + 'title_suffix': ''.join(title_suffix), } logger.debug('navigation_object_count: %d', navigation_object_count) diff --git a/mayan/apps/acls/widgets.py b/mayan/apps/acls/widgets.py index 8da765f16f..d6c866bca0 100644 --- a/mayan/apps/acls/widgets.py +++ b/mayan/apps/acls/widgets.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.safestring import mark_safe from django.contrib.contenttypes.models import ContentType @@ -8,7 +8,7 @@ from .literals import CONTENT_TYPE_ICON_MAP def content_type_icon(content_type): - return mark_safe(u'' % CONTENT_TYPE_ICON_MAP.get('%s.%s' % (content_type.app_label, content_type.model), 'help')) + return mark_safe('' % CONTENT_TYPE_ICON_MAP.get('%s.%s' % (content_type.app_label, content_type.model), 'help')) def object_w_content_type_icon(obj): diff --git a/mayan/apps/checkouts/__init__.py b/mayan/apps/checkouts/__init__.py index 3b2fcad171..4ec4c686bf 100644 --- a/mayan/apps/checkouts/__init__.py +++ b/mayan/apps/checkouts/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from datetime import timedelta diff --git a/mayan/apps/checkouts/api_views.py b/mayan/apps/checkouts/api_views.py index a5b694ca56..712a8575b7 100644 --- a/mayan/apps/checkouts/api_views.py +++ b/mayan/apps/checkouts/api_views.py @@ -1,9 +1,10 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals + +import pytz from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 -import pytz from rest_framework import generics, status from rest_framework.response import Response diff --git a/mayan/apps/checkouts/events.py b/mayan/apps/checkouts/events.py index e402f0faa2..459a015698 100644 --- a/mayan/apps/checkouts/events.py +++ b/mayan/apps/checkouts/events.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ diff --git a/mayan/apps/checkouts/exceptions.py b/mayan/apps/checkouts/exceptions.py index 46378eca0b..fb17b44ae6 100644 --- a/mayan/apps/checkouts/exceptions.py +++ b/mayan/apps/checkouts/exceptions.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext diff --git a/mayan/apps/checkouts/forms.py b/mayan/apps/checkouts/forms.py index ee3112e954..b0ce0f2b0c 100644 --- a/mayan/apps/checkouts/forms.py +++ b/mayan/apps/checkouts/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms diff --git a/mayan/apps/checkouts/links.py b/mayan/apps/checkouts/links.py index a66a309f13..5c1074f6c8 100644 --- a/mayan/apps/checkouts/links.py +++ b/mayan/apps/checkouts/links.py @@ -1,8 +1,11 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ -from .permissions import (PERMISSION_DOCUMENT_CHECKOUT, PERMISSION_DOCUMENT_CHECKIN, PERMISSION_DOCUMENT_CHECKIN_OVERRIDE) +from .permissions import ( + PERMISSION_DOCUMENT_CHECKOUT, PERMISSION_DOCUMENT_CHECKIN, + PERMISSION_DOCUMENT_CHECKIN_OVERRIDE +) def is_checked_out(context): @@ -13,7 +16,7 @@ def is_not_checked_out(context): return not context['object'].is_checked_out() -checkout_list = {'text': _(u'Checkouts'), 'view': 'checkouts:checkout_list', 'famfam': 'basket'} +checkout_list = {'text': _('Checkouts'), 'view': 'checkouts:checkout_list', 'famfam': 'basket'} checkout_document = {'text': _('Check out document'), 'view': 'checkouts:checkout_document', 'args': 'object.pk', 'famfam': 'basket_put', 'condition': is_not_checked_out, 'permissions': [PERMISSION_DOCUMENT_CHECKOUT]} checkin_document = {'text': _('Check in document'), 'view': 'checkouts:checkin_document', 'args': 'object.pk', 'famfam': 'basket_remove', 'condition': is_checked_out, 'permissions': [PERMISSION_DOCUMENT_CHECKIN, PERMISSION_DOCUMENT_CHECKIN_OVERRIDE]} checkout_info = {'text': _('Check in/out'), 'view': 'checkouts:checkout_info', 'args': 'object.pk', 'famfam': 'basket', 'permissions': [PERMISSION_DOCUMENT_CHECKIN, PERMISSION_DOCUMENT_CHECKIN_OVERRIDE, PERMISSION_DOCUMENT_CHECKOUT]} diff --git a/mayan/apps/checkouts/literals.py b/mayan/apps/checkouts/literals.py index 42e05f293f..400423a376 100644 --- a/mayan/apps/checkouts/literals.py +++ b/mayan/apps/checkouts/literals.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -6,6 +6,6 @@ STATE_CHECKED_OUT = 'checkedout' STATE_CHECKED_IN = 'checkedin' STATE_LABELS = { - STATE_CHECKED_OUT: _(u'Checked out'), - STATE_CHECKED_IN: _(u'Checked in/available'), + STATE_CHECKED_OUT: _('Checked out'), + STATE_CHECKED_IN: _('Checked in/available'), } diff --git a/mayan/apps/checkouts/managers.py b/mayan/apps/checkouts/managers.py index 31ccf449de..afecb27fbc 100644 --- a/mayan/apps/checkouts/managers.py +++ b/mayan/apps/checkouts/managers.py @@ -1,9 +1,9 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging -from django.db import models from django.core.exceptions import PermissionDenied +from django.db import models from django.utils.timezone import now from acls.models import AccessEntry diff --git a/mayan/apps/checkouts/models.py b/mayan/apps/checkouts/models.py index b85311c991..ec08d2a7cb 100644 --- a/mayan/apps/checkouts/models.py +++ b/mayan/apps/checkouts/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -20,16 +20,16 @@ class DocumentCheckout(models.Model): """ Model to store the state and information of a document checkout """ - document = models.ForeignKey(Document, verbose_name=_(u'Document'), unique=True) - checkout_datetime = models.DateTimeField(verbose_name=_(u'Check out date and time'), auto_now_add=True) - expiration_datetime = models.DateTimeField(verbose_name=_(u'Check out expiration date and time'), help_text=_(u'Amount of time to hold the document checked out in minutes.')) + document = models.ForeignKey(Document, verbose_name=_('Document'), unique=True) + checkout_datetime = models.DateTimeField(verbose_name=_('Check out date and time'), auto_now_add=True) + expiration_datetime = models.DateTimeField(verbose_name=_('Check out expiration date and time'), help_text=_('Amount of time to hold the document checked out in minutes.')) # TODO: simplify user_object to an instance of User user_content_type = models.ForeignKey(ContentType, null=True, blank=True) # blank and null added for ease of db migration user_object_id = models.PositiveIntegerField(null=True, blank=True) user_object = generic.GenericForeignKey(ct_field='user_content_type', fk_field='user_object_id') - block_new_version = models.BooleanField(default=True, verbose_name=_(u'Block new version upload'), help_text=_(u'Do not allow new version of this document to be uploaded.')) + block_new_version = models.BooleanField(default=True, verbose_name=_('Block new version upload'), help_text=_('Do not allow new version of this document to be uploaded.')) # block_metadata # block_editing @@ -55,5 +55,5 @@ class DocumentCheckout(models.Model): return ('checkout:checkout_info', [self.document.pk]) class Meta: - verbose_name = _(u'Document checkout') - verbose_name_plural = _(u'Document checkouts') + verbose_name = _('Document checkout') + verbose_name_plural = _('Document checkouts') diff --git a/mayan/apps/checkouts/permissions.py b/mayan/apps/checkouts/permissions.py index 415c197c29..5a8d631a35 100644 --- a/mayan/apps/checkouts/permissions.py +++ b/mayan/apps/checkouts/permissions.py @@ -1,12 +1,12 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -namespace = PermissionNamespace('checkouts', _(u'Document checkout')) +namespace = PermissionNamespace('checkouts', _('Document checkout')) -PERMISSION_DOCUMENT_CHECKOUT = Permission.objects.register(namespace, 'checkout_document', _(u'Check out documents')) -PERMISSION_DOCUMENT_CHECKIN = Permission.objects.register(namespace, 'checkin_document', _(u'Check in documents')) -PERMISSION_DOCUMENT_CHECKIN_OVERRIDE = Permission.objects.register(namespace, 'checkin_document_override', _(u'Forcefully check in documents')) -PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE = Permission.objects.register(namespace, 'checkout_restrictions_override', _(u'Allow overriding check out restrictions')) +PERMISSION_DOCUMENT_CHECKOUT = Permission.objects.register(namespace, 'checkout_document', _('Check out documents')) +PERMISSION_DOCUMENT_CHECKIN = Permission.objects.register(namespace, 'checkin_document', _('Check in documents')) +PERMISSION_DOCUMENT_CHECKIN_OVERRIDE = Permission.objects.register(namespace, 'checkin_document_override', _('Forcefully check in documents')) +PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE = Permission.objects.register(namespace, 'checkout_restrictions_override', _('Allow overriding check out restrictions')) diff --git a/mayan/apps/checkouts/serializers.py b/mayan/apps/checkouts/serializers.py index c232debdd6..2c28430bf6 100644 --- a/mayan/apps/checkouts/serializers.py +++ b/mayan/apps/checkouts/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from rest_framework import serializers diff --git a/mayan/apps/checkouts/tasks.py b/mayan/apps/checkouts/tasks.py index 7ed4e7be39..a6c561267a 100644 --- a/mayan/apps/checkouts/tasks.py +++ b/mayan/apps/checkouts/tasks.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) @app.task(ignore_result=True) def task_check_expired_check_outs(): logger.debug('executing...') - lock_id = u'task_expired_check_outs' + lock_id = 'task_expired_check_outs' try: logger.debug('trying to acquire lock: %s', lock_id) lock = Lock.acquire_lock(lock_id, LOCK_EXPIRE) diff --git a/mayan/apps/checkouts/urls.py b/mayan/apps/checkouts/urls.py index efa04c1341..0ac93964b7 100644 --- a/mayan/apps/checkouts/urls.py +++ b/mayan/apps/checkouts/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url from .api_views import APICheckedoutDocumentListView, APICheckedoutDocumentView diff --git a/mayan/apps/checkouts/views.py b/mayan/apps/checkouts/views.py index a7879e32d2..da2f754613 100644 --- a/mayan/apps/checkouts/views.py +++ b/mayan/apps/checkouts/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.contrib import messages from django.core.exceptions import PermissionDenied @@ -12,8 +12,7 @@ from documents.models import Document from documents.views import document_list from acls.models import AccessEntry -from common.utils import get_object_name -from common.utils import encapsulate +from common.utils import encapsulate, get_object_name from permissions.models import Permission from .exceptions import DocumentAlreadyCheckedOut, DocumentNotCheckedOut @@ -29,12 +28,12 @@ def checkout_list(request): return document_list( request, object_list=DocumentCheckout.objects.checked_out_documents(), - title=_(u'Documents checked out'), + title=_('Documents checked out'), extra_context={ 'extra_columns': [ - {'name': _(u'Checkout user'), 'attribute': encapsulate(lambda document: get_object_name(document.checkout_info().user_object, display_object_type=False))}, - {'name': _(u'Checkout time and date'), 'attribute': encapsulate(lambda document: document.checkout_info().checkout_datetime)}, - {'name': _(u'Checkout expiration'), 'attribute': encapsulate(lambda document: document.checkout_info().expiration_datetime)}, + {'name': _('Checkout user'), 'attribute': encapsulate(lambda document: get_object_name(document.checkout_info().user_object, display_object_type=False))}, + {'name': _('Checkout time and date'), 'attribute': encapsulate(lambda document: document.checkout_info().checkout_datetime)}, + {'name': _('Checkout expiration'), 'attribute': encapsulate(lambda document: document.checkout_info().expiration_datetime)}, ], } ) @@ -47,19 +46,19 @@ def checkout_info(request, document_pk): except PermissionDenied: AccessEntry.objects.check_accesses([PERMISSION_DOCUMENT_CHECKOUT, PERMISSION_DOCUMENT_CHECKIN], request.user, document) - paragraphs = [_(u'Document status: %s') % STATE_LABELS[document.checkout_state()]] + paragraphs = [_('Document status: %s') % STATE_LABELS[document.checkout_state()]] if document.is_checked_out(): checkout_info = document.checkout_info() - paragraphs.append(_(u'User: %s') % get_object_name(checkout_info.user_object, display_object_type=False)) - paragraphs.append(_(u'Check out time: %s') % checkout_info.checkout_datetime) - paragraphs.append(_(u'Check out expiration: %s') % checkout_info.expiration_datetime) - paragraphs.append(_(u'New versions allowed: %s') % (_(u'Yes') if not checkout_info.block_new_version else _(u'No'))) + paragraphs.append(_('User: %s') % get_object_name(checkout_info.user_object, display_object_type=False)) + paragraphs.append(_('Check out time: %s') % checkout_info.checkout_datetime) + paragraphs.append(_('Check out expiration: %s') % checkout_info.expiration_datetime) + paragraphs.append(_('New versions allowed: %s') % (_('Yes') if not checkout_info.block_new_version else _('No'))) return render_to_response('main/generic_template.html', { 'paragraphs': paragraphs, 'object': document, - 'title': _(u'Document check out details') + 'title': _('Document check out details') }, context_instance=RequestContext(request)) @@ -79,12 +78,12 @@ def checkout_document(request, document_pk): document_checkout.document = document document_checkout.save() except DocumentAlreadyCheckedOut: - messages.error(request, _(u'Document already checked out.')) + messages.error(request, _('Document already checked out.')) return HttpResponseRedirect(reverse('checkouts:checkout_info', args=[document.pk])) except Exception as exception: - messages.error(request, _(u'Error trying to check out document; %s') % exception) + messages.error(request, _('Error trying to check out document; %s') % exception) else: - messages.success(request, _(u'Document "%s" checked out successfully.') % document) + messages.success(request, _('Document "%s" checked out successfully.') % document) return HttpResponseRedirect(reverse('checkouts:checkout_info', args=[document.pk])) else: form = DocumentCheckoutForm(initial={'document': document}) @@ -92,7 +91,7 @@ def checkout_document(request, document_pk): return render_to_response('main/generic_form.html', { 'form': form, 'object': document, - 'title': _(u'Document check out') + 'title': _('Document check out') }, context_instance=RequestContext(request)) @@ -104,7 +103,7 @@ def checkin_document(request, document_pk): next = request.POST.get('next', request.GET.get('next', post_action_redirect if post_action_redirect else request.META.get('HTTP_REFERER', reverse('main:home')))) if not document.is_checked_out(): - messages.error(request, _(u'Document has not been checked out.')) + messages.error(request, _('Document has not been checked out.')) return HttpResponseRedirect(previous) # If the user trying to check in the document is the same as the check out @@ -125,11 +124,11 @@ def checkin_document(request, document_pk): try: document.check_in(user=request.user) except DocumentNotCheckedOut: - messages.error(request, _(u'Document has not been checked out.')) + messages.error(request, _('Document has not been checked out.')) except Exception as exception: - messages.error(request, _(u'Error trying to check in document; %s') % exception) + messages.error(request, _('Error trying to check in document; %s') % exception) else: - messages.success(request, _(u'Document "%s" checked in successfully.') % document) + messages.success(request, _('Document "%s" checked in successfully.') % document) return HttpResponseRedirect(next) context = { @@ -140,9 +139,9 @@ def checkin_document(request, document_pk): } if document.checkout_info().user_object != request.user: - context['title'] = _(u'You didn\'t originally checked out this document. Are you sure you wish to forcefully check in document: %s?') % document + context['title'] = _('You didn\'t originally checked out this document. Are you sure you wish to forcefully check in document: %s?') % document else: - context['title'] = _(u'Are you sure you wish to check in document: %s?') % document + context['title'] = _('Are you sure you wish to check in document: %s?') % document return render_to_response('main/generic_confirm.html', context, context_instance=RequestContext(request)) diff --git a/mayan/apps/checkouts/widgets.py b/mayan/apps/checkouts/widgets.py index 1429956839..37d14db1ad 100644 --- a/mayan/apps/checkouts/widgets.py +++ b/mayan/apps/checkouts/widgets.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime @@ -14,9 +14,9 @@ class SplitDeltaWidget(forms.widgets.MultiWidget): """ def __init__(self, attrs=None): widgets = ( - forms.widgets.TextInput(attrs={'maxlength': 3, 'style': 'width: 5em;', 'placeholder': _(u'Days')}), - forms.widgets.TextInput(attrs={'maxlength': 4, 'style': 'width: 5em;', 'placeholder': _(u'Hours')}), - forms.widgets.TextInput(attrs={'maxlength': 5, 'style': 'width: 5em;', 'placeholder': _(u'Minutes')}), + forms.widgets.TextInput(attrs={'maxlength': 3, 'style': 'width: 5em;', 'placeholder': _('Days')}), + forms.widgets.TextInput(attrs={'maxlength': 4, 'style': 'width: 5em;', 'placeholder': _('Hours')}), + forms.widgets.TextInput(attrs={'maxlength': 5, 'style': 'width: 5em;', 'placeholder': _('Minutes')}), ) super(SplitDeltaWidget, self).__init__(widgets, attrs) @@ -46,10 +46,10 @@ class SplitTimeDeltaField(forms.MultiValueField): widget = SplitDeltaWidget hidden_widget = SplitHiddenDeltaWidget default_error_messages = { - 'invalid_days': _(u'Enter a valid number of days.'), - 'invalid_hours': _(u'Enter a valid number of hours.'), - 'invalid_minutes': _(u'Enter a valid number of minutes.'), - 'invalid_timedelta': _(u'Enter a valid time difference.'), + 'invalid_days': _('Enter a valid number of days.'), + 'invalid_hours': _('Enter a valid number of hours.'), + 'invalid_minutes': _('Enter a valid number of minutes.'), + 'invalid_timedelta': _('Enter a valid time difference.'), } def __init__(self, *args, **kwargs): @@ -75,7 +75,7 @@ class SplitTimeDeltaField(forms.MultiValueField): ), ) super(SplitTimeDeltaField, self).__init__(fields, *args, **kwargs) - self.help_text = _(u'Amount of time to hold the document in the checked out state in days, hours and/or minutes.') + self.help_text = _('Amount of time to hold the document in the checked out state in days, hours and/or minutes.') self.label = _('Check out expiration date and time') def compress(self, data_list): diff --git a/mayan/apps/common/__init__.py b/mayan/apps/common/__init__.py index b55dce061b..7cf48e19d1 100644 --- a/mayan/apps/common/__init__.py +++ b/mayan/apps/common/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging import tempfile @@ -6,16 +6,15 @@ import tempfile from django.conf import settings from django.contrib.auth import models as auth_models from django.contrib.auth.models import User +from django.contrib.auth.signals import user_logged_in from django.db.models.signals import post_save from django.dispatch import receiver -from django.contrib.auth.signals import user_logged_in - from south.signals import post_migrate +from common import settings as common_settings from navigation.api import register_links, register_top_menu -from common import settings as common_settings from .links import (link_about, link_current_user_details, link_current_user_edit, link_current_user_locale_profile_details, diff --git a/mayan/apps/common/admin.py b/mayan/apps/common/admin.py index bdb728c7db..a5ad7b9106 100644 --- a/mayan/apps/common/admin.py +++ b/mayan/apps/common/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin diff --git a/mayan/apps/common/classes.py b/mayan/apps/common/classes.py index b82245484e..0e16788412 100644 --- a/mayan/apps/common/classes.py +++ b/mayan/apps/common/classes.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.db import models from django.utils.translation import ugettext @@ -39,7 +41,7 @@ class ModelAttribute(object): def get_display(self, show_name=False): if self.description: - return u'{} - {}'.format(self.name if show_name else self.label, self.description) + return '{} - {}'.format(self.name if show_name else self.label, self.description) else: return unicode(self.name if show_name else self.label) diff --git a/mayan/apps/common/compressed_files.py b/mayan/apps/common/compressed_files.py index 0c06ed9d67..c1542c8194 100644 --- a/mayan/apps/common/compressed_files.py +++ b/mayan/apps/common/compressed_files.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import zipfile try: diff --git a/mayan/apps/common/forms.py b/mayan/apps/common/forms.py index 8659615490..84de49539e 100644 --- a/mayan/apps/common/forms.py +++ b/mayan/apps/common/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import warnings import os @@ -95,7 +95,7 @@ class ChoiceForm(forms.Form): """ def __init__(self, *args, **kwargs): choices = kwargs.pop('choices', []) - label = kwargs.pop('label', _(u'Selection')) + label = kwargs.pop('label', _('Selection')) super(ChoiceForm, self).__init__(*args, **kwargs) self.fields['selection'].choices = choices self.fields['selection'].label = label @@ -140,15 +140,15 @@ class EmailAuthenticationForm(forms.Form): """ A form to use email address authentication """ - email = forms.CharField(label=_(u'Email'), max_length=254, + email = forms.CharField(label=_('Email'), max_length=254, widget=EmailInput() ) - password = forms.CharField(label=_(u'Password'), widget=forms.PasswordInput) + password = forms.CharField(label=_('Password'), widget=forms.PasswordInput) error_messages = { - 'invalid_login': _(u'Please enter a correct email and password. ' - u'Note that the password field is case-sensitive.'), - 'inactive': _(u'This account is inactive.'), + 'invalid_login': _('Please enter a correct email and password. ' + 'Note that the password field is case-sensitive.'), + 'inactive': _('This account is inactive.'), } def __init__(self, request=None, *args, **kwargs): @@ -193,7 +193,7 @@ class EmailAuthenticationForm(forms.Form): class FileDisplayForm(forms.Form): text = forms.CharField( - label='', # _(u'Text'), + label='', # _('Text'), widget=forms.widgets.Textarea( attrs={'cols': 40, 'rows': 20, 'readonly': 'readonly'} ) @@ -208,5 +208,5 @@ class FileDisplayForm(forms.Form): class LicenseForm(FileDisplayForm): - FILENAME = u'LICENSE' + FILENAME = 'LICENSE' DIRECTORY = [] diff --git a/mayan/apps/common/links.py b/mayan/apps/common/links.py index d67ad18e80..8d18e23f14 100644 --- a/mayan/apps/common/links.py +++ b/mayan/apps/common/links.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -7,14 +7,14 @@ def has_usable_password(context): return context['request'].user.has_usable_password -link_password_change = {'text': _(u'Change password'), 'view': 'common:password_change_view', 'famfam': 'computer_key', 'condition': has_usable_password} -link_current_user_details = {'text': _(u'User details'), 'view': 'common:current_user_details', 'famfam': 'vcard'} -link_current_user_edit = {'text': _(u'Edit details'), 'view': 'common:current_user_edit', 'famfam': 'vcard_edit'} +link_password_change = {'text': _('Change password'), 'view': 'common:password_change_view', 'famfam': 'computer_key', 'condition': has_usable_password} +link_current_user_details = {'text': _('User details'), 'view': 'common:current_user_details', 'famfam': 'vcard'} +link_current_user_edit = {'text': _('Edit details'), 'view': 'common:current_user_edit', 'famfam': 'vcard_edit'} -link_about = {'text': _(u'About'), 'view': 'common:about_view', 'famfam': 'information'} -link_license = {'text': _(u'License'), 'view': 'common:license_view', 'famfam': 'script'} +link_about = {'text': _('About'), 'view': 'common:about_view', 'famfam': 'information'} +link_license = {'text': _('License'), 'view': 'common:license_view', 'famfam': 'script'} -link_current_user_locale_profile_details = {'text': _(u'Locale profile'), 'view': 'common:current_user_locale_profile_details', 'famfam': 'world'} -link_current_user_locale_profile_edit = {'text': _(u'Edit locale profile'), 'view': 'common:current_user_locale_profile_edit', 'famfam': 'world_edit'} +link_current_user_locale_profile_details = {'text': _('Locale profile'), 'view': 'common:current_user_locale_profile_details', 'famfam': 'world'} +link_current_user_locale_profile_edit = {'text': _('Edit locale profile'), 'view': 'common:current_user_locale_profile_edit', 'famfam': 'world_edit'} -link_logout = {'text': _(u'Logout'), 'view': 'common:logout_view', 'famfam': 'door_out'} +link_logout = {'text': _('Logout'), 'view': 'common:logout_view', 'famfam': 'door_out'} diff --git a/mayan/apps/common/managers.py b/mayan/apps/common/managers.py index 78ed156ea3..e3b637cd7e 100644 --- a/mayan/apps/common/managers.py +++ b/mayan/apps/common/managers.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.db import models from django.contrib.auth.models import AnonymousUser diff --git a/mayan/apps/common/middleware/login_required_middleware.py b/mayan/apps/common/middleware/login_required_middleware.py index 3e64427e0c..ea631fa96e 100644 --- a/mayan/apps/common/middleware/login_required_middleware.py +++ b/mayan/apps/common/middleware/login_required_middleware.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import re diff --git a/mayan/apps/common/middleware/strip_spaces_widdleware.py b/mayan/apps/common/middleware/strip_spaces_widdleware.py index ddfa4edf52..b6d4a0ba7a 100644 --- a/mayan/apps/common/middleware/strip_spaces_widdleware.py +++ b/mayan/apps/common/middleware/strip_spaces_widdleware.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.html import strip_spaces_between_tags diff --git a/mayan/apps/common/middleware/timezone.py b/mayan/apps/common/middleware/timezone.py index e8208f628e..9abb30698b 100644 --- a/mayan/apps/common/middleware/timezone.py +++ b/mayan/apps/common/middleware/timezone.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import pytz from django.utils import timezone diff --git a/mayan/apps/common/models.py b/mayan/apps/common/models.py index 7f4102e3f8..58e74cbb48 100644 --- a/mayan/apps/common/models.py +++ b/mayan/apps/common/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from pytz import common_timezones @@ -18,7 +18,7 @@ SHARED_UPLOADED_FILE_PATH = 'shared_uploads' def upload_to(instance, filename): instance.filename = filename - return u'/'.join([SHARED_UPLOADED_FILE_PATH, filename]) + return '/'.join([SHARED_UPLOADED_FILE_PATH, filename]) class AnonymousUserSingleton(SingletonModel): @@ -28,26 +28,26 @@ class AnonymousUserSingleton(SingletonModel): return ugettext('Anonymous user') class Meta: - verbose_name = verbose_name_plural = _(u'Anonymous user') + verbose_name = verbose_name_plural = _('Anonymous user') class AutoAdminSingleton(SingletonModel): - account = models.ForeignKey(User, null=True, blank=True, related_name='auto_admin_account', verbose_name=_(u'Account')) - password = models.CharField(null=True, blank=True, verbose_name=_(u'Password'), max_length=128) - password_hash = models.CharField(null=True, blank=True, verbose_name=_(u'Password hash'), max_length=128) + account = models.ForeignKey(User, null=True, blank=True, related_name='auto_admin_account', verbose_name=_('Account')) + password = models.CharField(null=True, blank=True, verbose_name=_('Password'), max_length=128) + password_hash = models.CharField(null=True, blank=True, verbose_name=_('Password hash'), max_length=128) class Meta: - verbose_name = verbose_name_plural = _(u'Auto admin properties') + verbose_name = verbose_name_plural = _('Auto admin properties') class SharedUploadedFile(models.Model): - file = models.FileField(upload_to=upload_to, storage=shared_storage_backend, verbose_name=_(u'File')) + file = models.FileField(upload_to=upload_to, storage=shared_storage_backend, verbose_name=_('File')) filename = models.CharField(max_length=255, verbose_name=_('Filename')) datatime = models.DateTimeField(auto_now_add=True, verbose_name=_('Date time')) class Meta: - verbose_name = _(u'Shared uploaded file') - verbose_name_plural = _(u'Shared uploaded files') + verbose_name = _('Shared uploaded file') + verbose_name_plural = _('Shared uploaded files') def __unicode__(self): return self.filename @@ -67,5 +67,5 @@ class UserLocaleProfile(models.Model): return unicode(self.user) class Meta: - verbose_name = _(u'User locale profile') - verbose_name_plural = _(u'User locale profiles') + verbose_name = _('User locale profile') + verbose_name_plural = _('User locale profiles') diff --git a/mayan/apps/common/runtime.py b/mayan/apps/common/runtime.py index 5c68ea185f..44c2795f85 100644 --- a/mayan/apps/common/runtime.py +++ b/mayan/apps/common/runtime.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from common.utils import load_backend from .settings import SHARED_STORAGE diff --git a/mayan/apps/common/settings.py b/mayan/apps/common/settings.py index 5a87659cf4..111d831621 100644 --- a/mayan/apps/common/settings.py +++ b/mayan/apps/common/settings.py @@ -1,67 +1,67 @@ -"""Configuration options for the common app""" +from __future__ import unicode_literals -from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User +from django.utils.translation import ugettext_lazy as _ from smart_settings.api import register_setting TEMPORARY_DIRECTORY = register_setting( - namespace=u'common', - module=u'common.settings', - name=u'TEMPORARY_DIRECTORY', - global_name=u'COMMON_TEMPORARY_DIRECTORY', - default=u'/tmp', - description=_(u'Temporary directory used site wide to store thumbnails, previews and temporary files. If none is specified, one will be created using tempfile.mkdtemp()'), + namespace='common', + module='common.settings', + name='TEMPORARY_DIRECTORY', + global_name='COMMON_TEMPORARY_DIRECTORY', + default='/tmp', + description=_('Temporary directory used site wide to store thumbnails, previews and temporary files. If none is specified, one will be created using tempfile.mkdtemp()'), exists=True ) register_setting( - namespace=u'common', - module=u'common.settings', - name=u'AUTO_CREATE_ADMIN', - global_name=u'COMMON_AUTO_CREATE_ADMIN', + namespace='common', + module='common.settings', + name='AUTO_CREATE_ADMIN', + global_name='COMMON_AUTO_CREATE_ADMIN', default=True, ) register_setting( - namespace=u'common', - module=u'common.settings', - name=u'AUTO_ADMIN_USERNAME', - global_name=u'COMMON_AUTO_ADMIN_USERNAME', - default=u'admin', + namespace='common', + module='common.settings', + name='AUTO_ADMIN_USERNAME', + global_name='COMMON_AUTO_ADMIN_USERNAME', + default='admin', ) register_setting( - namespace=u'common', - module=u'common.settings', - name=u'AUTO_ADMIN_PASSWORD', - global_name=u'COMMON_AUTO_ADMIN_PASSWORD', + namespace='common', + module='common.settings', + name='AUTO_ADMIN_PASSWORD', + global_name='COMMON_AUTO_ADMIN_PASSWORD', default=User.objects.make_random_password(), ) register_setting( - namespace=u'common', - module=u'common.settings', - name=u'LOGIN_METHOD', - global_name=u'COMMON_LOGIN_METHOD', - default=u'username', - description=_(u'Controls the mechanism used to authenticated user. Options are: username, email'), + namespace='common', + module='common.settings', + name='LOGIN_METHOD', + global_name='COMMON_LOGIN_METHOD', + default='username', + description=_('Controls the mechanism used to authenticated user. Options are: username, email'), ) register_setting( - namespace=u'common', - module=u'common.settings', - name=u'ALLOW_ANONYMOUS_ACCESS', - global_name=u'COMMON_ALLOW_ANONYMOUS_ACCESS', + namespace='common', + module='common.settings', + name='ALLOW_ANONYMOUS_ACCESS', + global_name='COMMON_ALLOW_ANONYMOUS_ACCESS', default=False, - description=_(u'Allow non authenticated users, access to all views'), + description=_('Allow non authenticated users, access to all views'), ) register_setting( - namespace=u'common', - module=u'common.settings', - name=u'SHARED_STORAGE', - global_name=u'COMMON_SHARED_STORAGE', + namespace='common', + module='common.settings', + name='SHARED_STORAGE', + global_name='COMMON_SHARED_STORAGE', default='storage.backends.filebasedstorage.FileBasedStorage', - description=_(u'A storage backend that all workers can use to share files.'), + description=_('A storage backend that all workers can use to share files.'), ) diff --git a/mayan/apps/common/templatetags/autoadmin_tags.py b/mayan/apps/common/templatetags/autoadmin_tags.py index ee602a781a..b372b4df4f 100644 --- a/mayan/apps/common/templatetags/autoadmin_tags.py +++ b/mayan/apps/common/templatetags/autoadmin_tags.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.template import Library from common.models import AutoAdminSingleton @@ -8,4 +10,4 @@ register = Library() @register.simple_tag(takes_context=True) def auto_admin_properties(context): context['auto_admin_properties'] = AutoAdminSingleton.objects.get() - return u'' + return '' diff --git a/mayan/apps/common/templatetags/multiselect_tags.py b/mayan/apps/common/templatetags/multiselect_tags.py index 5ed52b30a7..6408c53f23 100644 --- a/mayan/apps/common/templatetags/multiselect_tags.py +++ b/mayan/apps/common/templatetags/multiselect_tags.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from json import dumps from django.template import Library diff --git a/mayan/apps/common/templatetags/non_breakable.py b/mayan/apps/common/templatetags/non_breakable.py index 9187038790..55ef62f5f2 100644 --- a/mayan/apps/common/templatetags/non_breakable.py +++ b/mayan/apps/common/templatetags/non_breakable.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.template import Library register = Library() @@ -5,4 +7,4 @@ register = Library() @register.filter def make_non_breakable(value): - return value.replace(u'-', u'\u2011') + return value.replace('-', '\u2011') diff --git a/mayan/apps/common/templatetags/project_tags.py b/mayan/apps/common/templatetags/project_tags.py index b6f026fd0f..f8e6d85eda 100644 --- a/mayan/apps/common/templatetags/project_tags.py +++ b/mayan/apps/common/templatetags/project_tags.py @@ -1,5 +1,5 @@ -from django.template import Library from django.conf import settings +from django.template import Library register = Library() diff --git a/mayan/apps/common/templatetags/set_var.py b/mayan/apps/common/templatetags/set_var.py index 88706a157c..f4fd7979f0 100644 --- a/mayan/apps/common/templatetags/set_var.py +++ b/mayan/apps/common/templatetags/set_var.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django import template register = template.Library() @@ -16,7 +18,7 @@ class SetVarNode(template.Node): # Make it global across all blocks context.dicts[0][self.var_name] = value - return u"" + return '' def set_var(parser, token): diff --git a/mayan/apps/common/templatetags/settings.py b/mayan/apps/common/templatetags/settings.py index 88706e1e76..90e27bc2cd 100644 --- a/mayan/apps/common/templatetags/settings.py +++ b/mayan/apps/common/templatetags/settings.py @@ -1,8 +1,9 @@ +from __future__ import unicode_literals + import re -from django.template import Node -from django.template import TemplateSyntaxError, Library from django.conf import settings +from django.template import Library, Node, TemplateSyntaxError register = Library() diff --git a/mayan/apps/common/templatetags/subtemplates_tags.py b/mayan/apps/common/templatetags/subtemplates_tags.py index 13fe8bf75c..540383a62d 100644 --- a/mayan/apps/common/templatetags/subtemplates_tags.py +++ b/mayan/apps/common/templatetags/subtemplates_tags.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import re from django.template import (Context, Library, Node, TemplateSyntaxError, diff --git a/mayan/apps/common/templatetags/variable_tags.py b/mayan/apps/common/templatetags/variable_tags.py index b483834c3a..5f7a7078ed 100644 --- a/mayan/apps/common/templatetags/variable_tags.py +++ b/mayan/apps/common/templatetags/variable_tags.py @@ -14,7 +14,7 @@ class CopyNode(Node): def render(self, context): context[Variable(self.var_name).resolve(context)] = Variable(self.source_variable).resolve(context) if self.delete_old: - context[Variable(self.source_variable).resolve(context)] = u'' + context[Variable(self.source_variable).resolve(context)] = '' return '' diff --git a/mayan/apps/common/templatetags/version_tags.py b/mayan/apps/common/templatetags/version_tags.py index 26c17b332d..ba338b4911 100644 --- a/mayan/apps/common/templatetags/version_tags.py +++ b/mayan/apps/common/templatetags/version_tags.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.template import Library from django.utils.importlib import import_module @@ -10,4 +12,4 @@ def app_version(app_name): app = import_module(app_name) return app.__version__ except ImportError: - return u'' + return '' diff --git a/mayan/apps/common/urls.py b/mayan/apps/common/urls.py index 1722167590..e230dadd90 100644 --- a/mayan/apps/common/urls.py +++ b/mayan/apps/common/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf import settings from django.conf.urls import patterns, url from django.views.generic import RedirectView, TemplateView diff --git a/mayan/apps/common/utils.py b/mayan/apps/common/utils.py index 61d6d765ad..34146f6fd1 100644 --- a/mayan/apps/common/utils.py +++ b/mayan/apps/common/utils.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import +from __future__ import unicode_literals import logging import os @@ -19,7 +19,7 @@ logger = logging.getLogger(__name__) def urlquote(link=None, get=None): - u""" + """ This method does both: urlquote() and urlencode() urlqoute(): Quote special characters in 'link' @@ -44,7 +44,7 @@ def urlquote(link=None, get=None): assert not get, get get = link link = '' - assert isinstance(get, dict), u'wrong type "%s", dict required' % type(get) + assert isinstance(get, dict), 'wrong type "%s", dict required' % type(get) # assert not (link.startswith('http://') or link.startswith('https://')), \ # 'This method should only quote the url path. # It should not start with http(s):// (%s)' % ( @@ -54,8 +54,8 @@ def urlquote(link=None, get=None): if isinstance(get, MultiValueDict): get = get.lists() if link: - link = u'%s?' % django_urlquote(link) - return u'%s%s' % (link, django_urlencode(get, doseq=True)) + link = '%s?' % django_urlquote(link) + return '%s%s' % (link, django_urlencode(get, doseq=True)) else: return django_urlquote(link) @@ -67,7 +67,7 @@ def return_attrib(obj, attrib, arguments=None): elif isinstance(obj, types.DictType) or isinstance(obj, types.DictionaryType): return obj[attrib] else: - result = reduce(getattr, attrib.split(u'.'), obj) + result = reduce(getattr, attrib.split('.'), obj) if isinstance(result, types.MethodType): if arguments: return result(**arguments) @@ -86,8 +86,8 @@ def return_attrib(obj, attrib, arguments=None): # http://snippets.dzone.com/user/jakob def pretty_size(size, suffixes=None): suffixes = suffixes or [ - (u'B', 1024L), (u'K', 1048576L), (u'M', 1073741824L), - (u'G', 1099511627776L), (u'T', 1125899906842624L) + ('B', 1024L), ('K', 1048576L), ('M', 1073741824L), + ('G', 1099511627776L), ('T', 1125899906842624L) ] for suf, lim in suffixes: @@ -104,20 +104,20 @@ def pretty_size_10(size): return pretty_size( size, suffixes=[ - (u'B', 1000L), (u'K', 1000000L), (u'M', 1000000000L), - (u'G', 1000000000000L), (u'T', 1000000000000000L) + ('B', 1000L), ('K', 1000000L), ('M', 1000000000L), + ('G', 1000000000000L), ('T', 1000000000000000L) ]) def return_type(value): if isinstance(value, types.FunctionType): - return value.__doc__ if value.__doc__ else _(u'Function found') + return value.__doc__ if value.__doc__ else _('Function found') elif isinstance(value, types.ClassType): - return u'%s.%s' % (value.__class__.__module__, value.__class__.__name__) + return '%s.%s' % (value.__class__.__module__, value.__class__.__name__) elif isinstance(value, types.TypeType): - return u'%s.%s' % (value.__module__, value.__name__) + return '%s.%s' % (value.__module__, value.__name__) elif isinstance(value, types.DictType) or isinstance(value, types.DictionaryType): - return u', '.join(list(value)) + return ', '.join(list(value)) else: return value @@ -125,8 +125,8 @@ def return_type(value): # http://stackoverflow.com/questions/4248399/page-range-for-printing-algorithm def parse_range(astr): result = set() - for part in astr.split(u','): - x = part.split(u'-') + for part in astr.split(','): + x = part.split('-') result.update(range(int(x[0]), int(x[-1]) + 1)) return sorted(result) @@ -140,10 +140,10 @@ def generate_choices_w_labels(choices, display_object_type=True): label = choice.get_full_name() if choice.get_full_name() else choice if display_object_type: - verbose_name = unicode(getattr(choice._meta, u'verbose_name', ct.name)) - results.append((u'%s,%s' % (ct.model, choice.pk), u'%s: %s' % (verbose_name, label))) + verbose_name = unicode(getattr(choice._meta, 'verbose_name', ct.name)) + results.append(('%s,%s' % (ct.model, choice.pk), '%s: %s' % (verbose_name, label))) else: - results.append((u'%s,%s' % (ct.model, choice.pk), u'%s' % (label))) + results.append(('%s,%s' % (ct.model, choice.pk), '%s' % (label))) # Sort results by the label not the key value return sorted(results, key=lambda x: x[1]) @@ -162,9 +162,9 @@ def get_object_name(obj, display_object_type=True): except AttributeError: verbose_name = ct_label - return u'%s: %s' % (verbose_name, label) + return '%s: %s' % (verbose_name, label) else: - return u'%s' % (label) + return '%s' % (label) def validate_path(path): diff --git a/mayan/apps/common/views.py b/mayan/apps/common/views.py index f0dc1f79e2..0b926c8e7d 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from json import dumps, loads @@ -39,15 +39,15 @@ def multi_object_action_view(request): next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', reverse('main:home')))) action = request.GET.get('action', None) - id_list = u','.join([key[3:] for key in request.GET.keys() if key.startswith('pk_')]) + id_list = ','.join([key[3:] for key in request.GET.keys() if key.startswith('pk_')]) items_property_list = [loads(key[11:]) for key in request.GET.keys() if key.startswith('properties_')] if not action: - messages.error(request, _(u'No action selected.')) + messages.error(request, _('No action selected.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) if not id_list and not items_property_list: - messages.error(request, _(u'Must select at least one item.')) + messages.error(request, _('Must select at least one item.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) # Separate redirects to keep backwards compatibility with older @@ -65,17 +65,17 @@ def multi_object_action_view(request): def get_obj_from_content_type_string(string): - model, pk = string.split(u',') + model, pk = string.split(',') ct = ContentType.objects.get(model=model) return ct.get_object_for_this_type(pk=pk) def assign_remove(request, left_list, right_list, add_method, remove_method, left_list_title=None, right_list_title=None, decode_content_type=False, extra_context=None, grouped=False): - left_list_name = u'left_list' - right_list_name = u'right_list' + left_list_name = 'left_list' + right_list_name = 'right_list' if request.method == 'POST': - if u'%s-submit' % left_list_name in request.POST.keys(): + if '%s-submit' % left_list_name in request.POST.keys(): unselected_list = ChoiceForm(request.POST, prefix=left_list_name, choices=left_list()) @@ -99,10 +99,10 @@ def assign_remove(request, left_list, right_list, add_method, remove_method, lef if settings.DEBUG: raise else: - messages.error(request, _(u'Unable to remove %(selection)s.') % { + messages.error(request, _('Unable to remove %(selection)s.') % { 'selection': label, 'right_list_title': right_list_title}) - elif u'%s-submit' % right_list_name in request.POST.keys(): + elif '%s-submit' % right_list_name in request.POST.keys(): selected_list = ChoiceForm(request.POST, prefix=right_list_name, choices=right_list()) @@ -124,7 +124,7 @@ def assign_remove(request, left_list, right_list, add_method, remove_method, lef if settings.DEBUG: raise else: - messages.error(request, _(u'Unable to add %(selection)s.') % { + messages.error(request, _('Unable to add %(selection)s.') % { 'selection': label, 'right_list_title': right_list_title}) unselected_list = ChoiceForm(prefix=left_list_name, choices=left_list()) selected_list = ChoiceForm(prefix=right_list_name, choices=right_list()) @@ -137,7 +137,7 @@ def assign_remove(request, left_list, right_list, add_method, remove_method, lef 'context': { 'form': unselected_list, 'title': left_list_title or ' ', - 'submit_label': _(u'Add'), + 'submit_label': _('Add'), 'submit_icon_famfam': 'add' } }, @@ -148,7 +148,7 @@ def assign_remove(request, left_list, right_list, add_method, remove_method, lef 'context': { 'form': selected_list, 'title': right_list_title or ' ', - 'submit_label': _(u'Remove'), + 'submit_label': _('Remove'), 'submit_icon_famfam': 'delete' } }, @@ -171,7 +171,7 @@ def current_user_details(request): return render_to_response( 'main/generic_form.html', { 'form': form, - 'title': _(u'Current user details'), + 'title': _('Current user details'), 'read_only': True, }, context_instance=RequestContext(request)) @@ -186,7 +186,7 @@ def current_user_locale_profile_details(request): return render_to_response( 'main/generic_form.html', { 'form': form, - 'title': _(u'Current user locale profile details'), + 'title': _('Current user locale profile details'), 'read_only': True, }, context_instance=RequestContext(request)) @@ -203,10 +203,10 @@ def current_user_edit(request): form = UserForm(instance=request.user, data=request.POST) if form.is_valid(): if User.objects.filter(email=form.cleaned_data['email']).exclude(pk=request.user.pk).count(): - messages.error(request, _(u'E-mail conflict, another user has that same email.')) + messages.error(request, _('E-mail conflict, another user has that same email.')) else: form.save() - messages.success(request, _(u'Current user\'s details updated.')) + messages.success(request, _('Current user\'s details updated.')) return HttpResponseRedirect(next) else: form = UserForm(instance=request.user) @@ -215,7 +215,7 @@ def current_user_edit(request): 'main/generic_form.html', { 'form': form, 'next': next, - 'title': _(u'Edit current user details'), + 'title': _('Edit current user details'), }, context_instance=RequestContext(request)) @@ -238,7 +238,7 @@ def current_user_locale_profile_edit(request): else: request.set_cookie(settings.LANGUAGE_COOKIE_NAME, form.cleaned_data['language']) - messages.success(request, _(u'Current user\'s locale profile details updated.')) + messages.success(request, _('Current user\'s locale profile details updated.')) return HttpResponseRedirect(next) else: form = LocaleProfileForm(instance=request.user.locale_profile) @@ -247,7 +247,7 @@ def current_user_locale_profile_edit(request): 'main/generic_form.html', { 'form': form, 'next': next, - 'title': _(u'Edit current user locale profile details'), + 'title': _('Edit current user locale profile details'), }, context_instance=RequestContext(request)) @@ -278,7 +278,7 @@ def license_view(request): return render_to_response( 'main/generic_detail.html', { 'form': form, - 'title': _(u'License'), + 'title': _('License'), }, context_instance=RequestContext(request)) @@ -287,7 +287,7 @@ def password_change_view(request): """ Password change wrapper for better control """ - context = {'title': _(u'Current user password change')} + context = {'title': _('Current user password change')} return password_change( request, @@ -302,7 +302,7 @@ def password_change_done(request): View called when the new user password has been accepted """ - messages.success(request, _(u'Your password has been successfully changed.')) + messages.success(request, _('Your password has been successfully changed.')) return redirect('common:current_user_details') diff --git a/mayan/apps/common/widgets.py b/mayan/apps/common/widgets.py index d1f0c480eb..d2f97459f9 100644 --- a/mayan/apps/common/widgets.py +++ b/mayan/apps/common/widgets.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from itertools import chain import os @@ -15,7 +17,7 @@ class PlainWidget(forms.widgets.Widget): widget and reduces the output to only it's value """ def render(self, name, value, attrs=None): - return mark_safe(u'%s' % value) + return mark_safe('%s' % value) class DetailSelectMultiple(forms.widgets.SelectMultiple): @@ -28,7 +30,7 @@ class DetailSelectMultiple(forms.widgets.SelectMultiple): value = '' final_attrs = self.build_attrs(attrs, name=name) css_class = final_attrs.get('class', 'list') - output = u'\n') def exists_with_famfam(path): @@ -66,11 +68,11 @@ def exists_with_famfam(path): return exception -def two_state_template(state, famfam_ok_icon=u'tick', famfam_fail_icon=u'cross'): +def two_state_template(state, famfam_ok_icon='tick', famfam_fail_icon='cross'): if state: - return mark_safe(u'' % famfam_ok_icon) + return mark_safe('' % famfam_ok_icon) else: - return mark_safe(u'' % famfam_fail_icon) + return mark_safe('' % famfam_fail_icon) class TextAreaDiv(forms.widgets.Widget): @@ -88,11 +90,11 @@ class TextAreaDiv(forms.widgets.Widget): def render(self, name, value, attrs=None): if value is None: - value = u'' + value = '' flat_attrs = flatatt(self.build_attrs(attrs, name=name)) content = conditional_escape(force_unicode(value)) - result = u'%s' % (flat_attrs, content) + result = '%s' % (flat_attrs, content) return mark_safe(result) @@ -124,7 +126,7 @@ class ScrollableCheckboxSelectMultiple(forms.widgets.CheckboxSelectMultiple): value = [] has_id = attrs and 'id' in attrs final_attrs = self.build_attrs(attrs, name=name) - output = [u'
    '] + output = ['
      '] # Normalize to strings str_values = set([force_unicode(v) for v in value]) for i, (option_value, option_label) in enumerate(chain(self.choices, choices)): @@ -132,7 +134,7 @@ class ScrollableCheckboxSelectMultiple(forms.widgets.CheckboxSelectMultiple): # so that the checkboxes don't all have the same ID attribute. if has_id: final_attrs = dict(final_attrs, id='%s_%s' % (attrs['id'], i)) - label_for = u' for="%s"' % final_attrs['id'] + label_for = ' for="%s"' % final_attrs['id'] else: label_for = '' @@ -140,7 +142,7 @@ class ScrollableCheckboxSelectMultiple(forms.widgets.CheckboxSelectMultiple): option_value = force_unicode(option_value) rendered_cb = cb.render(name, option_value) option_label = conditional_escape(force_unicode(option_label)) - output.append(u'
    • %s %s
    • ' % (label_for, rendered_cb, option_label)) - output.append(u'
    ') + output.append('
  • %s %s
  • ' % (label_for, rendered_cb, option_label)) + output.append('
') - return mark_safe(u'
%s
' % u'\n'.join(output)) + return mark_safe('
%s
' % '\n'.join(output)) diff --git a/mayan/apps/converter/api.py b/mayan/apps/converter/api.py index 03b024e00c..f0cbb768ed 100644 --- a/mayan/apps/converter/api.py +++ b/mayan/apps/converter/api.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import hashlib import logging @@ -31,7 +31,7 @@ def cache_cleanup(input_filepath, *args, **kwargs): def create_image_cache_filename(input_filepath, *args, **kwargs): if input_filepath: - hash_value = HASH_FUNCTION(u''.join([HASH_FUNCTION(smart_str(input_filepath)), unicode(args), unicode(kwargs)])) + hash_value = HASH_FUNCTION(''.join([HASH_FUNCTION(smart_str(input_filepath)), unicode(args), unicode(kwargs)])) return os.path.join(TEMPORARY_DIRECTORY, hash_value) else: return None @@ -71,7 +71,7 @@ def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype= transformations.append( { 'transformation': TRANSFORMATION_RESIZE, - 'arguments': dict(zip([u'width', u'height'], size.split(DIMENSION_SEPARATOR))) + 'arguments': dict(zip(['width', 'height'], size.split(DIMENSION_SEPARATOR))) } ) diff --git a/mayan/apps/converter/backends/__init__.py b/mayan/apps/converter/backends/__init__.py index 25a0284174..cbb6875187 100644 --- a/mayan/apps/converter/backends/__init__.py +++ b/mayan/apps/converter/backends/__init__.py @@ -1,18 +1,21 @@ +from __future__ import unicode_literals + + class ConverterBase(object): """ Base class that all backend classes must inherit """ def convert_file(self, input_filepath, *args, **kwargs): - raise NotImplementedError("Your %s class has not defined a convert_file() method, which is required." % self.__class__.__name__) + raise NotImplementedError('Your %s class has not defined a convert_file() method, which is required.' % self.__class__.__name__) def convert_document(self, document, *args, **kwargs): - raise NotImplementedError("Your %s class has not defined a convert_document() method, which is required." % self.__class__.__name__) + raise NotImplementedError('Your %s class has not defined a convert_document() method, which is required.' % self.__class__.__name__) def get_format_list(self): - raise NotImplementedError("Your %s class has not defined a get_format_list() method, which is required." % self.__class__.__name__) + raise NotImplementedError('Your %s class has not defined a get_format_list() method, which is required.' % self.__class__.__name__) def get_available_transformations(self): - raise NotImplementedError("Your %s class has not defined a get_available_transformations() method, which is required." % self.__class__.__name__) + raise NotImplementedError('Your %s class has not defined a get_available_transformations() method, which is required.' % self.__class__.__name__) def get_page_count(self, input_filepath): - raise NotImplementedError("Your %s class has not defined a get_page_count() method, which is required." % self.__class__.__name__) + raise NotImplementedError('Your %s class has not defined a get_page_count() method, which is required.' % self.__class__.__name__) diff --git a/mayan/apps/converter/backends/graphicsmagick.py b/mayan/apps/converter/backends/graphicsmagick.py index 8a4300c7d3..77b22a0b6f 100644 --- a/mayan/apps/converter/backends/graphicsmagick.py +++ b/mayan/apps/converter/backends/graphicsmagick.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import subprocess @@ -10,15 +10,15 @@ from ..literals import (DEFAULT_FILE_FORMAT, DEFAULT_PAGE_NUMBER, DIMENSION_SEPARATOR) from ..settings import GM_PATH, GM_SETTINGS -CONVERTER_ERROR_STARTS_WITH = u'starts with' -CONVERTER_ERROR_STRING_NO_DECODER = u'No decode delegate for this image format' +CONVERTER_ERROR_STARTS_WITH = 'starts with' +CONVERTER_ERROR_STRING_NO_DECODER = 'No decode delegate for this image format' class GraphicsMagick(ConverterBase): def identify_file(self, input_filepath, arguments=None): command = [] command.append(unicode(GM_PATH)) - command.append(u'identify') + command.append('identify') if arguments: command.extend(arguments) command.append(unicode(input_filepath)) @@ -39,32 +39,32 @@ class GraphicsMagick(ConverterBase): dimensions.append(unicode(transformation['arguments']['width'])) if 'height' in transformation['arguments']: dimensions.append(unicode(transformation['arguments']['height'])) - arguments.append(u'-resize') - arguments.append(u'%s' % DIMENSION_SEPARATOR.join(dimensions)) + arguments.append('-resize') + arguments.append('%s' % DIMENSION_SEPARATOR.join(dimensions)) elif transformation['transformation'] == TRANSFORMATION_ZOOM: - arguments.append(u'-resize') - arguments.append(u'%d%%' % transformation['arguments']['percent']) + arguments.append('-resize') + arguments.append('%d%%' % transformation['arguments']['percent']) elif transformation['transformation'] == TRANSFORMATION_ROTATE: - arguments.append(u'-rotate') - arguments.append(u'%s' % transformation['arguments']['degrees']) + arguments.append('-rotate') + arguments.append('%s' % transformation['arguments']['degrees']) except: pass - if file_format.lower() == u'jpeg' or file_format.lower() == u'jpg': - arguments.append(u'-quality') - arguments.append(u'85') + if file_format.lower() == 'jpeg' or file_format.lower() == 'jpg': + arguments.append('-quality') + arguments.append('85') # Graphicsmagick page number is 0 base - input_arg = u'%s[%d]' % (input_filepath, page - 1) + input_arg = '%s[%d]' % (input_filepath, page - 1) # Specify the file format next to the output filename - output_filepath = u'%s:%s' % (file_format, output_filepath) + output_filepath = '%s:%s' % (file_format, output_filepath) command = [] command.append(unicode(GM_PATH)) - command.append(u'convert') + command.append('convert') command.extend(unicode(GM_SETTINGS).split()) command.append(unicode(input_arg)) if arguments: diff --git a/mayan/apps/converter/backends/imagemagick.py b/mayan/apps/converter/backends/imagemagick.py index 114c81f454..2ee13b1612 100644 --- a/mayan/apps/converter/backends/imagemagick.py +++ b/mayan/apps/converter/backends/imagemagick.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import subprocess @@ -9,7 +9,7 @@ from ..literals import (DEFAULT_FILE_FORMAT, DEFAULT_PAGE_NUMBER, TRANSFORMATION_ROTATE, TRANSFORMATION_ZOOM) from ..settings import IM_CONVERT_PATH, IM_IDENTIFY_PATH -CONVERTER_ERROR_STRING_NO_DECODER = u'no decode delegate for this image format' +CONVERTER_ERROR_STRING_NO_DECODER = 'no decode delegate for this image format' class ImageMagick(ConverterBase): @@ -36,28 +36,28 @@ class ImageMagick(ConverterBase): dimensions.append(unicode(transformation['arguments']['width'])) if 'height' in transformation['arguments']: dimensions.append(unicode(transformation['arguments']['height'])) - arguments.append(u'-resize') - arguments.append(u'%s' % DIMENSION_SEPARATOR.join(dimensions)) + arguments.append('-resize') + arguments.append('%s' % DIMENSION_SEPARATOR.join(dimensions)) elif transformation['transformation'] == TRANSFORMATION_ZOOM: - arguments.append(u'-resize') - arguments.append(u'%d%%' % transformation['arguments']['percent']) + arguments.append('-resize') + arguments.append('%d%%' % transformation['arguments']['percent']) elif transformation['transformation'] == TRANSFORMATION_ROTATE: - arguments.append(u'-rotate') - arguments.append(u'%s' % transformation['arguments']['degrees']) + arguments.append('-rotate') + arguments.append('%s' % transformation['arguments']['degrees']) except: pass - if file_format.lower() == u'jpeg' or file_format.lower() == u'jpg': - arguments.append(u'-quality') - arguments.append(u'85') + if file_format.lower() == 'jpeg' or file_format.lower() == 'jpg': + arguments.append('-quality') + arguments.append('85') # Imagemagick page number is 0 base - input_arg = u'%s[%d]' % (input_filepath, page - 1) + input_arg = '%s[%d]' % (input_filepath, page - 1) # Specify the file format next to the output filename - output_filepath = u'%s:%s' % (file_format, output_filepath) + output_filepath = '%s:%s' % (file_format, output_filepath) command = [] command.append(unicode(IM_CONVERT_PATH)) diff --git a/mayan/apps/converter/backends/python.py b/mayan/apps/converter/backends/python.py index f3c849a4cd..9a82623d3f 100644 --- a/mayan/apps/converter/backends/python.py +++ b/mayan/apps/converter/backends/python.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import io import logging diff --git a/mayan/apps/converter/exceptions.py b/mayan/apps/converter/exceptions.py index 1423d38002..832fe5e1be 100644 --- a/mayan/apps/converter/exceptions.py +++ b/mayan/apps/converter/exceptions.py @@ -1,3 +1,6 @@ +from __future__ import unicode_literals + + class ConvertError(Exception): """ Base exception for all coverter app exceptions diff --git a/mayan/apps/converter/literals.py b/mayan/apps/converter/literals.py index 3686402fa5..ca2648e061 100644 --- a/mayan/apps/converter/literals.py +++ b/mayan/apps/converter/literals.py @@ -1,48 +1,50 @@ # -*- coding: utf-8 -*- +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ DEFAULT_ZOOM_LEVEL = 100 DEFAULT_ROTATION = 0 DEFAULT_PAGE_NUMBER = 1 -DEFAULT_FILE_FORMAT = u'jpeg' -DEFAULT_FILE_FORMAT_MIMETYPE = u'image/jpeg' +DEFAULT_FILE_FORMAT = 'jpeg' +DEFAULT_FILE_FORMAT_MIMETYPE = 'image/jpeg' -DIMENSION_SEPARATOR = u'x' +DIMENSION_SEPARATOR = 'x' -TRANSFORMATION_RESIZE = u'resize' -TRANSFORMATION_ROTATE = u'rotate' -TRANSFORMATION_DENSITY = u'density' -TRANSFORMATION_ZOOM = u'zoom' +TRANSFORMATION_RESIZE = 'resize' +TRANSFORMATION_ROTATE = 'rotate' +TRANSFORMATION_DENSITY = 'density' +TRANSFORMATION_ZOOM = 'zoom' TRANSFORMATION_CHOICES = { TRANSFORMATION_RESIZE: { - 'label': _(u'Resize'), - 'description': _(u'Resize.'), + 'label': _('Resize'), + 'description': _('Resize.'), 'arguments': [ - {'name': 'width', 'label': _(u'Width'), 'required': True}, - {'name': 'height', 'label': _(u'Height'), 'required': False}, + {'name': 'width', 'label': _('Width'), 'required': True}, + {'name': 'height', 'label': _('Height'), 'required': False}, ] }, TRANSFORMATION_ROTATE: { - 'label': _(u'Rotate'), - 'description': _(u'Rotate by n degress.'), + 'label': _('Rotate'), + 'description': _('Rotate by n degress.'), 'arguments': [ - {'name': 'degrees', 'label': _(u'Degrees'), 'required': True} + {'name': 'degrees', 'label': _('Degrees'), 'required': True} ] }, TRANSFORMATION_DENSITY: { - 'label': _(u'Density'), - 'description': _(u'Change the resolution (ie: DPI) without resizing.'), + 'label': _('Density'), + 'description': _('Change the resolution (ie: DPI) without resizing.'), 'arguments': [ - {'name': 'width', 'label': _(u'Width'), 'required': True}, - {'name': 'height', 'label': _(u'Height'), 'required': False}, + {'name': 'width', 'label': _('Width'), 'required': True}, + {'name': 'height', 'label': _('Height'), 'required': False}, ] }, TRANSFORMATION_ZOOM: { - 'label': _(u'Zoom'), - 'description': _(u'Zoom by n percent.'), + 'label': _('Zoom'), + 'description': _('Zoom by n percent.'), 'arguments': [ - {'name': 'percent', 'label': _(u'Percent'), 'required': True} + {'name': 'percent', 'label': _('Percent'), 'required': True} ] }, } diff --git a/mayan/apps/converter/office_converter.py b/mayan/apps/converter/office_converter.py index 79b1f17f88..6ed6650819 100644 --- a/mayan/apps/converter/office_converter.py +++ b/mayan/apps/converter/office_converter.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging import os @@ -10,53 +10,53 @@ from mimetype.api import get_mimetype from .exceptions import OfficeBackendError, UnknownFileFormat from .settings import LIBREOFFICE_PATH -CACHED_FILE_SUFFIX = u'_office_converter' +CACHED_FILE_SUFFIX = '_office_converter' CONVERTER_OFFICE_FILE_MIMETYPES = [ - u'application/msword', - u'application/mswrite', - u'application/mspowerpoint', - u'application/msexcel', - u'application/pgp-keys', - u'application/vnd.ms-excel', - u'application/vnd.ms-excel.addin.macroEnabled.12', - u'application/vnd.ms-excel.sheet.binary.macroEnabled.12', - u'application/vnd.ms-powerpoint', - u'application/vnd.oasis.opendocument.chart', - u'application/vnd.oasis.opendocument.chart-template', - u'application/vnd.oasis.opendocument.formula', - u'application/vnd.oasis.opendocument.formula-template', - u'application/vnd.oasis.opendocument.graphics', - u'application/vnd.oasis.opendocument.graphics-template', - u'application/vnd.oasis.opendocument.image', - u'application/vnd.oasis.opendocument.image-template', - u'application/vnd.oasis.opendocument.presentation', - u'application/vnd.oasis.opendocument.presentation-template', - u'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - u'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - u'application/vnd.openxmlformats-officedocument.presentationml.template', - u'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - u'application/vnd.openxmlformats-officedocument.presentationml.presentation', - u'application/vnd.openxmlformats-officedocument.presentationml.slide', - u'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - u'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - u'application/vnd.oasis.opendocument.spreadsheet', - u'application/vnd.oasis.opendocument.spreadsheet-template', - u'application/vnd.oasis.opendocument.text', - u'application/vnd.oasis.opendocument.text-master', - u'application/vnd.oasis.opendocument.text-template', - u'application/vnd.oasis.opendocument.text-web', - u'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - u'application/vnd.ms-office', - u'application/xml', - u'text/x-c', - u'text/x-c++', - u'text/x-pascal', - u'text/x-msdos-batch', - u'text/x-python', - u'text/x-shellscript', - u'text/plain', - u'text/rtf', + 'application/msword', + 'application/mswrite', + 'application/mspowerpoint', + 'application/msexcel', + 'application/pgp-keys', + 'application/vnd.ms-excel', + 'application/vnd.ms-excel.addin.macroEnabled.12', + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'application/vnd.ms-powerpoint', + 'application/vnd.oasis.opendocument.chart', + 'application/vnd.oasis.opendocument.chart-template', + 'application/vnd.oasis.opendocument.formula', + 'application/vnd.oasis.opendocument.formula-template', + 'application/vnd.oasis.opendocument.graphics', + 'application/vnd.oasis.opendocument.graphics-template', + 'application/vnd.oasis.opendocument.image', + 'application/vnd.oasis.opendocument.image-template', + 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.oasis.opendocument.presentation-template', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.oasis.opendocument.spreadsheet-template', + 'application/vnd.oasis.opendocument.text', + 'application/vnd.oasis.opendocument.text-master', + 'application/vnd.oasis.opendocument.text-template', + 'application/vnd.oasis.opendocument.text-web', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.ms-office', + 'application/xml', + 'text/x-c', + 'text/x-c++', + 'text/x-pascal', + 'text/x-msdos-batch', + 'text/x-python', + 'text/x-shellscript', + 'text/plain', + 'text/rtf', ] logger = logging.getLogger(__name__) @@ -88,7 +88,7 @@ class OfficeConverter(object): if self.mimetype in CONVERTER_OFFICE_FILE_MIMETYPES: # Cache results of conversion - self.output_filepath = os.path.join(TEMPORARY_DIRECTORY, u''.join([self.input_filepath, CACHED_FILE_SUFFIX])) + self.output_filepath = os.path.join(TEMPORARY_DIRECTORY, ''.join([self.input_filepath, CACHED_FILE_SUFFIX])) self.exists = os.path.exists(self.output_filepath) if not self.exists: try: @@ -122,11 +122,11 @@ class OfficeConverterBackendDirect(object): command = [] command.append(self.libreoffice_path) - command.append(u'--headless') - command.append(u'--convert-to') - command.append(u'pdf') + command.append('--headless') + command.append('--convert-to') + command.append('pdf') command.append(self.input_filepath) - command.append(u'--outdir') + command.append('--outdir') command.append(TEMPORARY_DIRECTORY) logger.debug('command: %s', command) diff --git a/mayan/apps/converter/settings.py b/mayan/apps/converter/settings.py index cf09c32448..d0732fc473 100644 --- a/mayan/apps/converter/settings.py +++ b/mayan/apps/converter/settings.py @@ -1,19 +1,19 @@ -"""Configuration options for the converter app""" +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from smart_settings.api import register_settings register_settings( - namespace=u'converter', - module=u'converter.settings', + namespace='converter', + module='converter.settings', settings=[ - {'name': u'IM_CONVERT_PATH', 'global_name': u'CONVERTER_IM_CONVERT_PATH', 'default': u'/usr/bin/convert', 'description': _(u'File path to imagemagick\'s convert program.'), 'exists': True}, - {'name': u'IM_IDENTIFY_PATH', 'global_name': u'CONVERTER_IM_IDENTIFY_PATH', 'default': u'/usr/bin/identify', 'description': _(u'File path to imagemagick\'s identify program.'), 'exists': True}, - {'name': u'GM_PATH', 'global_name': u'CONVERTER_GM_PATH', 'default': u'/usr/bin/gm', 'description': _(u'File path to graphicsmagick\'s program.'), 'exists': True}, - {'name': u'GM_SETTINGS', 'global_name': u'CONVERTER_GM_SETTINGS', 'default': u''}, - {'name': u'GRAPHICS_BACKEND', 'global_name': u'CONVERTER_GRAPHICS_BACKEND', 'default': u'converter.backends.python.Python', 'description': _(u'Graphics conversion backend to use. Options are: converter.backends.imagemagick.ImageMagick, converter.backends.graphicsmagick.GraphicsMagick and converter.backends.python.Python')}, - {'name': u'LIBREOFFICE_PATH', 'global_name': u'CONVERTER_LIBREOFFICE_PATH', 'default': u'/usr/bin/libreoffice', 'exists': True, 'description': _(u'Path to the libreoffice program.')}, - {'name': u'PDFTOPPM_PATH', 'global_name': u'CONVERTER_PDFTOPPM_PATH', 'default': u'/usr/bin/pdftoppm', 'exists': True, 'description': _(u'Path to the Popple program pdftoppm.')}, + {'name': 'IM_CONVERT_PATH', 'global_name': 'CONVERTER_IM_CONVERT_PATH', 'default': '/usr/bin/convert', 'description': _('File path to imagemagick\'s convert program.'), 'exists': True}, + {'name': 'IM_IDENTIFY_PATH', 'global_name': 'CONVERTER_IM_IDENTIFY_PATH', 'default': '/usr/bin/identify', 'description': _('File path to imagemagick\'s identify program.'), 'exists': True}, + {'name': 'GM_PATH', 'global_name': 'CONVERTER_GM_PATH', 'default': '/usr/bin/gm', 'description': _('File path to graphicsmagick\'s program.'), 'exists': True}, + {'name': 'GM_SETTINGS', 'global_name': 'CONVERTER_GM_SETTINGS', 'default': ''}, + {'name': 'GRAPHICS_BACKEND', 'global_name': 'CONVERTER_GRAPHICS_BACKEND', 'default': 'converter.backends.python.Python', 'description': _('Graphics conversion backend to use. Options are: converter.backends.imagemagick.ImageMagick, converter.backends.graphicsmagick.GraphicsMagick and converter.backends.python.Python')}, + {'name': 'LIBREOFFICE_PATH', 'global_name': 'CONVERTER_LIBREOFFICE_PATH', 'default': '/usr/bin/libreoffice', 'exists': True, 'description': _('Path to the libreoffice program.')}, + {'name': 'PDFTOPPM_PATH', 'global_name': 'CONVERTER_PDFTOPPM_PATH', 'default': '/usr/bin/pdftoppm', 'exists': True, 'description': _('Path to the Popple program pdftoppm.')}, ] ) diff --git a/mayan/apps/django_gpg/__init__.py b/mayan/apps/django_gpg/__init__.py index 8e450e7fbb..257fc133fc 100644 --- a/mayan/apps/django_gpg/__init__.py +++ b/mayan/apps/django_gpg/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from hkp import Key as KeyServerKey diff --git a/mayan/apps/django_gpg/api.py b/mayan/apps/django_gpg/api.py index 6c0e9f0477..a506daec56 100644 --- a/mayan/apps/django_gpg/api.py +++ b/mayan/apps/django_gpg/api.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging import os @@ -37,7 +37,7 @@ class Key(object): if exclude: excluded_id = exclude.key_id else: - excluded_id = u'' + excluded_id = '' for key in keys: if not key['keyid'] in excluded_id: key_instance = Key( @@ -89,10 +89,10 @@ class Key(object): @property def user_ids(self): - return u', '.join(self.uids) + return ', '.join(self.uids) def __str__(self): - return '%s "%s" (%s)' % (self.key_id, self.user_ids, KEY_TYPES.get(self.type, _(u'Unknown'))) + return '%s "%s" (%s)' % (self.key_id, self.user_ids, KEY_TYPES.get(self.type, _('Unknown'))) def __unicode__(self): return unicode(self.__str__()) @@ -129,7 +129,7 @@ class GPG(object): try: self.gpg = gnupg.GPG(**kwargs) except Exception as exception: - raise GPGException(u'ERROR: GPG initialization error; %s' % exception) + raise GPGException('ERROR: GPG initialization error; %s' % exception) def verify_file(self, file_input, detached_signature=None, fetch_key=False): """ @@ -242,7 +242,7 @@ class GPG(object): return result def create_key(self, *args, **kwargs): - if kwargs.get('passphrase') == u'': + if kwargs.get('passphrase') == '': kwargs.pop('passphrase') input_data = self.gpg.gen_key_input(**kwargs) @@ -271,7 +271,7 @@ class GPG(object): def query(self, term): results = {} for keyserver in self.keyservers: - url = u'http://%s' % keyserver + url = 'http://%s' % keyserver server = KeyServer(url) try: key_list = server.search(term) diff --git a/mayan/apps/django_gpg/forms.py b/mayan/apps/django_gpg/forms.py index 930298d4b1..c58b0eb02f 100644 --- a/mayan/apps/django_gpg/forms.py +++ b/mayan/apps/django_gpg/forms.py @@ -1,9 +1,11 @@ +from __future__ import unicode_literals + from django import forms from django.utils.translation import ugettext_lazy as _ class KeySearchForm(forms.Form): term = forms.CharField( - label=_(u'Term'), - help_text=_(u'Name, e-mail, key ID or key fingerprint to look for.') + label=_('Term'), + help_text=_('Name, e-mail, key ID or key fingerprint to look for.') ) diff --git a/mayan/apps/django_gpg/links.py b/mayan/apps/django_gpg/links.py index 09dccd4a0b..018f30e329 100644 --- a/mayan/apps/django_gpg/links.py +++ b/mayan/apps/django_gpg/links.py @@ -1,11 +1,15 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ -from .permissions import (PERMISSION_KEY_DELETE, PERMISSION_KEY_RECEIVE, - PERMISSION_KEY_VIEW, PERMISSION_KEYSERVER_QUERY) +from .permissions import ( + PERMISSION_KEY_DELETE, PERMISSION_KEY_RECEIVE, PERMISSION_KEY_VIEW, + PERMISSION_KEYSERVER_QUERY +) -private_keys = {'text': _(u'Private keys'), 'view': 'django_gpg:key_private_list', 'args': 'object.pk', 'famfam': 'key', 'icon': 'key.png', 'permissions': [PERMISSION_KEY_VIEW]} -public_keys = {'text': _(u'Public keys'), 'view': 'django_gpg:key_public_list', 'args': 'object.pk', 'famfam': 'key', 'icon': 'key.png', 'permissions': [PERMISSION_KEY_VIEW]} -key_delete = {'text': _(u'Delete'), 'view': 'django_gpg:key_delete', 'args': ['object.fingerprint', 'object.type'], 'famfam': 'key_delete', 'permissions': [PERMISSION_KEY_DELETE]} -key_query = {'text': _(u'Query keyservers'), 'view': 'django_gpg:key_query', 'famfam': 'zoom', 'permissions': [PERMISSION_KEYSERVER_QUERY]} -key_receive = {'text': _(u'Import'), 'view': 'django_gpg:key_receive', 'args': 'object.keyid', 'famfam': 'key_add', 'keep_query': True, 'permissions': [PERMISSION_KEY_RECEIVE]} -key_setup = {'text': _(u'Key management'), 'view': 'django_gpg:key_public_list', 'args': 'object.pk', 'famfam': 'key', 'icon': 'key.png', 'permissions': [PERMISSION_KEY_VIEW]} +private_keys = {'text': _('Private keys'), 'view': 'django_gpg:key_private_list', 'args': 'object.pk', 'famfam': 'key', 'icon': 'key.png', 'permissions': [PERMISSION_KEY_VIEW]} +public_keys = {'text': _('Public keys'), 'view': 'django_gpg:key_public_list', 'args': 'object.pk', 'famfam': 'key', 'icon': 'key.png', 'permissions': [PERMISSION_KEY_VIEW]} +key_delete = {'text': _('Delete'), 'view': 'django_gpg:key_delete', 'args': ['object.fingerprint', 'object.type'], 'famfam': 'key_delete', 'permissions': [PERMISSION_KEY_DELETE]} +key_query = {'text': _('Query keyservers'), 'view': 'django_gpg:key_query', 'famfam': 'zoom', 'permissions': [PERMISSION_KEYSERVER_QUERY]} +key_receive = {'text': _('Import'), 'view': 'django_gpg:key_receive', 'args': 'object.keyid', 'famfam': 'key_add', 'keep_query': True, 'permissions': [PERMISSION_KEY_RECEIVE]} +key_setup = {'text': _('Key management'), 'view': 'django_gpg:key_public_list', 'args': 'object.pk', 'famfam': 'key', 'icon': 'key.png', 'permissions': [PERMISSION_KEY_VIEW]} diff --git a/mayan/apps/django_gpg/permissions.py b/mayan/apps/django_gpg/permissions.py index bfb486789f..321478146b 100644 --- a/mayan/apps/django_gpg/permissions.py +++ b/mayan/apps/django_gpg/permissions.py @@ -1,12 +1,12 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -django_gpg_namespace = PermissionNamespace('django_gpg', _(u'Key management')) +django_gpg_namespace = PermissionNamespace('django_gpg', _('Key management')) -PERMISSION_KEY_VIEW = Permission.objects.register(django_gpg_namespace, 'key_view', _(u'View keys')) -PERMISSION_KEY_DELETE = Permission.objects.register(django_gpg_namespace, 'key_delete', _(u'Delete keys')) -PERMISSION_KEYSERVER_QUERY = Permission.objects.register(django_gpg_namespace, 'keyserver_query', _(u'Query keyservers')) -PERMISSION_KEY_RECEIVE = Permission.objects.register(django_gpg_namespace, 'key_receive', _(u'Import keys from keyservers')) +PERMISSION_KEY_VIEW = Permission.objects.register(django_gpg_namespace, 'key_view', _('View keys')) +PERMISSION_KEY_DELETE = Permission.objects.register(django_gpg_namespace, 'key_delete', _('Delete keys')) +PERMISSION_KEYSERVER_QUERY = Permission.objects.register(django_gpg_namespace, 'keyserver_query', _('Query keyservers')) +PERMISSION_KEY_RECEIVE = Permission.objects.register(django_gpg_namespace, 'key_receive', _('Import keys from keyservers')) diff --git a/mayan/apps/django_gpg/settings.py b/mayan/apps/django_gpg/settings.py index e3e2932d71..ec3ff8b815 100644 --- a/mayan/apps/django_gpg/settings.py +++ b/mayan/apps/django_gpg/settings.py @@ -1,19 +1,18 @@ -""" -Configuration options for the django_gpg app -""" +from __future__ import unicode_literals + import os -from django.utils.translation import ugettext_lazy as _ from django.conf import settings +from django.utils.translation import ugettext_lazy as _ from smart_settings.api import register_settings register_settings( - namespace=u'django_gpg', - module=u'django_gpg.settings', + namespace='django_gpg', + module='django_gpg.settings', settings=[ - {'name': u'KEYSERVERS', 'global_name': u'SIGNATURES_KEYSERVERS', 'default': ['pool.sks-keyservers.net'], 'description': _(u'List of keyservers to be queried for unknown keys.')}, - {'name': u'GPG_HOME', 'global_name': u'SIGNATURES_GPG_HOME', 'default': os.path.join(settings.MEDIA_ROOT, u'gpg_home'), 'description': _(u'Home directory used to store keys as well as configuration files.')}, - {'name': u'GPG_PATH', 'global_name': u'SIGNATURES_GPG_PATH', 'default': u'/usr/bin/gpg', 'description': _(u'Path to the GPG binary.')}, + {'name': 'KEYSERVERS', 'global_name': 'SIGNATURES_KEYSERVERS', 'default': ['pool.sks-keyservers.net'], 'description': _('List of keyservers to be queried for unknown keys.')}, + {'name': 'GPG_HOME', 'global_name': 'SIGNATURES_GPG_HOME', 'default': os.path.join(settings.MEDIA_ROOT, 'gpg_home'), 'description': _('Home directory used to store keys as well as configuration files.')}, + {'name': 'GPG_PATH', 'global_name': 'SIGNATURES_GPG_PATH', 'default': '/usr/bin/gpg', 'description': _('Path to the GPG binary.')}, ] ) diff --git a/mayan/apps/django_gpg/views.py b/mayan/apps/django_gpg/views.py index f8a1e530ea..43f2931b65 100644 --- a/mayan/apps/django_gpg/views.py +++ b/mayan/apps/django_gpg/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging @@ -15,8 +15,10 @@ from permissions.models import Permission from .api import Key from .exceptions import KeyImportError from .forms import KeySearchForm -from .permissions import (PERMISSION_KEY_DELETE, PERMISSION_KEY_RECEIVE, - PERMISSION_KEY_VIEW, PERMISSION_KEYSERVER_QUERY) +from .permissions import ( + PERMISSION_KEY_DELETE, PERMISSION_KEY_RECEIVE, PERMISSION_KEY_VIEW, + PERMISSION_KEYSERVER_QUERY +) from .runtime import gpg logger = logging.getLogger(__name__) @@ -35,12 +37,12 @@ def key_receive(request, key_id): results = gpg.query(term) keys_dict = dict([(key.keyid, key) for key in results]) key = gpg.import_key(keys_dict[key_id].key) - messages.success(request, _(u'Key: %s, imported successfully.') % key) + messages.success(request, _('Key: %s, imported successfully.') % key) return HttpResponseRedirect(next) except (KeyImportError, KeyError, TypeError) as exception: messages.error( request, - _(u'Unable to import key id: %(key_id)s; %(error)s') % + _('Unable to import key id: %(key_id)s; %(error)s') % { 'key_id': key_id, 'error': exception, @@ -49,8 +51,8 @@ def key_receive(request, key_id): return HttpResponseRedirect(previous) return render_to_response('main/generic_confirm.html', { - 'title': _(u'Import key'), - 'message': _(u'Are you sure you wish to import key id: %s?') % key_id, + 'title': _('Import key'), + 'message': _('Are you sure you wish to import key id: %s?') % key_id, 'next': next, 'previous': previous, 'submit_method': 'GET', @@ -63,10 +65,10 @@ def key_list(request, secret=True): if secret: object_list = Key.get_all(gpg, secret=True) - title = _(u'Private keys') + title = _('Private keys') else: object_list = Key.get_all(gpg) - title = _(u'Public keys') + title = _('Public keys') return render_to_response('main/generic_list.html', { 'object_list': object_list, @@ -74,12 +76,12 @@ def key_list(request, secret=True): 'hide_object': True, 'extra_columns': [ { - 'name': _(u'Key ID'), + 'name': _('Key ID'), 'attribute': 'key_id', }, { - 'name': _(u'Owner'), - 'attribute': encapsulate(lambda x: u', '.join(x.uids)), + 'name': _('Owner'), + 'attribute': encapsulate(lambda x: ', '.join(x.uids)), }, ] }, context_instance=RequestContext(request)) @@ -98,16 +100,16 @@ def key_delete(request, fingerprint, key_type): if request.method == 'POST': try: gpg.delete_key(key) - messages.success(request, _(u'Key: %s, deleted successfully.') % fingerprint) + messages.success(request, _('Key: %s, deleted successfully.') % fingerprint) return HttpResponseRedirect(next) except Exception as exception: messages.error(request, exception) return HttpResponseRedirect(previous) return render_to_response('main/generic_confirm.html', { - 'title': _(u'Delete key'), + 'title': _('Delete key'), 'delete_view': True, - 'message': _(u'Are you sure you wish to delete key: %s? If you try to delete a public key that is part of a public/private pair the private key will be deleted as well.') % key, + 'message': _('Are you sure you wish to delete key: %s? If you try to delete a public key that is part of a public/private pair the private key will be deleted as well.') % key, 'next': next, 'previous': previous, }, context_instance=RequestContext(request)) @@ -124,7 +126,7 @@ def key_query(request): { 'name': 'main/generic_form_subtemplate.html', 'context': { - 'title': _(u'Query key server'), + 'title': _('Query key server'), 'form': form, 'submit_method': 'GET', }, @@ -137,46 +139,46 @@ def key_query(request): { 'name': 'main/generic_list_subtemplate.html', 'context': { - 'title': _(u'results'), + 'title': _('results'), 'object_list': results, 'hide_object': True, 'extra_columns': [ { - 'name': _(u'ID'), + 'name': _('ID'), 'attribute': 'keyid', }, { - 'name': _(u'Type'), + 'name': _('Type'), 'attribute': 'algo', }, { - 'name': _(u'Creation date'), + 'name': _('Creation date'), 'attribute': 'creation_date', }, { - 'name': _(u'Disabled'), + 'name': _('Disabled'), 'attribute': 'disabled', }, { - 'name': _(u'Expiration date'), + 'name': _('Expiration date'), 'attribute': 'expiration_date', }, { - 'name': _(u'Expired'), + 'name': _('Expired'), 'attribute': 'expired', }, { - 'name': _(u'Length'), + 'name': _('Length'), 'attribute': 'key_length', }, { - 'name': _(u'Revoked'), + 'name': _('Revoked'), 'attribute': 'revoked', }, { - 'name': _(u'Identifies'), - 'attribute': encapsulate(lambda x: u', '.join([identity.uid for identity in x.identities])), + 'name': _('Identifies'), + 'attribute': encapsulate(lambda x: ', '.join([identity.uid for identity in x.identities])), }, ] }, diff --git a/mayan/apps/document_acls/__init__.py b/mayan/apps/document_acls/__init__.py index c2a824ee45..a6fea018cf 100644 --- a/mayan/apps/document_acls/__init__.py +++ b/mayan/apps/document_acls/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from acls.api import class_permissions from acls.permissions import ACLS_VIEW_ACL, ACLS_EDIT_ACL diff --git a/mayan/apps/document_acls/links.py b/mayan/apps/document_acls/links.py index 2e88554d06..31e8f3f5be 100644 --- a/mayan/apps/document_acls/links.py +++ b/mayan/apps/document_acls/links.py @@ -1,7 +1,7 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from acls.permissions import ACLS_VIEW_ACL -acl_list = {'text': _(u'ACLs'), 'view': 'document_acls:document_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} +acl_list = {'text': _('ACLs'), 'view': 'document_acls:document_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} diff --git a/mayan/apps/document_acls/urls.py b/mayan/apps/document_acls/urls.py index 6632eef295..a3ac0c4127 100644 --- a/mayan/apps/document_acls/urls.py +++ b/mayan/apps/document_acls/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('document_acls.views', diff --git a/mayan/apps/document_acls/views.py b/mayan/apps/document_acls/views.py index 99da50769c..c3bd4484a1 100644 --- a/mayan/apps/document_acls/views.py +++ b/mayan/apps/document_acls/views.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.shortcuts import get_object_or_404 from acls.views import acl_list_for diff --git a/mayan/apps/document_comments/__init__.py b/mayan/apps/document_comments/__init__.py index d8923784dc..8e5fe88561 100644 --- a/mayan/apps/document_comments/__init__.py +++ b/mayan/apps/document_comments/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.contrib.comments.models import Comment from django.contrib.contenttypes import generic @@ -11,8 +11,10 @@ from documents.models import Document from navigation.api import register_links, register_model_list_columns from .links import comment_add, comment_delete, comments_for_document -from .permissions import (PERMISSION_COMMENT_CREATE, - PERMISSION_COMMENT_DELETE, PERMISSION_COMMENT_VIEW) +from .permissions import ( + PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE, + PERMISSION_COMMENT_VIEW +) Document.add_to_class( @@ -30,15 +32,15 @@ class_permissions(Document, [PERMISSION_COMMENT_CREATE, register_model_list_columns(Comment, [ { - 'name': _(u'Date'), + 'name': _('Date'), 'attribute': 'submit_date' }, { - 'name': _(u'User'), + 'name': _('User'), 'attribute': encapsulate(lambda x: x.user.get_full_name() if x.user.get_full_name() else x.user) }, { - 'name': _(u'Comment'), + 'name': _('Comment'), 'attribute': 'comment' } ]) diff --git a/mayan/apps/document_comments/forms.py b/mayan/apps/document_comments/forms.py index 9c75121b2e..0d4d0f6d01 100644 --- a/mayan/apps/document_comments/forms.py +++ b/mayan/apps/document_comments/forms.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django import forms from django.contrib.comments.models import Comment diff --git a/mayan/apps/document_comments/links.py b/mayan/apps/document_comments/links.py index 21d1b96cd0..ededb377a5 100644 --- a/mayan/apps/document_comments/links.py +++ b/mayan/apps/document_comments/links.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals, absolute_import from django.utils.translation import ugettext_lazy as _ diff --git a/mayan/apps/document_comments/permissions.py b/mayan/apps/document_comments/permissions.py index 37e1391b61..79646c79fa 100644 --- a/mayan/apps/document_comments/permissions.py +++ b/mayan/apps/document_comments/permissions.py @@ -1,11 +1,11 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -comments_namespace = PermissionNamespace('comments', _(u'Comments')) +comments_namespace = PermissionNamespace('comments', _('Comments')) -PERMISSION_COMMENT_CREATE = Permission.objects.register(comments_namespace, 'comment_create', _(u'Create new comments')) -PERMISSION_COMMENT_DELETE = Permission.objects.register(comments_namespace, 'comment_delete', _(u'Delete comments')) -PERMISSION_COMMENT_VIEW = Permission.objects.register(comments_namespace, 'comment_view', _(u'View comments')) +PERMISSION_COMMENT_CREATE = Permission.objects.register(comments_namespace, 'comment_create', _('Create new comments')) +PERMISSION_COMMENT_DELETE = Permission.objects.register(comments_namespace, 'comment_delete', _('Delete comments')) +PERMISSION_COMMENT_VIEW = Permission.objects.register(comments_namespace, 'comment_view', _('View comments')) diff --git a/mayan/apps/document_comments/urls.py b/mayan/apps/document_comments/urls.py index 39e7fb9b31..88042839c9 100644 --- a/mayan/apps/document_comments/urls.py +++ b/mayan/apps/document_comments/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('document_comments.views', diff --git a/mayan/apps/document_comments/views.py b/mayan/apps/document_comments/views.py index 644b2c651f..f178463690 100644 --- a/mayan/apps/document_comments/views.py +++ b/mayan/apps/document_comments/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.contrib import messages from django.contrib.comments.models import Comment @@ -16,8 +16,10 @@ from documents.models import Document from permissions.models import Permission from .forms import CommentForm -from .permissions import (PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE, - PERMISSION_COMMENT_VIEW) +from .permissions import ( + PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE, + PERMISSION_COMMENT_VIEW +) def comment_delete(request, comment_id=None, comment_id_list=None): @@ -34,7 +36,7 @@ def comment_delete(request, comment_id=None, comment_id_list=None): comments = AccessEntry.objects.filter_objects_by_access(PERMISSION_COMMENT_DELETE, request.user, comments, related='content_object') if not comments: - messages.error(request, _(u'Must provide at least one comment.')) + messages.error(request, _('Must provide at least one comment.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', reverse('main:home')))) @@ -44,9 +46,9 @@ def comment_delete(request, comment_id=None, comment_id_list=None): for comment in comments: try: comment.delete() - messages.success(request, _(u'Comment "%s" deleted successfully.') % comment) + messages.success(request, _('Comment "%s" deleted successfully.') % comment) except Exception as exception: - messages.error(request, _(u'Error deleting comment "%(comment)s": %(error)s') % { + messages.error(request, _('Error deleting comment "%(comment)s": %(error)s') % { 'comment': comment, 'error': exception }) @@ -59,9 +61,9 @@ def comment_delete(request, comment_id=None, comment_id_list=None): } if len(comments) == 1: context['object'] = comments[0].content_object - context['title'] = _(u'Are you sure you wish to delete the comment: %s?') % ', '.join([unicode(d) for d in comments]) + context['title'] = _('Are you sure you wish to delete the comment: %s?') % ', '.join([unicode(d) for d in comments]) elif len(comments) > 1: - context['title'] = _(u'Are you sure you wish to delete the comments: %s?') % ', '.join([unicode(d) for d in comments]) + context['title'] = _('Are you sure you wish to delete the comments: %s?') % ', '.join([unicode(d) for d in comments]) return render_to_response('main/generic_confirm.html', context, context_instance=RequestContext(request)) @@ -95,14 +97,14 @@ def comment_add(request, document_id): comment.site = Site.objects.get_current() comment.save() - messages.success(request, _(u'Comment added successfully.')) + messages.success(request, _('Comment added successfully.')) return HttpResponseRedirect(next) else: form = CommentForm() return render_to_response('main/generic_form.html', { 'form': form, - 'title': _(u'Add comment to document'), + 'title': _('Add comment to document'), 'next': next, 'object': document, }, context_instance=RequestContext(request)) @@ -122,7 +124,7 @@ def comments_for_document(request, document_id): return render_to_response('main/generic_list.html', { 'object': document, 'access_object': document, - 'title': _(u'Document comments'), + 'title': _('Document comments'), 'object_list': Comment.objects.for_model(document).order_by('-submit_date'), 'hide_link': True, 'hide_object': True, diff --git a/mayan/apps/document_indexing/__init__.py b/mayan/apps/document_indexing/__init__.py index 3534137a8c..6d62719dd1 100644 --- a/mayan/apps/document_indexing/__init__.py +++ b/mayan/apps/document_indexing/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.db.models.signals import post_save, post_delete from django.dispatch import receiver @@ -36,7 +36,7 @@ def document_metadata_index_post_delete(sender, **kwargs): task_index_document.apply_async(kwargs=dict(document_id=kwargs['instance'].document.pk), queue='indexing') -register_maintenance_links([rebuild_index_instances], namespace='document_indexing', title=_(u'Indexes')) +register_maintenance_links([rebuild_index_instances], namespace='document_indexing', title=_('Indexes')) register_links(Document, [document_index_list], menu_name='form_header') register_links([Index, 'indexing:index_setup_list', 'indexing:index_setup_create'], [index_setup_list, index_setup_create], menu_name='secondary_menu') diff --git a/mayan/apps/document_indexing/admin.py b/mayan/apps/document_indexing/admin.py index 409bee5e34..545502b2e6 100644 --- a/mayan/apps/document_indexing/admin.py +++ b/mayan/apps/document_indexing/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin diff --git a/mayan/apps/document_indexing/api.py b/mayan/apps/document_indexing/api.py index 5f23d6d871..dc8cf12b75 100644 --- a/mayan/apps/document_indexing/api.py +++ b/mayan/apps/document_indexing/api.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -47,7 +47,7 @@ def cascade_eval(document, template_node, parent_index_instance=None): try: result = eval(template_node.expression, {'document': document}, AVAILABLE_INDEXING_FUNCTIONS) except Exception as exception: - error_message = _(u'Error indexing document: %(document)s; expression: %(expression)s; %(exception)s') % { + error_message = _('Error indexing document: %(document)s; expression: %(expression)s; %(exception)s') % { 'document': document, 'expression': template_node.expression, 'exception': exception} warnings.append(error_message) logger.debug(error_message) diff --git a/mayan/apps/document_indexing/api_views.py b/mayan/apps/document_indexing/api_views.py index 1a0ace2920..d2f5a41e9b 100644 --- a/mayan/apps/document_indexing/api_views.py +++ b/mayan/apps/document_indexing/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 diff --git a/mayan/apps/document_indexing/forms.py b/mayan/apps/document_indexing/forms.py index 4f4977f911..07c724dd54 100644 --- a/mayan/apps/document_indexing/forms.py +++ b/mayan/apps/document_indexing/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms diff --git a/mayan/apps/document_indexing/links.py b/mayan/apps/document_indexing/links.py index 98c1caaa8e..774f4037a8 100644 --- a/mayan/apps/document_indexing/links.py +++ b/mayan/apps/document_indexing/links.py @@ -1,15 +1,15 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from documents.permissions import PERMISSION_DOCUMENT_VIEW -from .permissions import (PERMISSION_DOCUMENT_INDEXING_CREATE, - PERMISSION_DOCUMENT_INDEXING_EDIT, - PERMISSION_DOCUMENT_INDEXING_DELETE, - PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES, - PERMISSION_DOCUMENT_INDEXING_SETUP, - PERMISSION_DOCUMENT_INDEXING_VIEW) +from .permissions import ( + PERMISSION_DOCUMENT_INDEXING_CREATE, PERMISSION_DOCUMENT_INDEXING_EDIT, + PERMISSION_DOCUMENT_INDEXING_DELETE, + PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES, + PERMISSION_DOCUMENT_INDEXING_SETUP, PERMISSION_DOCUMENT_INDEXING_VIEW +) def is_not_instance_root_node(context): @@ -20,23 +20,23 @@ def is_not_root_node(context): return not context['node'].is_root_node() -index_setup = {'text': _(u'Indexes'), 'view': 'indexing:index_setup_list', 'icon': 'tab.png', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} -index_setup_list = {'text': _(u'Indexes'), 'view': 'indexing:index_setup_list', 'famfam': 'tab', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} -index_setup_create = {'text': _(u'Create index'), 'view': 'indexing:index_setup_create', 'famfam': 'tab_add', 'permissions': [PERMISSION_DOCUMENT_INDEXING_CREATE]} -index_setup_edit = {'text': _(u'Edit'), 'view': 'indexing:index_setup_edit', 'args': 'index.pk', 'famfam': 'tab_edit', 'permissions': [PERMISSION_DOCUMENT_INDEXING_EDIT]} -index_setup_delete = {'text': _(u'Delete'), 'view': 'indexing:index_setup_delete', 'args': 'index.pk', 'famfam': 'tab_delete', 'permissions': [PERMISSION_DOCUMENT_INDEXING_DELETE]} -index_setup_view = {'text': _(u'Tree template'), 'view': 'indexing:index_setup_view', 'args': 'index.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} -index_setup_document_types = {'text': _(u'Document types'), 'view': 'indexing:index_setup_document_types', 'args': 'index.pk', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_INDEXING_EDIT]} +index_setup = {'text': _('Indexes'), 'view': 'indexing:index_setup_list', 'icon': 'tab.png', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} +index_setup_list = {'text': _('Indexes'), 'view': 'indexing:index_setup_list', 'famfam': 'tab', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} +index_setup_create = {'text': _('Create index'), 'view': 'indexing:index_setup_create', 'famfam': 'tab_add', 'permissions': [PERMISSION_DOCUMENT_INDEXING_CREATE]} +index_setup_edit = {'text': _('Edit'), 'view': 'indexing:index_setup_edit', 'args': 'index.pk', 'famfam': 'tab_edit', 'permissions': [PERMISSION_DOCUMENT_INDEXING_EDIT]} +index_setup_delete = {'text': _('Delete'), 'view': 'indexing:index_setup_delete', 'args': 'index.pk', 'famfam': 'tab_delete', 'permissions': [PERMISSION_DOCUMENT_INDEXING_DELETE]} +index_setup_view = {'text': _('Tree template'), 'view': 'indexing:index_setup_view', 'args': 'index.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} +index_setup_document_types = {'text': _('Document types'), 'view': 'indexing:index_setup_document_types', 'args': 'index.pk', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_INDEXING_EDIT]} -template_node_create = {'text': _(u'New child node'), 'view': 'indexing:template_node_create', 'args': 'node.pk', 'famfam': 'textfield_add', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} -template_node_edit = {'text': _(u'Edit'), 'view': 'indexing:template_node_edit', 'args': 'node.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'condition': is_not_root_node} -template_node_delete = {'text': _(u'Delete'), 'view': 'indexing:template_node_delete', 'args': 'node.pk', 'famfam': 'textfield_delete', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'condition': is_not_root_node} +template_node_create = {'text': _('New child node'), 'view': 'indexing:template_node_create', 'args': 'node.pk', 'famfam': 'textfield_add', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} +template_node_edit = {'text': _('Edit'), 'view': 'indexing:template_node_edit', 'args': 'node.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'condition': is_not_root_node} +template_node_delete = {'text': _('Delete'), 'view': 'indexing:template_node_delete', 'args': 'node.pk', 'famfam': 'textfield_delete', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'condition': is_not_root_node} -index_list = {'text': _(u'Index list'), 'view': 'indexing:index_list', 'famfam': 'tab', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW]} +index_list = {'text': _('Index list'), 'view': 'indexing:index_list', 'famfam': 'tab', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW]} -index_parent = {'text': _(u'Go up one level'), 'view': 'indexing:index_instance_node_view', 'args': 'object.parent.pk', 'famfam': 'arrow_up', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW], 'dont_mark_active': True, 'condition': is_not_instance_root_node} -document_index_list = {'text': _(u'Indexes'), 'view': 'indexing:document_index_list', 'args': 'object.pk', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW, PERMISSION_DOCUMENT_VIEW]} +index_parent = {'text': _('Go up one level'), 'view': 'indexing:index_instance_node_view', 'args': 'object.parent.pk', 'famfam': 'arrow_up', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW], 'dont_mark_active': True, 'condition': is_not_instance_root_node} +document_index_list = {'text': _('Indexes'), 'view': 'indexing:document_index_list', 'args': 'object.pk', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW, PERMISSION_DOCUMENT_VIEW]} document_index_main_menu_link = {'text': _('Indexes'), 'famfam': 'tab', 'view': 'indexing:index_list'} -rebuild_index_instances = {'text': _('Rebuild indexes'), 'view': 'indexing:rebuild_index_instances', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES], 'description': _(u'Deletes and creates from scratch all the document indexes.')} +rebuild_index_instances = {'text': _('Rebuild indexes'), 'view': 'indexing:rebuild_index_instances', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES], 'description': _('Deletes and creates from scratch all the document indexes.')} diff --git a/mayan/apps/document_indexing/managers.py b/mayan/apps/document_indexing/managers.py index 61080f5370..13dcd3b33c 100644 --- a/mayan/apps/document_indexing/managers.py +++ b/mayan/apps/document_indexing/managers.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.db import models diff --git a/mayan/apps/document_indexing/models.py b/mayan/apps/document_indexing/models.py index c47ef32e58..1a0da6fade 100644 --- a/mayan/apps/document_indexing/models.py +++ b/mayan/apps/document_indexing/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -12,11 +12,11 @@ from .managers import IndexManager class Index(models.Model): - name = models.CharField(unique=True, max_length=64, verbose_name=_(u'Name'), help_text=_(u'Internal name used to reference this index.')) + 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' - title = models.CharField(unique=True, max_length=128, verbose_name=_(u'Title'), help_text=_(u'The name that will be visible to users.')) - enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'), help_text=_(u'Causes this index to be visible and updated when document data changes.')) - document_types = models.ManyToManyField(DocumentType, verbose_name=_(u'Document types')) + title = models.CharField(unique=True, max_length=128, verbose_name=_('Title'), help_text=_('The name that will be visible to users.')) + enabled = models.BooleanField(default=True, verbose_name=_('Enabled'), help_text=_('Causes this index to be visible and updated when document data changes.')) + document_types = models.ManyToManyField(DocumentType, verbose_name=_('Document types')) objects = IndexManager() @@ -44,7 +44,7 @@ class Index(models.Model): IndexTemplateNode.objects.get_or_create(parent=None, index=self) def get_document_types_names(self): - return u', '.join([unicode(document_type) for document_type in self.document_types.all()] or [u'None']) + return ', '.join([unicode(document_type) for document_type in self.document_types.all()] or ['None']) def natural_key(self): return (self.name,) @@ -56,30 +56,30 @@ class Index(models.Model): return 0 class Meta: - verbose_name = _(u'Index') - verbose_name_plural = _(u'Indexes') + verbose_name = _('Index') + verbose_name_plural = _('Indexes') class IndexTemplateNode(MPTTModel): parent = TreeForeignKey('self', null=True, blank=True) - index = models.ForeignKey(Index, verbose_name=_(u'Index'), related_name='node_templates') - expression = models.CharField(max_length=128, verbose_name=_(u'Indexing expression'), help_text=_(u'Enter a python string expression to be evaluated.')) - enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'), help_text=_(u'Causes this node to be visible and updated when document data changes.')) - link_documents = models.BooleanField(default=False, verbose_name=_(u'Link documents'), help_text=_(u'Check this option to have this node act as a container for documents and not as a parent for further nodes.')) + index = models.ForeignKey(Index, verbose_name=_('Index'), related_name='node_templates') + expression = models.CharField(max_length=128, verbose_name=_('Indexing expression'), help_text=_('Enter a python string expression to be evaluated.')) + 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): return self.expression class Meta: - verbose_name = _(u'Index node template') - verbose_name_plural = _(u'Indexes node template') + verbose_name = _('Index node template') + verbose_name_plural = _('Indexes node template') class IndexInstanceNode(MPTTModel): parent = TreeForeignKey('self', null=True, blank=True) - index_template_node = models.ForeignKey(IndexTemplateNode, related_name='node_instance', verbose_name=_(u'Index template node')) - value = models.CharField(max_length=128, blank=True, verbose_name=_(u'Value')) - documents = models.ManyToManyField(Document, related_name='node_instances', verbose_name=_(u'Documents')) + 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): return self.value @@ -97,5 +97,5 @@ class IndexInstanceNode(MPTTModel): return self.get_children() class Meta: - verbose_name = _(u'Index node instance') - verbose_name_plural = _(u'Indexes node instances') + verbose_name = _('Index node instance') + verbose_name_plural = _('Indexes node instances') diff --git a/mayan/apps/document_indexing/permissions.py b/mayan/apps/document_indexing/permissions.py index d752e158b6..a0ecac6e45 100644 --- a/mayan/apps/document_indexing/permissions.py +++ b/mayan/apps/document_indexing/permissions.py @@ -1,15 +1,15 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -document_indexing_namespace = PermissionNamespace('document_indexing', _(u'Indexing')) +document_indexing_namespace = PermissionNamespace('document_indexing', _('Indexing')) -PERMISSION_DOCUMENT_INDEXING_SETUP = Permission.objects.register(document_indexing_namespace, 'document_index_setup', _(u'Configure document indexes')) -PERMISSION_DOCUMENT_INDEXING_CREATE = Permission.objects.register(document_indexing_namespace, 'document_index_create', _(u'Create new document indexes')) -PERMISSION_DOCUMENT_INDEXING_EDIT = Permission.objects.register(document_indexing_namespace, 'document_index_edit', _(u'Edit document indexes')) -PERMISSION_DOCUMENT_INDEXING_DELETE = Permission.objects.register(document_indexing_namespace, 'document_index_delete', _(u'Delete document indexes')) +PERMISSION_DOCUMENT_INDEXING_SETUP = Permission.objects.register(document_indexing_namespace, 'document_index_setup', _('Configure document indexes')) +PERMISSION_DOCUMENT_INDEXING_CREATE = Permission.objects.register(document_indexing_namespace, 'document_index_create', _('Create new document indexes')) +PERMISSION_DOCUMENT_INDEXING_EDIT = Permission.objects.register(document_indexing_namespace, 'document_index_edit', _('Edit document indexes')) +PERMISSION_DOCUMENT_INDEXING_DELETE = Permission.objects.register(document_indexing_namespace, 'document_index_delete', _('Delete document indexes')) -PERMISSION_DOCUMENT_INDEXING_VIEW = Permission.objects.register(document_indexing_namespace, 'document_index_view', _(u'View document indexes')) -PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES = Permission.objects.register(document_indexing_namespace, 'document_rebuild_indexes', _(u'Rebuild document indexes')) +PERMISSION_DOCUMENT_INDEXING_VIEW = Permission.objects.register(document_indexing_namespace, 'document_index_view', _('View document indexes')) +PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES = Permission.objects.register(document_indexing_namespace, 'document_rebuild_indexes', _('Rebuild document indexes')) diff --git a/mayan/apps/document_indexing/serializers.py b/mayan/apps/document_indexing/serializers.py index 25880f427e..6b73d83b63 100644 --- a/mayan/apps/document_indexing/serializers.py +++ b/mayan/apps/document_indexing/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from rest_framework import serializers diff --git a/mayan/apps/document_indexing/settings.py b/mayan/apps/document_indexing/settings.py index 891bd71039..72f51eb4a7 100644 --- a/mayan/apps/document_indexing/settings.py +++ b/mayan/apps/document_indexing/settings.py @@ -1,4 +1,4 @@ -"""Configuration options for the document_indexing app""" +from __future__ import unicode_literals from smart_settings.api import register_settings @@ -6,10 +6,10 @@ available_indexing_functions = { } register_settings( - namespace=u'document_indexing', - module=u'document_indexing.settings', + namespace='document_indexing', + module='document_indexing.settings', settings=[ # Definition - {'name': u'AVAILABLE_INDEXING_FUNCTIONS', 'global_name': u'DOCUMENT_INDEXING_AVAILABLE_INDEXING_FUNCTIONS', 'default': available_indexing_functions}, + {'name': 'AVAILABLE_INDEXING_FUNCTIONS', 'global_name': 'DOCUMENT_INDEXING_AVAILABLE_INDEXING_FUNCTIONS', 'default': available_indexing_functions}, ] ) diff --git a/mayan/apps/document_indexing/tasks.py b/mayan/apps/document_indexing/tasks.py index d0415d3622..637dddd4c8 100644 --- a/mayan/apps/document_indexing/tasks.py +++ b/mayan/apps/document_indexing/tasks.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import logging from mayan.celery import app diff --git a/mayan/apps/document_indexing/tests.py b/mayan/apps/document_indexing/tests.py index 49458682de..669c77822c 100644 --- a/mayan/apps/document_indexing/tests.py +++ b/mayan/apps/document_indexing/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.files.base import File from django.test import TestCase @@ -32,11 +32,11 @@ class IndexTestCase(TestCase): # Create simple index template root = index.template_root index.node_templates.create(parent=root, expression='document.metadata_value_of.test', link_documents=True) - self.failUnlessEqual(list(IndexTemplateNode.objects.values_list('expression', flat=True)), [u'', u'document.metadata_value_of.test']) + self.failUnlessEqual(list(IndexTemplateNode.objects.values_list('expression', flat=True)), ['', 'document.metadata_value_of.test']) # Add document metadata value to trigger index node instance creation self.document.metadata.create(metadata_type=metadata_type, value='0001') - self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u'', u'0001']) + self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), ['', '0001']) # Check that document is in instance node instance_node = IndexInstanceNode.objects.get(value='0001') @@ -46,7 +46,7 @@ class IndexTestCase(TestCase): document_metadata = self.document.metadata.get(metadata_type=metadata_type) document_metadata.value = '0002' document_metadata.save() - self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u'', u'0002']) + self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), ['', '0002']) # Check that document is in new instance node instance_node = IndexInstanceNode.objects.get(value='0002') @@ -54,12 +54,12 @@ class IndexTestCase(TestCase): # Check node instance is destoyed when no metadata is available self.document.metadata.get(metadata_type=metadata_type).delete() - self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u'']) + self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), ['']) # Add document metadata value again to trigger index node instance creation self.document.metadata.create(metadata_type=metadata_type, value='0003') - self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u'', u'0003']) + self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), ['', '0003']) # Check node instance is destroyed when no documents are contained self.document.delete() - self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u'']) + self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), ['']) diff --git a/mayan/apps/document_indexing/tools.py b/mayan/apps/document_indexing/tools.py index 71470eb25e..2cee553550 100644 --- a/mayan/apps/document_indexing/tools.py +++ b/mayan/apps/document_indexing/tools.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from documents.models import Document from .api import index_document diff --git a/mayan/apps/document_indexing/urls.py b/mayan/apps/document_indexing/urls.py index f5a44f6414..6f0460ab47 100644 --- a/mayan/apps/document_indexing/urls.py +++ b/mayan/apps/document_indexing/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url from .api_views import (APIDocumentIndexListView, diff --git a/mayan/apps/document_indexing/views.py b/mayan/apps/document_indexing/views.py index 6f7d35966e..7222ffa881 100644 --- a/mayan/apps/document_indexing/views.py +++ b/mayan/apps/document_indexing/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.contrib import messages from django.core.exceptions import PermissionDenied @@ -35,13 +35,13 @@ from .widgets import index_instance_item_link, get_breadcrumbs, node_level def index_setup_list(request): context = { - 'title': _(u'Indexes'), + 'title': _('Indexes'), 'hide_object': True, 'list_object_variable_name': 'index', 'extra_columns': [ - {'name': _(u'Name'), 'attribute': 'name'}, - {'name': _(u'Title'), 'attribute': 'title'}, - {'name': _(u'Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, + {'name': _('Name'), 'attribute': 'name'}, + {'name': _('Title'), 'attribute': 'title'}, + {'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, ] } @@ -66,13 +66,13 @@ def index_setup_create(request): if form.is_valid(): index = form.save() apply_default_acls(index, request.user) - messages.success(request, _(u'Index created successfully.')) + messages.success(request, _('Index created successfully.')) return HttpResponseRedirect(reverse('indexing:index_setup_list')) else: form = IndexForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Create index'), + 'title': _('Create index'), 'form': form, }, context_instance=RequestContext(request)) @@ -89,13 +89,13 @@ def index_setup_edit(request, index_pk): form = IndexForm(request.POST, instance=index) if form.is_valid(): form.save() - messages.success(request, _(u'Index edited successfully')) + messages.success(request, _('Index edited successfully')) return HttpResponseRedirect(reverse('indexing:index_setup_list')) else: form = IndexForm(instance=index) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit index: %s') % index, + 'title': _('Edit index: %s') % index, 'form': form, 'index': index, 'navigation_object_name': 'index', @@ -118,9 +118,9 @@ def index_setup_delete(request, index_pk): if request.method == 'POST': try: index.delete() - messages.success(request, _(u'Index: %s deleted successfully.') % index) + messages.success(request, _('Index: %s deleted successfully.') % index) except Exception as exception: - messages.error(request, _(u'Index: %(index)s delete error: %(error)s') % { + messages.error(request, _('Index: %(index)s delete error: %(error)s') % { 'index': index, 'error': exception}) return HttpResponseRedirect(next) @@ -131,7 +131,7 @@ def index_setup_delete(request, index_pk): 'delete_view': True, 'previous': previous, 'next': next, - 'title': _(u'Are you sure you with to delete the index: %s?') % index, + 'title': _('Are you sure you with to delete the index: %s?') % index, } return render_to_response('main/generic_confirm.html', context, @@ -153,12 +153,12 @@ def index_setup_view(request, index_pk): 'index': index, 'list_object_variable_name': 'node', 'navigation_object_name': 'index', - 'title': _(u'Tree template nodes for index: %s') % index, + 'title': _('Tree template nodes for index: %s') % index, 'hide_object': True, 'extra_columns': [ - {'name': _(u'Level'), 'attribute': encapsulate(lambda x: node_level(x))}, - {'name': _(u'Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, - {'name': _(u'Has document links?'), 'attribute': encapsulate(lambda x: two_state_template(x.link_documents))}, + {'name': _('Level'), 'attribute': encapsulate(lambda x: node_level(x))}, + {'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, + {'name': _('Has document links?'), 'attribute': encapsulate(lambda x: two_state_template(x.link_documents))}, ], } @@ -180,8 +180,8 @@ def index_setup_document_types(request, index_pk): right_list=lambda: generate_choices_w_labels(index.document_types.all(), display_object_type=False), add_method=lambda x: index.document_types.add(x), remove_method=lambda x: index.document_types.remove(x), - left_list_title=_(u'Document types not in index: %s') % index, - right_list_title=_(u'Document types for index: %s') % index, + left_list_title=_('Document types not in index: %s') % index, + right_list_title=_('Document types for index: %s') % index, decode_content_type=True, extra_context={ 'navigation_object_name': 'index', @@ -203,13 +203,13 @@ def template_node_create(request, parent_pk): form = IndexTemplateNodeForm(request.POST) if form.is_valid(): node = form.save() - messages.success(request, _(u'Index template node created successfully.')) + messages.success(request, _('Index template node created successfully.')) return HttpResponseRedirect(reverse('indexing:index_setup_view', args=[node.index.pk])) else: form = IndexTemplateNodeForm(initial={'index': parent_node.index, 'parent': parent_node}) return render_to_response('main/generic_form.html', { - 'title': _(u'Create child node'), + 'title': _('Create child node'), 'form': form, 'index': parent_node.index, 'navigation_object_name': 'index', @@ -228,20 +228,20 @@ def template_node_edit(request, node_pk): form = IndexTemplateNodeForm(request.POST, instance=node) if form.is_valid(): form.save() - messages.success(request, _(u'Index template node edited successfully')) + messages.success(request, _('Index template node edited successfully')) return HttpResponseRedirect(reverse('indexing:index_setup_view', args=[node.index.pk])) else: form = IndexTemplateNodeForm(instance=node) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit index template node: %s') % node, + 'title': _('Edit index template node: %s') % node, 'form': form, 'index': node.index, 'node': node, 'navigation_object_list': [ - {'object': 'index', 'name': _(u'Index')}, - {'object': 'node', 'name': _(u'Node')} + {'object': 'index', 'name': _('Index')}, + {'object': 'node', 'name': _('Node')} ], }, context_instance=RequestContext(request)) @@ -262,9 +262,9 @@ def template_node_delete(request, node_pk): if request.method == 'POST': try: node.delete() - messages.success(request, _(u'Node: %s deleted successfully.') % node) + messages.success(request, _('Node: %s deleted successfully.') % node) except Exception as exception: - messages.error(request, _(u'Node: %(node)s delete error: %(error)s') % { + messages.error(request, _('Node: %(node)s delete error: %(error)s') % { 'node': node, 'error': exception}) return HttpResponseRedirect(next) @@ -273,13 +273,13 @@ def template_node_delete(request, node_pk): 'delete_view': True, 'previous': previous, 'next': next, - 'title': _(u'Are you sure you with to delete the index template node: %s?') % node, + 'title': _('Are you sure you with to delete the index template node: %s?') % node, 'index': node.index, 'node': node, 'navigation_object_list': [ - {'object': 'index', 'name': _(u'Index')}, - {'object': 'node', 'name': _(u'Node')} + {'object': 'index', 'name': _('Index')}, + {'object': 'node', 'name': _('Node')} ], } @@ -293,11 +293,11 @@ def index_list(request): Show a list of enabled indexes """ context = { - 'title': _(u'Indexes'), + 'title': _('Indexes'), 'hide_links': True, 'extra_columns': [ - {'name': _(u'Nodes'), 'attribute': 'get_instance_node_count'}, - {'name': _(u'Document types'), 'attribute': 'get_document_types_names'}, + {'name': _('Nodes'), 'attribute': 'get_instance_node_count'}, + {'name': _('Document types'), 'attribute': 'get_document_types_names'}, ], } @@ -328,7 +328,7 @@ def index_instance_node_view(request, index_instance_node_pk): except PermissionDenied: AccessEntry.objects.check_access(PERMISSION_DOCUMENT_INDEXING_VIEW, request.user, index_instance.index) - title = mark_safe(_(u'Contents for index: %s') % breadcrumbs) + title = mark_safe(_('Contents for index: %s') % breadcrumbs) if index_instance: if index_instance.index_template_node.link_documents: @@ -346,11 +346,11 @@ def index_instance_node_view(request, index_instance_node_pk): 'object_list': index_instance_list, 'extra_columns_preffixed': [ { - 'name': _(u'Node'), + 'name': _('Node'), 'attribute': encapsulate(lambda x: index_instance_item_link(x)) }, { - 'name': _(u'Items'), + 'name': _('Items'), 'attribute': encapsulate(lambda x: x.documents.count() if x.index_template_node.link_documents else x.get_children().count()) } ], @@ -375,12 +375,12 @@ def rebuild_index_instances(request): return render_to_response('main/generic_confirm.html', { 'previous': previous, 'next': next, - 'title': _(u'Are you sure you wish to rebuild all indexes?'), - 'message': _(u'On large databases this operation may take some time to execute.'), + 'title': _('Are you sure you wish to rebuild all indexes?'), + 'message': _('On large databases this operation may take some time to execute.'), }, context_instance=RequestContext(request)) else: task_do_rebuild_all_indexes.apply_async(queue='tools') - messages.success(request, _(u'Index rebuild queued successfully.')) + messages.success(request, _('Index rebuild queued successfully.')) return HttpResponseRedirect(next) @@ -402,7 +402,7 @@ def document_index_list(request, document_id): object_list.append(get_breadcrumbs(index_instance, single_link=True, include_count=True)) return render_to_response('main/generic_list.html', { - 'title': _(u'Indexes containing this document'), + 'title': _('Indexes containing this document'), 'object_list': object_list, 'hide_link': True, 'object': document diff --git a/mayan/apps/document_indexing/widgets.py b/mayan/apps/document_indexing/widgets.py index dca33aca6e..d1723c55ee 100644 --- a/mayan/apps/document_indexing/widgets.py +++ b/mayan/apps/document_indexing/widgets.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.html import mark_safe from django.utils.translation import ugettext from .models import IndexInstanceNode -FOLDER_W_DOCUMENTS = u'folder_page' -FOLDER_ICON = u'folder' +FOLDER_W_DOCUMENTS = 'folder_page' +FOLDER_ICON = 'folder' def index_instance_item_link(index_instance_item): @@ -17,8 +17,8 @@ def index_instance_item_link(index_instance_item): else: icon = FOLDER_ICON else: - icon = u'' - icon_template = u'' % icon if icon else u'' + icon = '' + icon_template = '' % icon if icon else '' return mark_safe('%(icon_template)s%(text)s' % { 'url': index_instance_item.get_absolute_url(), 'icon_template': icon_template, @@ -34,9 +34,9 @@ def get_instance_link(index_instance_node, text=None, simple=False): if simple: # Just display the instance's value or overrided text, no # HTML anchor - template = u'%(value)s' + template = '%(value)s' else: - template = u'%(value)s' + template = '%(value)s' return template % { 'url': index_instance_node.get_absolute_url(), @@ -62,15 +62,15 @@ def get_breadcrumbs(index_instance, simple=False, single_link=False, include_cou output = [] if include_count: - output.append(u'(%d)' % index_instance.documents.count()) + output.append('(%d)' % index_instance.documents.count()) if single_link: # Return the entire breadcrumb path as a single HTML anchor - output.insert(0, get_instance_link(index_instance_node=index_instance, text=(u' / '.join(result)))) - return mark_safe(u' '.join(output)) + output.insert(0, get_instance_link(index_instance_node=index_instance, text=(' / '.join(result)))) + return mark_safe(' '.join(output)) else: - output.insert(0, u' / '.join(result)) - return mark_safe(u' '.join(output)) + output.insert(0, ' / '.join(result)) + return mark_safe(' '.join(output)) def node_level(x): @@ -78,10 +78,10 @@ def node_level(x): Render an indented tree like output for a specific node """ return mark_safe( - u''.join( + ''.join( [ - u'     ' * (getattr(x, x._mptt_meta.level_attr) - 1), - u'' if x.is_root_node() else u'î’Œ', + '     ' * (getattr(x, x._mptt_meta.level_attr) - 1), + '' if x.is_root_node() else 'î’Œ', ugettext('Root') if x.is_root_node() else unicode(x) ] ) diff --git a/mayan/apps/document_signatures/__init__.py b/mayan/apps/document_signatures/__init__.py index 3d2bf83f01..f8e92bfc5e 100644 --- a/mayan/apps/document_signatures/__init__.py +++ b/mayan/apps/document_signatures/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -13,13 +13,15 @@ from django_gpg.runtime import gpg from documents.models import Document, DocumentVersion from navigation.api import register_links -from .links import (document_signature_delete, document_signature_download, - document_signature_upload, document_verify) +from .links import ( + document_signature_delete, document_signature_download, + document_signature_upload, document_verify +) from .models import DocumentVersionSignature -from .permissions import (PERMISSION_DOCUMENT_VERIFY, - PERMISSION_SIGNATURE_DELETE, - PERMISSION_SIGNATURE_DOWNLOAD, - PERMISSION_SIGNATURE_UPLOAD) +from .permissions import ( + PERMISSION_DOCUMENT_VERIFY, PERMISSION_SIGNATURE_DELETE, + PERMISSION_SIGNATURE_DOWNLOAD, PERMISSION_SIGNATURE_UPLOAD +) logger = logging.getLogger(__name__) diff --git a/mayan/apps/document_signatures/forms.py b/mayan/apps/document_signatures/forms.py index a1bc6871ec..a79d2b1718 100644 --- a/mayan/apps/document_signatures/forms.py +++ b/mayan/apps/document_signatures/forms.py @@ -1,8 +1,10 @@ +from __future__ import unicode_literals + from django import forms from django.utils.translation import ugettext_lazy as _ class DetachedSignatureForm(forms.Form): file = forms.FileField( - label=_(u'Signature file'), + label=_('Signature file'), ) diff --git a/mayan/apps/document_signatures/links.py b/mayan/apps/document_signatures/links.py index d17022a3f6..329b1a0e50 100644 --- a/mayan/apps/document_signatures/links.py +++ b/mayan/apps/document_signatures/links.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -19,7 +19,7 @@ def doesnt_have_detached_signature(context): return DocumentVersionSignature.objects.has_detached_signature(context['object']) is False -document_signature_delete = {'text': _(u'Delete signature'), 'view': 'signatures:document_signature_delete', 'args': 'object.pk', 'famfam': 'pencil_delete', 'permissions': [PERMISSION_SIGNATURE_DELETE], 'conditional_disable': doesnt_have_detached_signature} -document_signature_download = {'text': _(u'Download signature'), 'view': 'signatures:document_signature_download', 'args': 'object.pk', 'famfam': 'disk', 'permissions': [PERMISSION_SIGNATURE_DOWNLOAD], 'conditional_disable': doesnt_have_detached_signature} -document_signature_upload = {'text': _(u'Upload signature'), 'view': 'signatures:document_signature_upload', 'args': 'object.pk', 'famfam': 'pencil_add', 'permissions': [PERMISSION_SIGNATURE_UPLOAD], 'conditional_disable': has_embedded_signature} -document_verify = {'text': _(u'Signatures'), 'view': 'signatures:document_verify', 'args': 'object.pk', 'famfam': 'text_signature', 'permissions': [PERMISSION_DOCUMENT_VERIFY]} +document_signature_delete = {'text': _('Delete signature'), 'view': 'signatures:document_signature_delete', 'args': 'object.pk', 'famfam': 'pencil_delete', 'permissions': [PERMISSION_SIGNATURE_DELETE], 'conditional_disable': doesnt_have_detached_signature} +document_signature_download = {'text': _('Download signature'), 'view': 'signatures:document_signature_download', 'args': 'object.pk', 'famfam': 'disk', 'permissions': [PERMISSION_SIGNATURE_DOWNLOAD], 'conditional_disable': doesnt_have_detached_signature} +document_signature_upload = {'text': _('Upload signature'), 'view': 'signatures:document_signature_upload', 'args': 'object.pk', 'famfam': 'pencil_add', 'permissions': [PERMISSION_SIGNATURE_UPLOAD], 'conditional_disable': has_embedded_signature} +document_verify = {'text': _('Signatures'), 'view': 'signatures:document_verify', 'args': 'object.pk', 'famfam': 'text_signature', 'permissions': [PERMISSION_DOCUMENT_VERIFY]} diff --git a/mayan/apps/document_signatures/managers.py b/mayan/apps/document_signatures/managers.py index b61e96df6e..91559e08e8 100644 --- a/mayan/apps/document_signatures/managers.py +++ b/mayan/apps/document_signatures/managers.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import logging from django.db import models diff --git a/mayan/apps/document_signatures/models.py b/mayan/apps/document_signatures/models.py index ead15e53d0..dbb16e6359 100644 --- a/mayan/apps/document_signatures/models.py +++ b/mayan/apps/document_signatures/models.py @@ -1,4 +1,5 @@ -from __future__ import absolute_import +from __future__ import unicode_literals + import logging import uuid @@ -18,9 +19,9 @@ class DocumentVersionSignature(models.Model): """ Model that describes a document version signature properties """ - document_version = models.ForeignKey(DocumentVersion, verbose_name=_(u'Document version'), editable=False) - signature_file = models.FileField(blank=True, null=True, upload_to=lambda instance, filename: unicode(uuid.uuid4()), storage=storage_backend, verbose_name=_(u'Signature file'), editable=False) - has_embedded_signature = models.BooleanField(default=False, verbose_name=_(u'Has embedded signature'), editable=False) + document_version = models.ForeignKey(DocumentVersion, verbose_name=_('Document version'), editable=False) + signature_file = models.FileField(blank=True, null=True, upload_to=lambda instance, filename: unicode(uuid.uuid4()), storage=storage_backend, verbose_name=_('Signature file'), editable=False) + has_embedded_signature = models.BooleanField(default=False, verbose_name=_('Has embedded signature'), editable=False) objects = DocumentVersionSignatureManager() @@ -35,5 +36,5 @@ class DocumentVersionSignature(models.Model): super(DocumentVersionSignature, self).save(*args, **kwargs) class Meta: - verbose_name = _(u'Document version signature') - verbose_name_plural = _(u'Document version signatures') + verbose_name = _('Document version signature') + verbose_name_plural = _('Document version signatures') diff --git a/mayan/apps/document_signatures/permissions.py b/mayan/apps/document_signatures/permissions.py index f02a6b18d2..b0d402324c 100644 --- a/mayan/apps/document_signatures/permissions.py +++ b/mayan/apps/document_signatures/permissions.py @@ -1,11 +1,11 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -document_signatures_namespace = PermissionNamespace('document_signatures', _(u'Document signatures')) -PERMISSION_DOCUMENT_VERIFY = Permission.objects.register(document_signatures_namespace, 'document_verify', _(u'Verify document signatures')) -PERMISSION_SIGNATURE_DELETE = Permission.objects.register(document_signatures_namespace, 'signature_delete', _(u'Delete detached signatures')) -PERMISSION_SIGNATURE_DOWNLOAD = Permission.objects.register(document_signatures_namespace, 'signature_download', _(u'Download detached signatures')) -PERMISSION_SIGNATURE_UPLOAD = Permission.objects.register(document_signatures_namespace, 'signature_upload', _(u'Upload detached signatures')) +document_signatures_namespace = PermissionNamespace('document_signatures', _('Document signatures')) +PERMISSION_DOCUMENT_VERIFY = Permission.objects.register(document_signatures_namespace, 'document_verify', _('Verify document signatures')) +PERMISSION_SIGNATURE_DELETE = Permission.objects.register(document_signatures_namespace, 'signature_delete', _('Delete detached signatures')) +PERMISSION_SIGNATURE_DOWNLOAD = Permission.objects.register(document_signatures_namespace, 'signature_download', _('Download detached signatures')) +PERMISSION_SIGNATURE_UPLOAD = Permission.objects.register(document_signatures_namespace, 'signature_upload', _('Upload detached signatures')) diff --git a/mayan/apps/document_signatures/tests.py b/mayan/apps/document_signatures/tests.py index bd3d9e650c..6ec2be1665 100644 --- a/mayan/apps/document_signatures/tests.py +++ b/mayan/apps/document_signatures/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os diff --git a/mayan/apps/document_signatures/urls.py b/mayan/apps/document_signatures/urls.py index c227cd1490..9996f23fe6 100644 --- a/mayan/apps/document_signatures/urls.py +++ b/mayan/apps/document_signatures/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('document_signatures.views', diff --git a/mayan/apps/document_signatures/views.py b/mayan/apps/document_signatures/views.py index e08880e080..dec04c9e66 100644 --- a/mayan/apps/document_signatures/views.py +++ b/mayan/apps/document_signatures/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from datetime import datetime import logging @@ -20,10 +20,10 @@ from permissions.models import Permission from .forms import DetachedSignatureForm from .models import DocumentVersionSignature -from .permissions import (PERMISSION_DOCUMENT_VERIFY, - PERMISSION_SIGNATURE_UPLOAD, - PERMISSION_SIGNATURE_DOWNLOAD, - PERMISSION_SIGNATURE_DELETE) +from .permissions import ( + PERMISSION_DOCUMENT_VERIFY, PERMISSION_SIGNATURE_UPLOAD, + PERMISSION_SIGNATURE_DOWNLOAD, PERMISSION_SIGNATURE_DELETE +) logger = logging.getLogger(__name__) @@ -46,29 +46,29 @@ def document_verify(request, document_pk): else: signature_state = SIGNATURE_STATES.get(getattr(signature, 'status', None)) - paragraphs = [_(u'Signature status: %s') % signature_state['text']] + paragraphs = [_('Signature status: %s') % signature_state['text']] try: if DocumentVersionSignature.objects.has_embedded_signature(document): - signature_type = _(u'Embedded') + signature_type = _('Embedded') else: - signature_type = _(u'Detached') + signature_type = _('Detached') except ValueError: - signature_type = _(u'None') + signature_type = _('None') if signature: paragraphs.extend( [ - _(u'Signature ID: %s') % signature.signature_id, - _(u'Signature type: %s') % signature_type, - _(u'Key ID: %s') % signature.key_id, - _(u'Timestamp: %s') % datetime.fromtimestamp(int(signature.sig_timestamp)), - _(u'Signee: %s') % force_escape(getattr(signature, 'username', u'')), + _('Signature ID: %s') % signature.signature_id, + _('Signature type: %s') % signature_type, + _('Key ID: %s') % signature.key_id, + _('Timestamp: %s') % datetime.fromtimestamp(int(signature.sig_timestamp)), + _('Signee: %s') % force_escape(getattr(signature, 'username', '')), ] ) return render_to_response('main/generic_template.html', { - 'title': _(u'Document signature properties'), + 'title': _('Document signature properties'), 'object': document, 'document': document, 'paragraphs': paragraphs, @@ -94,7 +94,7 @@ def document_signature_upload(request, document_pk): if form.is_valid(): try: DocumentVersionSignature.objects.add_detached_signature(document, request.FILES['file']) - messages.success(request, _(u'Detached signature uploaded successfully.')) + messages.success(request, _('Detached signature uploaded successfully.')) return HttpResponseRedirect(next) except Exception as exception: messages.error(request, exception) @@ -103,7 +103,7 @@ def document_signature_upload(request, document_pk): form = DetachedSignatureForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Upload detached signature'), + 'title': _('Upload detached signature'), 'next': next, 'form': form, 'previous': previous, @@ -125,8 +125,8 @@ def document_signature_download(request, document_pk): return serve_file( request, signature, - save_as=u'"%s.sig"' % document.filename, - content_type=u'application/octet-stream' + save_as='"%s.sig"' % document.filename, + content_type='application/octet-stream' ) except Exception as exception: messages.error(request, exception) @@ -152,14 +152,14 @@ def document_signature_delete(request, document_pk): if request.method == 'POST': try: DocumentVersionSignature.objects.clear_detached_signature(document) - messages.success(request, _(u'Detached signature deleted successfully.')) + messages.success(request, _('Detached signature deleted successfully.')) return HttpResponseRedirect(next) except Exception as exception: - messages.error(request, _(u'Error while deleting the detached signature; %s') % exception) + messages.error(request, _('Error while deleting the detached signature; %s') % exception) return HttpResponseRedirect(previous) return render_to_response('main/generic_confirm.html', { - 'title': _(u'Are you sure you wish to delete the detached signature from document: %s?') % document, + 'title': _('Are you sure you wish to delete the detached signature from document: %s?') % document, 'next': next, 'previous': previous, 'object': document, diff --git a/mayan/apps/document_states/admin.py b/mayan/apps/document_states/admin.py index 5c5a39cc7e..221b114687 100644 --- a/mayan/apps/document_states/admin.py +++ b/mayan/apps/document_states/admin.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.contrib import admin from .models import Workflow, WorkflowInstance, WorkflowState, WorkflowTransition diff --git a/mayan/apps/document_states/managers.py b/mayan/apps/document_states/managers.py index ea9ad19962..f72aba5968 100644 --- a/mayan/apps/document_states/managers.py +++ b/mayan/apps/document_states/managers.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.db import models diff --git a/mayan/apps/document_states/tests.py b/mayan/apps/document_states/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/mayan/apps/document_states/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/mayan/apps/document_states/urls.py b/mayan/apps/document_states/urls.py index 7c96c80ec2..7aae2fd723 100644 --- a/mayan/apps/document_states/urls.py +++ b/mayan/apps/document_states/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url from .views import ( diff --git a/mayan/apps/document_states/views.py b/mayan/apps/document_states/views.py index 595922936b..e98fd88460 100644 --- a/mayan/apps/document_states/views.py +++ b/mayan/apps/document_states/views.py @@ -14,9 +14,10 @@ from django.views.generic import FormView from acls.models import AccessEntry from common.utils import encapsulate, generate_choices_w_labels -from common.views import (SingleObjectCreateView, SingleObjectDeleteView, - SingleObjectEditView, SingleObjectListView, - assign_remove) +from common.views import ( + SingleObjectCreateView, SingleObjectDeleteView, SingleObjectEditView, + SingleObjectListView, assign_remove +) from common.widgets import two_state_template from documents.models import Document from permissions.models import Permission @@ -460,7 +461,7 @@ def setup_workflow_document_types(request, pk): remove_method=lambda x: workflow.document_types.remove(x), decode_content_type=True, extra_context={ - 'main_title': _(u'Document types assigned the workflow: %s') % workflow, + 'main_title': _('Document types assigned the workflow: %s') % workflow, 'object': workflow, } ) diff --git a/mayan/apps/documents/__init__.py b/mayan/apps/documents/__init__.py index 58e3e2cf20..fbcb180b24 100644 --- a/mayan/apps/documents/__init__.py +++ b/mayan/apps/documents/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import tempfile @@ -10,53 +10,45 @@ from common.utils import encapsulate, validate_path from dynamic_search.classes import SearchModel from events.permissions import PERMISSION_EVENTS_VIEW from main.api import register_maintenance_links -from navigation.api import (register_links, register_model_list_columns) +from navigation.api import register_links, register_model_list_columns from navigation.links import link_spacer from project_setup.api import register_setup from rest_api.classes import APIEndPoint from statistics.classes import StatisticNamespace from documents import settings as document_settings -from .links import (document_clear_image_cache, - document_clear_transformations, document_content, - document_delete, - document_document_type_edit, - document_events_view, - document_multiple_document_type_edit, document_download, - document_edit, document_list, - document_list_recent, document_multiple_delete, - document_multiple_clear_transformations, - document_multiple_download, - document_multiple_update_page_count, document_page_edit, - document_page_navigation_first, - document_page_navigation_last, - document_page_navigation_next, - document_page_navigation_previous, - document_page_rotate_left, document_page_rotate_right, - document_page_text, document_page_transformation_list, - document_page_transformation_create, - document_page_transformation_edit, - document_page_transformation_delete, document_page_view, - document_page_view_reset, document_page_zoom_in, - document_page_zoom_out, document_preview, document_print, - document_properties, document_type_create, - document_type_delete, document_type_edit, - document_type_filename_create, - document_type_filename_delete, document_type_filename_edit, - document_type_filename_list, document_type_list, - document_type_setup, document_update_page_count, - document_version_download, document_version_list, - document_version_revert) -from .models import (Document, DocumentPage, DocumentPageTransformation, - DocumentType, DocumentTypeFilename, DocumentVersion) -from .permissions import (PERMISSION_DOCUMENT_DELETE, - PERMISSION_DOCUMENT_DOWNLOAD, - PERMISSION_DOCUMENT_EDIT, - PERMISSION_DOCUMENT_NEW_VERSION, - PERMISSION_DOCUMENT_PROPERTIES_EDIT, - PERMISSION_DOCUMENT_TRANSFORM, - PERMISSION_DOCUMENT_VERSION_REVERT, - PERMISSION_DOCUMENT_VIEW) +from .links import ( + document_clear_image_cache, document_clear_transformations, + document_content, document_delete, document_document_type_edit, + document_events_view, document_multiple_document_type_edit, + document_download, document_edit, document_list, document_list_recent, + document_multiple_delete, document_multiple_clear_transformations, + document_multiple_download, document_multiple_update_page_count, + document_page_edit, document_page_navigation_first, + document_page_navigation_last, document_page_navigation_next, + document_page_navigation_previous, document_page_rotate_left, + document_page_rotate_right, document_page_text, + document_page_transformation_list, document_page_transformation_create, + document_page_transformation_edit, document_page_transformation_delete, + document_page_view, document_page_view_reset, document_page_zoom_in, + document_page_zoom_out, document_preview, document_print, + document_properties, document_type_create, document_type_delete, + document_type_edit, document_type_filename_create, + document_type_filename_delete, document_type_filename_edit, + document_type_filename_list, document_type_list, document_type_setup, + document_update_page_count, document_version_download, + document_version_list, document_version_revert +) +from .models import ( + Document, DocumentPage, DocumentPageTransformation, DocumentType, + DocumentTypeFilename, DocumentVersion +) +from .permissions import ( + PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, + PERMISSION_DOCUMENT_EDIT, PERMISSION_DOCUMENT_NEW_VERSION, + PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_TRANSFORM, + PERMISSION_DOCUMENT_VERSION_REVERT, PERMISSION_DOCUMENT_VIEW +) from .settings import THUMBNAIL_SIZE from .statistics import DocumentStatistics, DocumentUsageStatistics from .widgets import document_thumbnail @@ -98,14 +90,14 @@ register_links('documents:document_page_transformation_list', [document_page_tra register_links('documents:document_page_transformation_create', [document_page_transformation_create], menu_name='sidebar') register_links(['documents:document_page_transformation_edit', 'documents:document_page_transformation_delete'], [document_page_transformation_create], menu_name='sidebar') -register_maintenance_links([document_clear_image_cache], namespace='documents', title=_(u'Documents')) +register_maintenance_links([document_clear_image_cache], namespace='documents', title=_('Documents')) register_model_list_columns(Document, [ { - 'name': _(u'Thumbnail'), 'attribute': + 'name': _('Thumbnail'), 'attribute': encapsulate(lambda x: document_thumbnail(x, gallery_name='documents:document_list', title=getattr(x, 'filename', None), size=THUMBNAIL_SIZE)) }, { - 'name': _(u'Type'), 'attribute': 'document_type' + 'name': _('Type'), 'attribute': 'document_type' } ]) @@ -114,32 +106,30 @@ if (not validate_path(document_settings.CACHE_PATH)) or (not document_settings.C register_setup(document_type_setup) -class_permissions(Document, [PERMISSION_DOCUMENT_DELETE, - PERMISSION_DOCUMENT_DOWNLOAD, - PERMISSION_DOCUMENT_EDIT, - PERMISSION_DOCUMENT_NEW_VERSION, - PERMISSION_DOCUMENT_PROPERTIES_EDIT, - PERMISSION_DOCUMENT_TRANSFORM, - PERMISSION_DOCUMENT_VERSION_REVERT, - PERMISSION_DOCUMENT_VIEW, - PERMISSION_EVENTS_VIEW]) +class_permissions(Document, [ + PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, + PERMISSION_DOCUMENT_EDIT, PERMISSION_DOCUMENT_NEW_VERSION, + PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_TRANSFORM, + PERMISSION_DOCUMENT_VERSION_REVERT, PERMISSION_DOCUMENT_VIEW, + PERMISSION_EVENTS_VIEW +]) document_search = SearchModel('documents', 'Document', permission=PERMISSION_DOCUMENT_VIEW, serializer_string='documents.serializers.DocumentSerializer') # TODO: move these to their respective apps # Moving these to other apps cause an ImportError; circular import? -document_search.add_model_field('document_type__name', label=_(u'Document type')) -document_search.add_model_field('versions__mimetype', label=_(u'MIME type')) -document_search.add_model_field('label', label=_(u'Label')) -document_search.add_model_field('metadata__metadata_type__name', label=_(u'Metadata type')) -document_search.add_model_field('metadata__value', label=_(u'Metadata value')) -document_search.add_model_field('versions__pages__content', label=_(u'Content')) -document_search.add_model_field('description', label=_(u'Description')) -document_search.add_model_field('tags__label', label=_(u'Tags')) +document_search.add_model_field('document_type__name', label=_('Document type')) +document_search.add_model_field('versions__mimetype', label=_('MIME type')) +document_search.add_model_field('label', label=_('Label')) +document_search.add_model_field('metadata__metadata_type__name', label=_('Metadata type')) +document_search.add_model_field('metadata__value', label=_('Metadata value')) +document_search.add_model_field('versions__pages__content', label=_('Content')) +document_search.add_model_field('description', label=_('Description')) +document_search.add_model_field('tags__label', label=_('Tags')) -namespace = StatisticNamespace(name='documents', label=_(u'Documents')) -namespace.add_statistic(DocumentStatistics(name='document_stats', label=_(u'Document tendencies'))) -namespace.add_statistic(DocumentUsageStatistics(name='document_usage', label=_(u'Document usage'))) +namespace = StatisticNamespace(name='documents', label=_('Documents')) +namespace.add_statistic(DocumentStatistics(name='document_stats', label=_('Document tendencies'))) +namespace.add_statistic(DocumentUsageStatistics(name='document_usage', label=_('Document usage'))) APIEndPoint('documents') diff --git a/mayan/apps/documents/admin.py b/mayan/apps/documents/admin.py index 0e66dabcd5..b668763ca5 100644 --- a/mayan/apps/documents/admin.py +++ b/mayan/apps/documents/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin diff --git a/mayan/apps/documents/api_views.py b/mayan/apps/documents/api_views.py index 3a7a58cb25..0c65bf6c9c 100644 --- a/mayan/apps/documents/api_views.py +++ b/mayan/apps/documents/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # TODO: Improve API methods docstrings diff --git a/mayan/apps/documents/events.py b/mayan/apps/documents/events.py index c5f6eb6130..1e5a85a451 100644 --- a/mayan/apps/documents/events.py +++ b/mayan/apps/documents/events.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ diff --git a/mayan/apps/documents/exceptions.py b/mayan/apps/documents/exceptions.py index e3ab3eec34..b5c9c3eac6 100644 --- a/mayan/apps/documents/exceptions.py +++ b/mayan/apps/documents/exceptions.py @@ -1,3 +1,6 @@ +from __future__ import unicode_literals + + class NewDocumentVersionNotAllowed(Exception): """ Uploading new versions for this document is not allowed diff --git a/mayan/apps/documents/forms.py b/mayan/apps/documents/forms.py index c062bff69a..78e3950b0b 100644 --- a/mayan/apps/documents/forms.py +++ b/mayan/apps/documents/forms.py @@ -1,17 +1,18 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms from django.utils.encoding import force_unicode from django.utils.html import conditional_escape from django.utils.safestring import mark_safe -from django.utils.translation import ugettext_lazy as _ -from django.utils.translation import ugettext +from django.utils.translation import ugettext_lazy as _, ugettext from common.forms import DetailForm from common.widgets import TextAreaDiv -from .models import (Document, DocumentType, DocumentPage, - DocumentPageTransformation, DocumentTypeFilename) +from .models import ( + Document, DocumentType, DocumentPage, DocumentPageTransformation, + DocumentTypeFilename +) from .literals import DEFAULT_ZIP_FILENAME from .widgets import DocumentPagesCarouselWidget, DocumentPageImageWidget @@ -42,7 +43,7 @@ class DocumentPageForm(DetailForm): }) page_image = forms.CharField( - label=_(u'Page image'), widget=DocumentPageImageWidget() + label=_('Page image'), widget=DocumentPageImageWidget() ) @@ -52,7 +53,7 @@ class DocumentPageForm_text(DetailForm): fields = ('page_label', 'content') content = forms.CharField( - label=_(u'Contents'), + label=_('Contents'), widget=forms.widgets.Textarea(attrs={ 'rows': 18, 'cols': 80, 'readonly': 'readonly' })) @@ -85,9 +86,9 @@ class DocumentPreviewForm(forms.Form): super(DocumentPreviewForm, self).__init__(*args, **kwargs) self.fields['preview'].initial = document try: - self.fields['preview'].label = _(u'Document pages (%d)') % document.page_count + self.fields['preview'].label = _('Document pages (%d)') % document.page_count except AttributeError: - self.fields['preview'].label = _(u'Document pages (%d)') % 0 + self.fields['preview'].label = _('Document pages (%d)') % 0 preview = forms.CharField(widget=DocumentPagesCarouselWidget()) @@ -114,7 +115,7 @@ class DocumentForm(forms.ModelForm): self.fields['document_type_available_filenames'] = forms.ModelChoiceField( queryset=filenames_qs, required=False, - label=_(u'Quick document rename')) + label=_('Quick document rename')) class DocumentPropertiesForm(DetailForm): @@ -135,7 +136,7 @@ class DocumentContentForm(forms.Form): self.document = kwargs.pop('document', None) super(DocumentContentForm, self).__init__(*args, **kwargs) content = [] - self.fields['contents'].initial = u'' + self.fields['contents'].initial = '' try: document_pages = self.document.pages.all() except AttributeError: @@ -144,12 +145,12 @@ class DocumentContentForm(forms.Form): for page in document_pages: if page.content: content.append(conditional_escape(force_unicode(page.content))) - content.append(u'\n\n\n
- %s -

\n\n\n' % (ugettext(u'Page %(page_number)d') % {'page_number': page.page_number})) + content.append('\n\n\n
- %s -

\n\n\n' % (ugettext('Page %(page_number)d') % {'page_number': page.page_number})) - self.fields['contents'].initial = mark_safe(u''.join(content)) + self.fields['contents'].initial = mark_safe(''.join(content)) contents = forms.CharField( - label=_(u'Contents'), + label=_('Contents'), widget=TextAreaDiv() ) @@ -159,11 +160,11 @@ class DocumentTypeSelectForm(forms.Form): Form to select the document type of a document to be created, used as form #1 in the document creation wizard """ - document_type = forms.ModelChoiceField(queryset=DocumentType.objects.all(), label=(u'Document type')) + document_type = forms.ModelChoiceField(queryset=DocumentType.objects.all(), label=('Document type')) class PrintForm(forms.Form): - page_range = forms.CharField(label=_(u'Page range'), required=False) + page_range = forms.CharField(label=_('Page range'), required=False) class DocumentTypeForm(forms.ModelForm): @@ -193,8 +194,8 @@ class DocumentTypeFilenameForm_create(forms.ModelForm): class DocumentDownloadForm(forms.Form): - compressed = forms.BooleanField(label=_(u'Compress'), required=False, help_text=_(u'Download the document in the original format or in a compressed manner. This option is selectable only when downloading one document, for multiple documents, the bundle will always be downloads as a compressed file.')) - zip_filename = forms.CharField(initial=DEFAULT_ZIP_FILENAME, label=_(u'Compressed filename'), required=False, help_text=_(u'The filename of the compressed file that will contain the documents to be downloaded, if the previous option is selected.')) + compressed = forms.BooleanField(label=_('Compress'), required=False, help_text=_('Download the document in the original format or in a compressed manner. This option is selectable only when downloading one document, for multiple documents, the bundle will always be downloads as a compressed file.')) + zip_filename = forms.CharField(initial=DEFAULT_ZIP_FILENAME, label=_('Compressed filename'), required=False, help_text=_('The filename of the compressed file that will contain the documents to be downloaded, if the previous option is selected.')) def __init__(self, *args, **kwargs): self.document_versions = kwargs.pop('document_versions', None) diff --git a/mayan/apps/documents/links.py b/mayan/apps/documents/links.py index 5243442909..430f126d39 100644 --- a/mayan/apps/documents/links.py +++ b/mayan/apps/documents/links.py @@ -1,16 +1,17 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.permissions import PERMISSION_EVENTS_VIEW -from .permissions import (PERMISSION_DOCUMENT_PROPERTIES_EDIT, - PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_DELETE, - PERMISSION_DOCUMENT_DOWNLOAD, PERMISSION_DOCUMENT_TRANSFORM, - PERMISSION_DOCUMENT_TOOLS, PERMISSION_DOCUMENT_EDIT, - PERMISSION_DOCUMENT_VERSION_REVERT, PERMISSION_DOCUMENT_TYPE_EDIT, - PERMISSION_DOCUMENT_TYPE_DELETE, PERMISSION_DOCUMENT_TYPE_CREATE, - PERMISSION_DOCUMENT_TYPE_VIEW) +from .permissions import ( + PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_VIEW, + PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, + PERMISSION_DOCUMENT_TRANSFORM, PERMISSION_DOCUMENT_TOOLS, + PERMISSION_DOCUMENT_EDIT, PERMISSION_DOCUMENT_VERSION_REVERT, + PERMISSION_DOCUMENT_TYPE_EDIT, PERMISSION_DOCUMENT_TYPE_DELETE, + PERMISSION_DOCUMENT_TYPE_CREATE, PERMISSION_DOCUMENT_TYPE_VIEW +) from .settings import ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL # Document page links expressions @@ -36,60 +37,60 @@ def is_current_version(context): return context['object'].document.latest_version.timestamp == context['object'].timestamp -document_list = {'text': _(u'All documents'), 'view': 'documents:document_list', 'famfam': 'page'} -document_list_recent = {'text': _(u'Recent documents'), 'view': 'documents:document_list_recent', 'famfam': 'page'} -document_preview = {'text': _(u'Preview'), 'view': 'documents:document_preview', 'args': 'object.id', 'famfam': 'page', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_content = {'text': _(u'Content'), 'view': 'documents:document_content', 'args': 'object.id', 'famfam': 'page_white_text', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_properties = {'text': _(u'Properties'), 'view': 'documents:document_properties', 'args': 'object.id', 'famfam': 'page_gear', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_delete = {'text': _(u'Delete'), 'view': 'documents:document_delete', 'args': 'object.id', 'famfam': 'page_delete', 'permissions': [PERMISSION_DOCUMENT_DELETE]} -document_multiple_delete = {'text': _(u'Delete'), 'view': 'documents:document_multiple_delete', 'famfam': 'page_delete', 'permissions': [PERMISSION_DOCUMENT_DELETE]} -document_edit = {'text': _(u'Edit properties'), 'view': 'documents:document_edit', 'args': 'object.id', 'famfam': 'page_edit', 'permissions': [PERMISSION_DOCUMENT_PROPERTIES_EDIT]} -document_document_type_edit = {'text': _(u'Change type'), 'view': 'documents:document_document_type_edit', 'args': 'object.id', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_PROPERTIES_EDIT]} -document_multiple_document_type_edit = {'text': _(u'Change type'), 'view': 'documents:document_multiple_document_type_edit', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_PROPERTIES_EDIT]} -document_download = {'text': _(u'Download'), 'view': 'documents:document_download', 'args': 'object.id', 'famfam': 'page_save', 'permissions': [PERMISSION_DOCUMENT_DOWNLOAD]} -document_multiple_download = {'text': _(u'Download'), 'view': 'documents:document_multiple_download', 'famfam': 'page_save', 'permissions': [PERMISSION_DOCUMENT_DOWNLOAD]} -document_version_download = {'text': _(u'Download'), 'view': 'documents:document_version_download', 'args': 'object.pk', 'famfam': 'page_save', 'permissions': [PERMISSION_DOCUMENT_DOWNLOAD]} -document_update_page_count = {'text': _(u'Reset page count'), 'view': 'documents:document_update_page_count', 'args': 'object.pk', 'famfam': 'page_white_csharp', 'permissions': [PERMISSION_DOCUMENT_TOOLS]} -document_multiple_update_page_count = {'text': _(u'Reset page count'), 'view': 'documents:document_multiple_update_page_count', 'famfam': 'page_white_csharp', 'permissions': [PERMISSION_DOCUMENT_TOOLS]} -document_clear_transformations = {'text': _(u'Clear transformations'), 'view': 'documents:document_clear_transformations', 'args': 'object.id', 'famfam': 'page_paintbrush', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} -document_multiple_clear_transformations = {'text': _(u'Clear transformations'), 'view': 'documents:document_multiple_clear_transformations', 'famfam': 'page_paintbrush', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} -document_print = {'text': _(u'Print'), 'view': 'documents:document_print', 'args': 'object.id', 'famfam': 'printer', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_events_view = {'text': _(u'Events'), 'view': 'events:events_for_object', 'args': ['"documents"', '"document"', 'object.id'], 'famfam': 'book_go', 'permissions': [PERMISSION_EVENTS_VIEW]} +document_list = {'text': _('All documents'), 'view': 'documents:document_list', 'famfam': 'page'} +document_list_recent = {'text': _('Recent documents'), 'view': 'documents:document_list_recent', 'famfam': 'page'} +document_preview = {'text': _('Preview'), 'view': 'documents:document_preview', 'args': 'object.id', 'famfam': 'page', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_content = {'text': _('Content'), 'view': 'documents:document_content', 'args': 'object.id', 'famfam': 'page_white_text', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_properties = {'text': _('Properties'), 'view': 'documents:document_properties', 'args': 'object.id', 'famfam': 'page_gear', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_delete = {'text': _('Delete'), 'view': 'documents:document_delete', 'args': 'object.id', 'famfam': 'page_delete', 'permissions': [PERMISSION_DOCUMENT_DELETE]} +document_multiple_delete = {'text': _('Delete'), 'view': 'documents:document_multiple_delete', 'famfam': 'page_delete', 'permissions': [PERMISSION_DOCUMENT_DELETE]} +document_edit = {'text': _('Edit properties'), 'view': 'documents:document_edit', 'args': 'object.id', 'famfam': 'page_edit', 'permissions': [PERMISSION_DOCUMENT_PROPERTIES_EDIT]} +document_document_type_edit = {'text': _('Change type'), 'view': 'documents:document_document_type_edit', 'args': 'object.id', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_PROPERTIES_EDIT]} +document_multiple_document_type_edit = {'text': _('Change type'), 'view': 'documents:document_multiple_document_type_edit', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_PROPERTIES_EDIT]} +document_download = {'text': _('Download'), 'view': 'documents:document_download', 'args': 'object.id', 'famfam': 'page_save', 'permissions': [PERMISSION_DOCUMENT_DOWNLOAD]} +document_multiple_download = {'text': _('Download'), 'view': 'documents:document_multiple_download', 'famfam': 'page_save', 'permissions': [PERMISSION_DOCUMENT_DOWNLOAD]} +document_version_download = {'text': _('Download'), 'view': 'documents:document_version_download', 'args': 'object.pk', 'famfam': 'page_save', 'permissions': [PERMISSION_DOCUMENT_DOWNLOAD]} +document_update_page_count = {'text': _('Reset page count'), 'view': 'documents:document_update_page_count', 'args': 'object.pk', 'famfam': 'page_white_csharp', 'permissions': [PERMISSION_DOCUMENT_TOOLS]} +document_multiple_update_page_count = {'text': _('Reset page count'), 'view': 'documents:document_multiple_update_page_count', 'famfam': 'page_white_csharp', 'permissions': [PERMISSION_DOCUMENT_TOOLS]} +document_clear_transformations = {'text': _('Clear transformations'), 'view': 'documents:document_clear_transformations', 'args': 'object.id', 'famfam': 'page_paintbrush', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} +document_multiple_clear_transformations = {'text': _('Clear transformations'), 'view': 'documents:document_multiple_clear_transformations', 'famfam': 'page_paintbrush', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} +document_print = {'text': _('Print'), 'view': 'documents:document_print', 'args': 'object.id', 'famfam': 'printer', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_events_view = {'text': _('Events'), 'view': 'events:events_for_object', 'args': ['"documents"', '"document"', 'object.id'], 'famfam': 'book_go', 'permissions': [PERMISSION_EVENTS_VIEW]} # Tools -document_clear_image_cache = {'text': _(u'Clear the document image cache'), 'view': 'documents:document_clear_image_cache', 'famfam': 'camera_delete', 'permissions': [PERMISSION_DOCUMENT_TOOLS], 'description': _(u'Clear the graphics representations used to speed up the documents\' display and interactive transformations results.')} +document_clear_image_cache = {'text': _('Clear the document image cache'), 'view': 'documents:document_clear_image_cache', 'famfam': 'camera_delete', 'permissions': [PERMISSION_DOCUMENT_TOOLS], 'description': _('Clear the graphics representations used to speed up the documents\' display and interactive transformations results.')} # Document pages -document_page_transformation_list = {'text': _(u'Page transformations'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_list', 'args': 'page.pk', 'famfam': 'pencil_go', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} -document_page_transformation_create = {'text': _(u'Create new transformation'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_create', 'args': 'page.pk', 'famfam': 'pencil_add', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} -document_page_transformation_edit = {'text': _(u'Edit'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_edit', 'args': 'transformation.pk', 'famfam': 'pencil_go', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} -document_page_transformation_delete = {'text': _(u'Delete'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_delete', 'args': 'transformation.pk', 'famfam': 'pencil_delete', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} +document_page_transformation_list = {'text': _('Page transformations'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_list', 'args': 'page.pk', 'famfam': 'pencil_go', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} +document_page_transformation_create = {'text': _('Create new transformation'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_create', 'args': 'page.pk', 'famfam': 'pencil_add', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} +document_page_transformation_edit = {'text': _('Edit'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_edit', 'args': 'transformation.pk', 'famfam': 'pencil_go', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} +document_page_transformation_delete = {'text': _('Delete'), 'class': 'no-parent-history', 'view': 'documents:document_page_transformation_delete', 'args': 'transformation.pk', 'famfam': 'pencil_delete', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]} -document_page_view = {'text': _(u'Page image'), 'class': 'no-parent-history', 'view': 'documents:document_page_view', 'args': 'page.pk', 'famfam': 'page_white_picture', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_page_text = {'text': _(u'Page text'), 'class': 'no-parent-history', 'view': 'documents:document_page_text', 'args': 'page.pk', 'famfam': 'page_white_text', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_page_edit = {'text': _(u'Edit page text'), 'class': 'no-parent-history', 'view': 'documents:document_page_edit', 'args': 'page.pk', 'famfam': 'page_white_edit', 'permissions': [PERMISSION_DOCUMENT_EDIT]} -document_page_navigation_next = {'text': _(u'Next page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_next', 'args': 'page.pk', 'famfam': 'resultset_next', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_last_page, 'keep_query': True} -document_page_navigation_previous = {'text': _(u'Previous page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_previous', 'args': 'page.pk', 'famfam': 'resultset_previous', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_first_page, 'keep_query': True} -document_page_navigation_first = {'text': _(u'First page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_first', 'args': 'page.pk', 'famfam': 'resultset_first', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_first_page, 'keep_query': True} -document_page_navigation_last = {'text': _(u'Last page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_last', 'args': 'page.pk', 'famfam': 'resultset_last', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_last_page, 'keep_query': True} -document_page_zoom_in = {'text': _(u'Zoom in'), 'class': 'no-parent-history', 'view': 'documents:document_page_zoom_in', 'args': 'page.pk', 'famfam': 'zoom_in', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_max_zoom} -document_page_zoom_out = {'text': _(u'Zoom out'), 'class': 'no-parent-history', 'view': 'documents:document_page_zoom_out', 'args': 'page.pk', 'famfam': 'zoom_out', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_min_zoom} -document_page_rotate_right = {'text': _(u'Rotate right'), 'class': 'no-parent-history', 'view': 'documents:document_page_rotate_right', 'args': 'page.pk', 'famfam': 'arrow_turn_right', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_page_rotate_left = {'text': _(u'Rotate left'), 'class': 'no-parent-history', 'view': 'documents:document_page_rotate_left', 'args': 'page.pk', 'famfam': 'arrow_turn_left', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_page_view_reset = {'text': _(u'Reset view'), 'class': 'no-parent-history', 'view': 'documents:document_page_view_reset', 'args': 'page.pk', 'famfam': 'page_white', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_page_view = {'text': _('Page image'), 'class': 'no-parent-history', 'view': 'documents:document_page_view', 'args': 'page.pk', 'famfam': 'page_white_picture', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_page_text = {'text': _('Page text'), 'class': 'no-parent-history', 'view': 'documents:document_page_text', 'args': 'page.pk', 'famfam': 'page_white_text', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_page_edit = {'text': _('Edit page text'), 'class': 'no-parent-history', 'view': 'documents:document_page_edit', 'args': 'page.pk', 'famfam': 'page_white_edit', 'permissions': [PERMISSION_DOCUMENT_EDIT]} +document_page_navigation_next = {'text': _('Next page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_next', 'args': 'page.pk', 'famfam': 'resultset_next', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_last_page, 'keep_query': True} +document_page_navigation_previous = {'text': _('Previous page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_previous', 'args': 'page.pk', 'famfam': 'resultset_previous', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_first_page, 'keep_query': True} +document_page_navigation_first = {'text': _('First page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_first', 'args': 'page.pk', 'famfam': 'resultset_first', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_first_page, 'keep_query': True} +document_page_navigation_last = {'text': _('Last page'), 'class': 'no-parent-history', 'view': 'documents:document_page_navigation_last', 'args': 'page.pk', 'famfam': 'resultset_last', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_last_page, 'keep_query': True} +document_page_zoom_in = {'text': _('Zoom in'), 'class': 'no-parent-history', 'view': 'documents:document_page_zoom_in', 'args': 'page.pk', 'famfam': 'zoom_in', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_max_zoom} +document_page_zoom_out = {'text': _('Zoom out'), 'class': 'no-parent-history', 'view': 'documents:document_page_zoom_out', 'args': 'page.pk', 'famfam': 'zoom_out', 'permissions': [PERMISSION_DOCUMENT_VIEW], 'conditional_disable': is_min_zoom} +document_page_rotate_right = {'text': _('Rotate right'), 'class': 'no-parent-history', 'view': 'documents:document_page_rotate_right', 'args': 'page.pk', 'famfam': 'arrow_turn_right', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_page_rotate_left = {'text': _('Rotate left'), 'class': 'no-parent-history', 'view': 'documents:document_page_rotate_left', 'args': 'page.pk', 'famfam': 'arrow_turn_left', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_page_view_reset = {'text': _('Reset view'), 'class': 'no-parent-history', 'view': 'documents:document_page_view_reset', 'args': 'page.pk', 'famfam': 'page_white', 'permissions': [PERMISSION_DOCUMENT_VIEW]} # Document versions -document_version_list = {'text': _(u'Versions'), 'view': 'documents:document_version_list', 'args': 'object.pk', 'famfam': 'page_world', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -document_version_revert = {'text': _(u'Revert'), 'view': 'documents:document_version_revert', 'args': 'object.pk', 'famfam': 'page_refresh', 'permissions': [PERMISSION_DOCUMENT_VERSION_REVERT], 'conditional_disable': is_current_version} +document_version_list = {'text': _('Versions'), 'view': 'documents:document_version_list', 'args': 'object.pk', 'famfam': 'page_world', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_version_revert = {'text': _('Revert'), 'view': 'documents:document_version_revert', 'args': 'object.pk', 'famfam': 'page_refresh', 'permissions': [PERMISSION_DOCUMENT_VERSION_REVERT], 'conditional_disable': is_current_version} # Document type related links -document_type_list = {'text': _(u'Document types'), 'view': 'documents:document_type_list', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_TYPE_VIEW]} -document_type_setup = {'text': _(u'Document types'), 'view': 'documents:document_type_list', 'famfam': 'layout', 'icon': 'layout.png', 'permissions': [PERMISSION_DOCUMENT_TYPE_VIEW]} -document_type_edit = {'text': _(u'Edit'), 'view': 'documents:document_type_edit', 'args': 'document_type.id', 'famfam': 'layout_edit', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} -document_type_delete = {'text': _(u'Delete'), 'view': 'documents:document_type_delete', 'args': 'document_type.id', 'famfam': 'layout_delete', 'permissions': [PERMISSION_DOCUMENT_TYPE_DELETE]} -document_type_create = {'text': _(u'Create document type'), 'view': 'documents:document_type_create', 'famfam': 'layout_add', 'permissions': [PERMISSION_DOCUMENT_TYPE_CREATE]} +document_type_list = {'text': _('Document types'), 'view': 'documents:document_type_list', 'famfam': 'layout', 'permissions': [PERMISSION_DOCUMENT_TYPE_VIEW]} +document_type_setup = {'text': _('Document types'), 'view': 'documents:document_type_list', 'famfam': 'layout', 'icon': 'layout.png', 'permissions': [PERMISSION_DOCUMENT_TYPE_VIEW]} +document_type_edit = {'text': _('Edit'), 'view': 'documents:document_type_edit', 'args': 'document_type.id', 'famfam': 'layout_edit', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} +document_type_delete = {'text': _('Delete'), 'view': 'documents:document_type_delete', 'args': 'document_type.id', 'famfam': 'layout_delete', 'permissions': [PERMISSION_DOCUMENT_TYPE_DELETE]} +document_type_create = {'text': _('Create document type'), 'view': 'documents:document_type_create', 'famfam': 'layout_add', 'permissions': [PERMISSION_DOCUMENT_TYPE_CREATE]} -document_type_filename_list = {'text': _(u'Filenames'), 'view': 'documents:document_type_filename_list', 'args': 'document_type.id', 'famfam': 'database', 'permissions': [PERMISSION_DOCUMENT_TYPE_VIEW]} -document_type_filename_create = {'text': _(u'Add filename to document type'), 'view': 'documents:document_type_filename_create', 'args': 'document_type.id', 'famfam': 'database_add', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} -document_type_filename_edit = {'text': _(u'Edit'), 'view': 'documents:document_type_filename_edit', 'args': 'filename.id', 'famfam': 'database_edit', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} -document_type_filename_delete = {'text': _(u'Delete'), 'view': 'documents:document_type_filename_delete', 'args': 'filename.id', 'famfam': 'database_delete', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} +document_type_filename_list = {'text': _('Filenames'), 'view': 'documents:document_type_filename_list', 'args': 'document_type.id', 'famfam': 'database', 'permissions': [PERMISSION_DOCUMENT_TYPE_VIEW]} +document_type_filename_create = {'text': _('Add filename to document type'), 'view': 'documents:document_type_filename_create', 'args': 'document_type.id', 'famfam': 'database_add', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} +document_type_filename_edit = {'text': _('Edit'), 'view': 'documents:document_type_filename_edit', 'args': 'filename.id', 'famfam': 'database_edit', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} +document_type_filename_delete = {'text': _('Delete'), 'view': 'documents:document_type_filename_delete', 'args': 'filename.id', 'famfam': 'database_delete', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} diff --git a/mayan/apps/documents/literals.py b/mayan/apps/documents/literals.py index 81f08edae6..0d0de6b851 100644 --- a/mayan/apps/documents/literals.py +++ b/mayan/apps/documents/literals.py @@ -1,8 +1,4 @@ -PICTURE_ERROR_SMALL = u'picture_error.png' -PICTURE_ERROR_MEDIUM = u'1297211435_error.png' -PICTURE_UNKNOWN_SMALL = u'1299549572_unknown2.png' -PICTURE_UNKNOWN_MEDIUM = u'1299549805_unknown.png' - -DEFAULT_ZIP_FILENAME = u'document_bundle.zip' +from __future__ import unicode_literals +DEFAULT_ZIP_FILENAME = 'document_bundle.zip' DOCUMENT_IMAGE_TASK_TIMEOUT = 20 diff --git a/mayan/apps/documents/managers.py b/mayan/apps/documents/managers.py index 8da252f73d..351ef583d0 100644 --- a/mayan/apps/documents/managers.py +++ b/mayan/apps/documents/managers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from ast import literal_eval import logging diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index d698df3f0e..458511baf4 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from ast import literal_eval import base64 @@ -49,10 +49,10 @@ class DocumentType(models.Model): Define document types or classes to which a specific set of properties can be attached """ - name = models.CharField(max_length=32, verbose_name=_(u'Name'), unique=True) + name = models.CharField(max_length=32, verbose_name=_('Name'), unique=True) # TODO: find a way to move this to the ocr app - ocr = models.BooleanField(default=True, verbose_name=_(u'Automatically queue newly created documents for OCR.')) + ocr = models.BooleanField(default=True, verbose_name=_('Automatically queue newly created documents for OCR.')) objects = DocumentTypeManager() @@ -63,8 +63,8 @@ class DocumentType(models.Model): return (self.name,) class Meta: - verbose_name = _(u'Document type') - verbose_name_plural = _(u'Documents types') + verbose_name = _('Document type') + verbose_name_plural = _('Documents types') ordering = ['name'] @@ -74,17 +74,17 @@ class Document(models.Model): """ uuid = models.CharField(default=lambda: UUID_FUNCTION(), max_length=48, editable=False) - document_type = models.ForeignKey(DocumentType, verbose_name=_(u'Document type'), related_name='documents') + document_type = models.ForeignKey(DocumentType, verbose_name=_('Document type'), related_name='documents') label = models.CharField(max_length=255, default=_('Uninitialized document'), db_index=True, help_text=_('The name of the document'), verbose_name=_('Label')) - description = models.TextField(blank=True, null=True, verbose_name=_(u'Description')) - date_added = models.DateTimeField(verbose_name=_(u'Added'), auto_now_add=True) + description = models.TextField(blank=True, null=True, verbose_name=_('Description')) + date_added = models.DateTimeField(verbose_name=_('Added'), auto_now_add=True) language = models.CharField(choices=LANGUAGE_CHOICES, default=LANGUAGE, max_length=8, verbose_name=_('Language')) objects = DocumentManager() class Meta: - verbose_name = _(u'Document') - verbose_name_plural = _(u'Documents') + verbose_name = _('Document') + verbose_name_plural = _('Documents') ordering = ['-date_added'] def set_document_type(self, document_type, force=False): @@ -127,7 +127,7 @@ class Document(models.Model): document_version = DocumentVersion.objects.get(pk=version) document_page = document_version.pages.get(page_number=page) transformations, warnings = document_page.get_transformation_list() - hash_value = HASH_FUNCTION(u''.join([document_version.checksum, unicode(page), unicode(transformations)])) + hash_value = HASH_FUNCTION(''.join([document_version.checksum, unicode(page), unicode(transformations)])) return os.path.join(CACHE_PATH, hash_value), transformations def get_image_cache_name(self, page, version): @@ -165,7 +165,7 @@ class Document(models.Model): image = open(file_path, 'r') base64_data = base64.b64encode(image.read()) image.close() - return u'data:%s;base64,%s' % (mimetype, base64_data) + return 'data:%s;base64,%s' % (mimetype, base64_data) else: return file_path @@ -285,23 +285,23 @@ class DocumentVersion(models.Model): def register_post_save_hook(cls, order, func): cls._post_save_hooks[order] = func - document = models.ForeignKey(Document, verbose_name=_(u'Document'), related_name='versions') - timestamp = models.DateTimeField(verbose_name=_(u'Timestamp'), auto_now_add=True) - comment = models.TextField(blank=True, verbose_name=_(u'Comment')) + document = models.ForeignKey(Document, verbose_name=_('Document'), related_name='versions') + timestamp = models.DateTimeField(verbose_name=_('Timestamp'), auto_now_add=True) + comment = models.TextField(blank=True, verbose_name=_('Comment')) # File related fields - file = models.FileField(upload_to=lambda instance, filename: UUID_FUNCTION(), storage=storage_backend, verbose_name=_(u'File')) + file = models.FileField(upload_to=lambda instance, filename: UUID_FUNCTION(), storage=storage_backend, verbose_name=_('File')) mimetype = models.CharField(max_length=255, null=True, blank=True, editable=False) encoding = models.CharField(max_length=64, null=True, blank=True, editable=False) - checksum = models.TextField(blank=True, null=True, verbose_name=_(u'Checksum'), editable=False) + checksum = models.TextField(blank=True, null=True, verbose_name=_('Checksum'), editable=False) class Meta: - verbose_name = _(u'Document version') - verbose_name_plural = _(u'Document version') + verbose_name = _('Document version') + verbose_name_plural = _('Document version') def __unicode__(self): - return u'{0} - {1}'.format(self.document, self.timestamp) + return '{0} - {1}'.format(self.document, self.timestamp) def save(self, *args, **kwargs): """ @@ -353,7 +353,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(u'This document\'s file format is not known, the page count has therefore defaulted to 1.') + self.description = ugettext('This document\'s file format is not known, the page count has therefore defaulted to 1.') self.save() try: os.remove(filepath) @@ -405,8 +405,8 @@ class DocumentVersion(models.Model): try: self.mimetype, self.encoding = get_mimetype(self.open(), self.document.label) except: - self.mimetype = u'' - self.encoding = u'' + self.mimetype = '' + self.encoding = '' finally: if save: self.save() @@ -471,9 +471,9 @@ class DocumentTypeFilename(models.Model): List of filenames available to a specific document type for the quick rename functionality """ - document_type = models.ForeignKey(DocumentType, related_name='filenames', verbose_name=_(u'Document type')) - filename = models.CharField(max_length=128, verbose_name=_(u'Filename'), db_index=True) - enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled')) + document_type = models.ForeignKey(DocumentType, related_name='filenames', verbose_name=_('Document type')) + filename = models.CharField(max_length=128, verbose_name=_('Filename'), db_index=True) + enabled = models.BooleanField(default=True, verbose_name=_('Enabled')) def __unicode__(self): return self.filename @@ -481,21 +481,21 @@ class DocumentTypeFilename(models.Model): class Meta: ordering = ['filename'] unique_together = ('document_type', 'filename') - verbose_name = _(u'Document type quick rename filename') - verbose_name_plural = _(u'Document types quick rename filenames') + verbose_name = _('Document type quick rename filename') + verbose_name_plural = _('Document types quick rename filenames') class DocumentPage(models.Model): """ Model that describes a document version page including it's content """ - document_version = models.ForeignKey(DocumentVersion, verbose_name=_(u'Document version'), related_name='pages') - content = models.TextField(blank=True, null=True, verbose_name=_(u'Content')) - page_label = models.CharField(max_length=40, blank=True, null=True, verbose_name=_(u'Page label')) - page_number = models.PositiveIntegerField(default=1, editable=False, verbose_name=_(u'Page number'), db_index=True) + document_version = models.ForeignKey(DocumentVersion, verbose_name=_('Document version'), related_name='pages') + content = models.TextField(blank=True, null=True, verbose_name=_('Content')) + 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): - return _(u'Page %(page_num)d out of %(total_pages)d of %(document)s') % { + return _('Page %(page_num)d out of %(total_pages)d of %(document)s') % { 'document': unicode(self.document), 'page_num': self.page_number, 'total_pages': self.document_version.pages.count() @@ -503,8 +503,8 @@ class DocumentPage(models.Model): class Meta: ordering = ['page_number'] - verbose_name = _(u'Document page') - verbose_name_plural = _(u'Document pages') + verbose_name = _('Document page') + verbose_name_plural = _('Document pages') @models.permalink def get_absolute_url(self): @@ -521,7 +521,7 @@ class DocumentPage(models.Model): class ArgumentsValidator(object): - message = _(u'Enter a valid value.') + message = _('Enter a valid value.') code = 'invalid' def __init__(self, message=None, code=None): @@ -546,10 +546,10 @@ class DocumentPageTransformation(models.Model): Model that stores the transformation and transformation arguments for a given document page """ - document_page = models.ForeignKey(DocumentPage, verbose_name=_(u'Document page')) - order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_(u'Order'), db_index=True) - transformation = models.CharField(choices=get_available_transformations_choices(), max_length=128, verbose_name=_(u'Transformation')) - arguments = models.TextField(blank=True, null=True, verbose_name=_(u'Arguments'), help_text=_(u'Use dictionaries to indentify arguments, example: {\'degrees\':90}'), validators=[ArgumentsValidator()]) + document_page = models.ForeignKey(DocumentPage, verbose_name=_('Document page')) + order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_('Order'), db_index=True) + transformation = models.CharField(choices=get_available_transformations_choices(), max_length=128, verbose_name=_('Transformation')) + arguments = models.TextField(blank=True, null=True, verbose_name=_('Arguments'), help_text=_('Use dictionaries to indentify arguments, example: {\'degrees\':90}'), validators=[ArgumentsValidator()]) objects = DocumentPageTransformationManager() def __unicode__(self): @@ -557,8 +557,8 @@ class DocumentPageTransformation(models.Model): class Meta: ordering = ('order',) - verbose_name = _(u'Document page transformation') - verbose_name_plural = _(u'Document page transformations') + verbose_name = _('Document page transformation') + verbose_name_plural = _('Document page transformations') class RecentDocument(models.Model): @@ -566,9 +566,9 @@ class RecentDocument(models.Model): Keeps a list of the n most recent accessed or created document for a given user """ - user = models.ForeignKey(User, verbose_name=_(u'User'), editable=False) - document = models.ForeignKey(Document, verbose_name=_(u'Document'), editable=False) - datetime_accessed = models.DateTimeField(verbose_name=_(u'Accessed'), auto_now=True, db_index=True) + user = models.ForeignKey(User, verbose_name=_('User'), editable=False) + document = models.ForeignKey(Document, verbose_name=_('Document'), editable=False) + datetime_accessed = models.DateTimeField(verbose_name=_('Accessed'), auto_now=True, db_index=True) objects = RecentDocumentManager() @@ -577,8 +577,8 @@ class RecentDocument(models.Model): class Meta: ordering = ('-datetime_accessed',) - verbose_name = _(u'Recent document') - verbose_name_plural = _(u'Recent documents') + verbose_name = _('Recent document') + verbose_name_plural = _('Recent documents') # Quick hack to break the DocumentPage and DocumentPageTransformation circular dependency diff --git a/mayan/apps/documents/permissions.py b/mayan/apps/documents/permissions.py index 93d6bda51a..459d2d2d7e 100644 --- a/mayan/apps/documents/permissions.py +++ b/mayan/apps/documents/permissions.py @@ -1,25 +1,25 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -document_namespace = PermissionNamespace('documents', _(u'Documents')) +document_namespace = PermissionNamespace('documents', _('Documents')) -PERMISSION_DOCUMENT_CREATE = Permission.objects.register(document_namespace, 'document_create', _(u'Create documents')) -PERMISSION_DOCUMENT_PROPERTIES_EDIT = Permission.objects.register(document_namespace, 'document_properties_edit', _(u'Edit document properties')) -PERMISSION_DOCUMENT_EDIT = Permission.objects.register(document_namespace, 'document_edit', _(u'Edit documents')) -PERMISSION_DOCUMENT_VIEW = Permission.objects.register(document_namespace, 'document_view', _(u'View documents')) -PERMISSION_DOCUMENT_DELETE = Permission.objects.register(document_namespace, 'document_delete', _(u'Delete documents')) -PERMISSION_DOCUMENT_DOWNLOAD = Permission.objects.register(document_namespace, 'document_download', _(u'Download documents')) -PERMISSION_DOCUMENT_TRANSFORM = Permission.objects.register(document_namespace, 'document_transform', _(u'Transform documents')) -PERMISSION_DOCUMENT_TOOLS = Permission.objects.register(document_namespace, 'document_tools', _(u'Execute document modifying tools')) -PERMISSION_DOCUMENT_VERSION_REVERT = Permission.objects.register(document_namespace, 'document_version_revert', _(u'Revert documents to a previous version')) -PERMISSION_DOCUMENT_NEW_VERSION = Permission.objects.register(document_namespace, 'document_new_version', _(u'Create new document versions')) +PERMISSION_DOCUMENT_CREATE = Permission.objects.register(document_namespace, 'document_create', _('Create documents')) +PERMISSION_DOCUMENT_PROPERTIES_EDIT = Permission.objects.register(document_namespace, 'document_properties_edit', _('Edit document properties')) +PERMISSION_DOCUMENT_EDIT = Permission.objects.register(document_namespace, 'document_edit', _('Edit documents')) +PERMISSION_DOCUMENT_VIEW = Permission.objects.register(document_namespace, 'document_view', _('View documents')) +PERMISSION_DOCUMENT_DELETE = Permission.objects.register(document_namespace, 'document_delete', _('Delete documents')) +PERMISSION_DOCUMENT_DOWNLOAD = Permission.objects.register(document_namespace, 'document_download', _('Download documents')) +PERMISSION_DOCUMENT_TRANSFORM = Permission.objects.register(document_namespace, 'document_transform', _('Transform documents')) +PERMISSION_DOCUMENT_TOOLS = Permission.objects.register(document_namespace, 'document_tools', _('Execute document modifying tools')) +PERMISSION_DOCUMENT_VERSION_REVERT = Permission.objects.register(document_namespace, 'document_version_revert', _('Revert documents to a previous version')) +PERMISSION_DOCUMENT_NEW_VERSION = Permission.objects.register(document_namespace, 'document_new_version', _('Create new document versions')) -documents_setup_namespace = PermissionNamespace('documents_setup', _(u'Documents setup')) +documents_setup_namespace = PermissionNamespace('documents_setup', _('Documents setup')) -PERMISSION_DOCUMENT_TYPE_VIEW = Permission.objects.register(documents_setup_namespace, 'document_type_view', _(u'View document types')) -PERMISSION_DOCUMENT_TYPE_EDIT = Permission.objects.register(documents_setup_namespace, 'document_type_edit', _(u'Edit document types')) -PERMISSION_DOCUMENT_TYPE_DELETE = Permission.objects.register(documents_setup_namespace, 'document_type_delete', _(u'Delete document types')) -PERMISSION_DOCUMENT_TYPE_CREATE = Permission.objects.register(documents_setup_namespace, 'document_type_create', _(u'Create document types')) +PERMISSION_DOCUMENT_TYPE_VIEW = Permission.objects.register(documents_setup_namespace, 'document_type_view', _('View document types')) +PERMISSION_DOCUMENT_TYPE_EDIT = Permission.objects.register(documents_setup_namespace, 'document_type_edit', _('Edit document types')) +PERMISSION_DOCUMENT_TYPE_DELETE = Permission.objects.register(documents_setup_namespace, 'document_type_delete', _('Delete document types')) +PERMISSION_DOCUMENT_TYPE_CREATE = Permission.objects.register(documents_setup_namespace, 'document_type_create', _('Create document types')) diff --git a/mayan/apps/documents/runtime.py b/mayan/apps/documents/runtime.py index 64e654954c..b3ee09bb14 100644 --- a/mayan/apps/documents/runtime.py +++ b/mayan/apps/documents/runtime.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from common.utils import load_backend from .settings import STORAGE_BACKEND diff --git a/mayan/apps/documents/serializers.py b/mayan/apps/documents/serializers.py index b4303cb3c7..346f980973 100644 --- a/mayan/apps/documents/serializers.py +++ b/mayan/apps/documents/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from rest_framework import serializers diff --git a/mayan/apps/documents/settings.py b/mayan/apps/documents/settings.py index e93af99faa..9704339bc5 100644 --- a/mayan/apps/documents/settings.py +++ b/mayan/apps/documents/settings.py @@ -1,4 +1,4 @@ -"""Configuration options for the documents app""" +from __future__ import unicode_literals import os import pycountry @@ -11,25 +11,25 @@ from smart_settings.api import register_settings LANGUAGE_CHOICES = [(i.bibliographic, _(i.name)) for i in list(pycountry.languages)] register_settings( - namespace=u'documents', - module=u'documents.settings', + namespace='documents', + module='documents.settings', settings=[ # Storage - {'name': u'STORAGE_BACKEND', 'global_name': u'DOCUMENTS_STORAGE_BACKEND', 'default': 'storage.backends.filebasedstorage.FileBasedStorage'}, + {'name': 'STORAGE_BACKEND', 'global_name': 'DOCUMENTS_STORAGE_BACKEND', 'default': 'storage.backends.filebasedstorage.FileBasedStorage'}, # Usage - {'name': u'PREVIEW_SIZE', 'global_name': u'DOCUMENTS_PREVIEW_SIZE', 'default': u'640x480'}, - {'name': u'PRINT_SIZE', 'global_name': u'DOCUMENTS_PRINT_SIZE', 'default': u'1400'}, - {'name': u'MULTIPAGE_PREVIEW_SIZE', 'global_name': u'DOCUMENTS_MULTIPAGE_PREVIEW_SIZE', 'default': u'160x120'}, - {'name': u'THUMBNAIL_SIZE', 'global_name': u'DOCUMENTS_THUMBNAIL_SIZE', 'default': u'50x50'}, - {'name': u'DISPLAY_SIZE', 'global_name': u'DOCUMENTS_DISPLAY_SIZE', 'default': u'1200'}, - {'name': u'RECENT_COUNT', 'global_name': u'DOCUMENTS_RECENT_COUNT', 'default': 40, 'description': _(u'Maximum number of recent (created, edited, viewed) documents to remember per user.')}, - {'name': u'ZOOM_PERCENT_STEP', 'global_name': u'DOCUMENTS_ZOOM_PERCENT_STEP', 'default': 50, 'description': _(u'Amount in percent zoom in or out a document page per user interaction.')}, - {'name': u'ZOOM_MAX_LEVEL', 'global_name': u'DOCUMENTS_ZOOM_MAX_LEVEL', 'default': 200, 'description': _(u'Maximum amount in percent (%) to allow user to zoom in a document page interactively.')}, - {'name': u'ZOOM_MIN_LEVEL', 'global_name': u'DOCUMENTS_ZOOM_MIN_LEVEL', 'default': 50, 'description': _(u'Minimum amount in percent (%) to allow user to zoom out a document page interactively.')}, - {'name': u'ROTATION_STEP', 'global_name': u'DOCUMENTS_ROTATION_STEP', 'default': 90, 'description': _(u'Amount in degrees to rotate a document page per user interaction.')}, + {'name': 'PREVIEW_SIZE', 'global_name': 'DOCUMENTS_PREVIEW_SIZE', 'default': '640x480'}, + {'name': 'PRINT_SIZE', 'global_name': 'DOCUMENTS_PRINT_SIZE', 'default': '1400'}, + {'name': 'MULTIPAGE_PREVIEW_SIZE', 'global_name': 'DOCUMENTS_MULTIPAGE_PREVIEW_SIZE', 'default': '160x120'}, + {'name': 'THUMBNAIL_SIZE', 'global_name': 'DOCUMENTS_THUMBNAIL_SIZE', 'default': '50x50'}, + {'name': 'DISPLAY_SIZE', 'global_name': 'DOCUMENTS_DISPLAY_SIZE', 'default': '1200'}, + {'name': 'RECENT_COUNT', 'global_name': 'DOCUMENTS_RECENT_COUNT', 'default': 40, 'description': _('Maximum number of recent (created, edited, viewed) documents to remember per user.')}, + {'name': 'ZOOM_PERCENT_STEP', 'global_name': 'DOCUMENTS_ZOOM_PERCENT_STEP', 'default': 50, 'description': _('Amount in percent zoom in or out a document page per user interaction.')}, + {'name': 'ZOOM_MAX_LEVEL', 'global_name': 'DOCUMENTS_ZOOM_MAX_LEVEL', 'default': 200, 'description': _('Maximum amount in percent (%) to allow user to zoom in a document page interactively.')}, + {'name': 'ZOOM_MIN_LEVEL', 'global_name': 'DOCUMENTS_ZOOM_MIN_LEVEL', 'default': 50, 'description': _('Minimum amount in percent (%) to allow user to zoom out a document page interactively.')}, + {'name': 'ROTATION_STEP', 'global_name': 'DOCUMENTS_ROTATION_STEP', 'default': 90, 'description': _('Amount in degrees to rotate a document page per user interaction.')}, # - {'name': u'CACHE_PATH', 'global_name': u'DOCUMENTS_CACHE_PATH', 'default': os.path.join(settings.MEDIA_ROOT, 'image_cache'), 'exists': True}, - {'name': u'LANGUAGE', 'global_name': u'DOCUMENTS_LANGUAGE', 'default': u'eng', 'description': _('Default documents language (in ISO639-2 format).')}, - {'name': u'LANGUAGE_CHOICES', 'global_name': u'DOCUMENTS_LANGUAGE_CHOICES', 'default': LANGUAGE_CHOICES, 'description': _('List of supported document languages.')}, + {'name': 'CACHE_PATH', 'global_name': 'DOCUMENTS_CACHE_PATH', 'default': os.path.join(settings.MEDIA_ROOT, 'image_cache'), 'exists': True}, + {'name': 'LANGUAGE', 'global_name': 'DOCUMENTS_LANGUAGE', 'default': 'eng', 'description': _('Default documents language (in ISO639-2 format).')}, + {'name': 'LANGUAGE_CHOICES', 'global_name': 'DOCUMENTS_LANGUAGE_CHOICES', 'default': LANGUAGE_CHOICES, 'description': _('List of supported document languages.')}, ] ) diff --git a/mayan/apps/documents/signals.py b/mayan/apps/documents/signals.py index 664e58aded..58f7b0dd80 100644 --- a/mayan/apps/documents/signals.py +++ b/mayan/apps/documents/signals.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.dispatch import Signal post_version_upload = Signal(providing_args=['instance'], use_caching=True) diff --git a/mayan/apps/documents/statistics.py b/mayan/apps/documents/statistics.py index afc8693f4d..c8697d82ec 100644 --- a/mayan/apps/documents/statistics.py +++ b/mayan/apps/documents/statistics.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from django.db.models import Avg, Count, Min, Max @@ -21,7 +21,7 @@ def get_used_size(path, file_list): return total_size -def storage_count(path=u'.'): +def storage_count(path='.'): try: directories, files = storage_backend.listdir(path) except OSError: @@ -43,13 +43,13 @@ class DocumentStatistics(Statistic): results = [] results.extend([ - _(u'Document types: %d') % DocumentType.objects.count(), + _('Document types: %d') % DocumentType.objects.count(), ]) document_stats = DocumentVersion.objects.annotate(page_count=Count('pages')).aggregate(Min('page_count'), Max('page_count'), Avg('page_count')) results.extend([ - _(u'Minimum amount of pages per document: %d') % (document_stats['page_count__min'] or 0), - _(u'Maximum amount of pages per document: %d') % (document_stats['page_count__max'] or 0), - _(u'Average amount of pages per document: %f') % (document_stats['page_count__avg'] or 0), + _('Minimum amount of pages per document: %d') % (document_stats['page_count__min'] or 0), + _('Maximum amount of pages per document: %d') % (document_stats['page_count__max'] or 0), + _('Average amount of pages per document: %f') % (document_stats['page_count__avg'] or 0), ]) return results @@ -62,14 +62,14 @@ class DocumentUsageStatistics(Statistic): total_db_documents = Document.objects.only('pk',).count() results.extend([ - _(u'Documents in database: %d') % total_db_documents, + _('Documents in database: %d') % total_db_documents, ]) try: total_storage_documents, storage_used_space = storage_count() - results.append(_(u'Documents in storage: %d') % + results.append(_('Documents in storage: %d') % total_storage_documents) - results.append(_(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % { + results.append(_('Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % { 'base_2': pretty_size(storage_used_space), 'base_10': pretty_size_10(storage_used_space), 'bytes': storage_used_space @@ -78,7 +78,7 @@ class DocumentUsageStatistics(Statistic): pass results.extend([ - _(u'Document pages in database: %d') % DocumentPage.objects.only('pk',).count(), + _('Document pages in database: %d') % DocumentPage.objects.only('pk',).count(), ]) return results diff --git a/mayan/apps/documents/tasks.py b/mayan/apps/documents/tasks.py index 4ea60645a9..eb6d08ec1c 100644 --- a/mayan/apps/documents/tasks.py +++ b/mayan/apps/documents/tasks.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import logging from django.contrib.auth.models import User @@ -51,13 +53,13 @@ def task_new_document(document_type_id, shared_uploaded_file_id, label, descript # TODO: Report/record how was file uploaded # if result['is_compressed'] is None: - # messages.success(request, _(u'File uploaded successfully.')) + # messages.success(request, _('File uploaded successfully.')) # if result['is_compressed'] is True: - # messages.success(request, _(u'File uncompressed successfully and uploaded as individual files.')) + # messages.success(request, _('File uncompressed successfully and uploaded as individual files.')) # if result['is_compressed'] is False: - # messages.warning(request, _(u'File was not a compressed file, uploaded as it was.')) + # messages.warning(request, _('File was not a compressed file, uploaded as it was.')) @app.task(ignore_result=True) diff --git a/mayan/apps/documents/templatetags/printing_tags.py b/mayan/apps/documents/templatetags/printing_tags.py index dc0ae08827..63e5dcfdff 100644 --- a/mayan/apps/documents/templatetags/printing_tags.py +++ b/mayan/apps/documents/templatetags/printing_tags.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.template import Library, Node, Variable from converter.api import get_dimensions @@ -12,9 +14,9 @@ class GetImageSizeNode(Node): def render(self, context): document = Variable(self.document).resolve(context) width, height = get_dimensions(document) - context[u'document_width'], context['document_height'] = width, height - context[u'document_aspect'] = float(width) / float(height) - return u'' + context['document_width'], context['document_height'] = width, height + context['document_aspect'] = float(width) / float(height) + return '' @register.tag diff --git a/mayan/apps/documents/tests.py b/mayan/apps/documents/tests.py index dfacd2ad27..1c270fc033 100644 --- a/mayan/apps/documents/tests.py +++ b/mayan/apps/documents/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from json import loads import os @@ -83,7 +83,7 @@ class DocumentAPICreateDocumentTestCase(TestCase): self.assertEqual(response.status_code, status.HTTP_200_OK) # Make sure a token was returned - self.assertTrue(u'token' in response.content) + self.assertTrue('token' in response.content) token = loads(response.content)['token'] diff --git a/mayan/apps/documents/urls.py b/mayan/apps/documents/urls.py index 3a988bea96..1430ef1043 100644 --- a/mayan/apps/documents/urls.py +++ b/mayan/apps/documents/urls.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import patterns, url diff --git a/mayan/apps/documents/views.py b/mayan/apps/documents/views.py index 3d7c982b5b..bea5c567ae 100644 --- a/mayan/apps/documents/views.py +++ b/mayan/apps/documents/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging import urlparse @@ -29,28 +29,33 @@ from permissions.models import Permission from .events import ( event_document_properties_edit, event_document_type_change ) -from .forms import (DocumentContentForm, DocumentDownloadForm, DocumentForm, - DocumentPageForm, DocumentPageForm_edit, - DocumentPageForm_text, DocumentPageTransformationForm, - DocumentPreviewForm, DocumentPropertiesForm, - DocumentTypeForm, DocumentTypeFilenameForm, - DocumentTypeFilenameForm_create, DocumentTypeSelectForm, - PrintForm) +from .forms import ( + DocumentContentForm, DocumentDownloadForm, DocumentForm, DocumentPageForm, + DocumentPageForm_edit, DocumentPageForm_text, + DocumentPageTransformationForm, DocumentPreviewForm, DocumentPropertiesForm, + DocumentTypeForm, DocumentTypeFilenameForm, DocumentTypeFilenameForm_create, + DocumentTypeSelectForm, PrintForm +) from .literals import DOCUMENT_IMAGE_TASK_TIMEOUT -from .models import (Document, DocumentType, DocumentPage, - DocumentPageTransformation, DocumentTypeFilename, - DocumentVersion, RecentDocument) -from .permissions import (PERMISSION_DOCUMENT_PROPERTIES_EDIT, - PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_DELETE, - PERMISSION_DOCUMENT_DOWNLOAD, PERMISSION_DOCUMENT_TRANSFORM, - PERMISSION_DOCUMENT_TOOLS, PERMISSION_DOCUMENT_EDIT, - PERMISSION_DOCUMENT_VERSION_REVERT, PERMISSION_DOCUMENT_TYPE_EDIT, - PERMISSION_DOCUMENT_TYPE_DELETE, PERMISSION_DOCUMENT_TYPE_CREATE, - PERMISSION_DOCUMENT_TYPE_VIEW) -from .settings import (PREVIEW_SIZE, RECENT_COUNT, ROTATION_STEP, - ZOOM_PERCENT_STEP, ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL) -from .tasks import (task_clear_image_cache, task_get_document_image, - task_update_page_count) +from .models import ( + Document, DocumentType, DocumentPage, DocumentPageTransformation, + DocumentTypeFilename, DocumentVersion, RecentDocument +) +from .permissions import ( + PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_VIEW, + PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, + PERMISSION_DOCUMENT_TRANSFORM, PERMISSION_DOCUMENT_TOOLS, + PERMISSION_DOCUMENT_EDIT, PERMISSION_DOCUMENT_VERSION_REVERT, + PERMISSION_DOCUMENT_TYPE_EDIT, PERMISSION_DOCUMENT_TYPE_DELETE, + PERMISSION_DOCUMENT_TYPE_CREATE, PERMISSION_DOCUMENT_TYPE_VIEW +) +from .settings import ( + PREVIEW_SIZE, RECENT_COUNT, ROTATION_STEP, ZOOM_PERCENT_STEP, + ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL +) +from .tasks import ( + task_clear_image_cache, task_get_document_image, task_update_page_count +) logger = logging.getLogger(__name__) @@ -60,7 +65,7 @@ class DocumentListView(SingleObjectListView): object_permission = PERMISSION_DOCUMENT_VIEW extra_context = { - 'title': _(u'All documents'), + 'title': _('All documents'), 'hide_links': True, } @@ -81,7 +86,7 @@ def document_list(request, object_list=None, title=None, extra_context=None): context = { 'object_list': final_object_list, - 'title': title if title else _(u'documents'), + 'title': title if title else _('documents'), 'hide_links': True, } if extra_context: @@ -102,19 +107,19 @@ def document_properties(request, document_id): document.add_as_recent_document_for_user(request.user) document_fields = [ - {'label': _(u'Date added'), 'field': lambda x: x.date_added.date()}, - {'label': _(u'Time added'), 'field': lambda x: unicode(x.date_added.time()).split('.')[0]}, - {'label': _(u'UUID'), 'field': 'uuid'}, + {'label': _('Date added'), 'field': lambda x: x.date_added.date()}, + {'label': _('Time added'), 'field': lambda x: unicode(x.date_added.time()).split('.')[0]}, + {'label': _('UUID'), 'field': 'uuid'}, ] if document.latest_version: document_fields.extend([ - {'label': _(u'File mimetype'), 'field': lambda x: x.file_mimetype or _(u'None')}, - {'label': _(u'File encoding'), 'field': lambda x: x.file_mime_encoding or _(u'None')}, - {'label': _(u'File size'), 'field': lambda x: pretty_size(x.size) if x.size else '-'}, - {'label': _(u'Exists in storage'), 'field': 'exists'}, - {'label': _(u'File path in storage'), 'field': 'file'}, - {'label': _(u'Checksum'), 'field': 'checksum'}, - {'label': _(u'Pages'), 'field': 'page_count'}, + {'label': _('File mimetype'), 'field': lambda x: x.file_mimetype or _('None')}, + {'label': _('File encoding'), 'field': lambda x: x.file_mime_encoding or _('None')}, + {'label': _('File size'), 'field': lambda x: pretty_size(x.size) if x.size else '-'}, + {'label': _('Exists in storage'), 'field': 'exists'}, + {'label': _('File path in storage'), 'field': 'file'}, + {'label': _('Checksum'), 'field': 'checksum'}, + {'label': _('Pages'), 'field': 'page_count'}, ]) document_properties_form = DocumentPropertiesForm(instance=document, extra_fields=document_fields) @@ -123,7 +128,7 @@ def document_properties(request, document_id): 'form': document_properties_form, 'document': document, 'object': document, - 'title': _(u'Document properties'), + 'title': _('Document properties'), }, context_instance=RequestContext(request)) @@ -143,7 +148,7 @@ def document_preview(request, document_id): 'document': document, 'form': preview_form, 'object': document, - 'title': _(u'Document preview'), + 'title': _('Document preview'), }, context_instance=RequestContext(request)) @@ -163,7 +168,7 @@ def document_content(request, document_id): 'document': document, 'form': content_form, 'object': document, - 'title': _(u'Document content'), + 'title': _('Document content'), }, context_instance=RequestContext(request)) @@ -176,7 +181,7 @@ def document_delete(request, document_id=None, document_id_list=None): elif document_id_list: documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) try: @@ -191,10 +196,9 @@ def document_delete(request, document_id=None, document_id_list=None): for document in documents: try: document.delete() - # create_history(HISTORY_DOCUMENT_DELETED, data={'user': request.user, 'document': document}) - messages.success(request, _(u'Document deleted successfully.')) + messages.success(request, _('Document deleted successfully.')) except Exception as exception: - messages.error(request, _(u'Document: %(document)s delete error: %(error)s') % { + messages.error(request, _('Document: %(document)s delete error: %(error)s') % { 'document': document, 'error': exception }) @@ -207,9 +211,9 @@ def document_delete(request, document_id=None, document_id_list=None): } if len(documents) == 1: context['object'] = documents[0] - context['title'] = _(u'Are you sure you wish to delete the document: %s?') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Are you sure you wish to delete the document: %s?') % ', '.join([unicode(d) for d in documents]) elif len(documents) > 1: - context['title'] = _(u'Are you sure you wish to delete the documents: %s?') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Are you sure you wish to delete the documents: %s?') % ', '.join([unicode(d) for d in documents]) return render_to_response('main/generic_confirm.html', context, context_instance=RequestContext(request)) @@ -243,7 +247,7 @@ def document_edit(request, document_id): event_document_properties_edit.commit(actor=request.user, target=document) document.add_as_recent_document_for_user(request.user) - messages.success(request, _(u'Document "%s" edited successfully.') % document) + messages.success(request, _('Document "%s" edited successfully.') % document) return HttpResponseRedirect(document.get_absolute_url()) else: @@ -265,7 +269,7 @@ def document_document_type_edit(request, document_id=None, document_id_list=None elif document_id_list: documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) try: @@ -285,7 +289,7 @@ def document_document_type_edit(request, document_id=None, document_id_list=None event_document_type_change.commit(actor=request.user, target=document) document.add_as_recent_document_for_user(request.user) - messages.success(request, _(u'Document type changed successfully.')) + messages.success(request, _('Document type changed successfully.')) return HttpResponseRedirect(next) else: form = DocumentTypeSelectForm(initial={'document_type': documents[0].document_type}) @@ -299,9 +303,9 @@ def document_document_type_edit(request, document_id=None, document_id_list=None if len(documents) == 1: context['object'] = documents[0] - context['title'] = _(u'Are you sure you wish to change the type of the document: %s?') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Are you sure you wish to change the type of the document: %s?') % ', '.join([unicode(d) for d in documents]) elif len(documents) > 1: - context['title'] = _(u'Are you sure you wish to change the type of the documents: %s?') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Are you sure you wish to change the type of the documents: %s?') % ', '.join([unicode(d) for d in documents]) return render_to_response('main/generic_form.html', context, context_instance=RequestContext(request)) @@ -359,7 +363,7 @@ def document_download(request, document_id=None, document_id_list=None, document { 'name': 'main/generic_list_subtemplate.html', 'context': { - 'title': _(u'Documents to be downloaded'), + 'title': _('Documents to be downloaded'), 'object_list': document_versions, 'hide_link': True, 'hide_object': True, @@ -367,10 +371,10 @@ def document_download(request, document_id=None, document_id_list=None, document 'scrollable_content': True, 'scrollable_content_height': '200px', 'extra_columns': [ - {'name': _(u'Document'), 'attribute': 'document'}, - {'name': _(u'Date and time'), 'attribute': 'timestamp'}, - {'name': _(u'MIME type'), 'attribute': 'mimetype'}, - {'name': _(u'Encoding'), 'attribute': 'encoding'}, + {'name': _('Document'), 'attribute': 'document'}, + {'name': _('Date and time'), 'attribute': 'timestamp'}, + {'name': _('MIME type'), 'attribute': 'mimetype'}, + {'name': _('Encoding'), 'attribute': 'encoding'}, ], } } @@ -392,7 +396,7 @@ def document_download(request, document_id=None, document_id_list=None, document return serve_file( request, compressed_file.as_file(form.cleaned_data['zip_filename']), - save_as=u'"%s"' % form.cleaned_data['zip_filename'], + save_as='"%s"' % form.cleaned_data['zip_filename'], content_type='application/zip' ) # TODO: DO a redirection afterwards @@ -410,7 +414,7 @@ def document_download(request, document_id=None, document_id_list=None, document return serve_file( request, document_versions[0].file, - save_as=u'"%s"' % document_versions[0].document.label, + save_as='"%s"' % document_versions[0].document.label, content_type=document_versions[0].mimetype if document_versions[0].mimetype else 'application/octet-stream' ) except Exception as exception: @@ -426,10 +430,10 @@ def document_download(request, document_id=None, document_id_list=None, document context = { 'form': form, 'subtemplates_list': subtemplates_list, - 'title': _(u'Download documents'), - 'submit_label': _(u'Download'), + 'title': _('Download documents'), + 'submit_label': _('Download'), 'previous': previous, - 'cancel_label': _(u'Return'), + 'cancel_label': _('Return'), } if len(document_versions) == 1: @@ -455,7 +459,7 @@ def document_update_page_count(request, document_id=None, document_id_list=None) elif document_id_list: documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) try: @@ -472,16 +476,16 @@ def document_update_page_count(request, document_id=None, document_id_list=None) messages.success( request, ungettext( - _(u'Document queued for page count reset.'), - _(u'Documents queued for page count reset.'), + _('Document queued for page count reset.'), + _('Documents queued for page count reset.'), len(documents) ) ) return HttpResponseRedirect(previous) title = ungettext( - _(u'Are you sure you wish to reset the page count of this document?'), - _(u'Are you sure you wish to reset the page count of these documents?'), + _('Are you sure you wish to reset the page count of this document?'), + _('Are you sure you wish to reset the page count of these documents?'), len(documents) ) @@ -509,7 +513,7 @@ def document_clear_transformations(request, document_id=None, document_id_list=N documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] post_redirect = None else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) try: @@ -527,9 +531,9 @@ def document_clear_transformations(request, document_id=None, document_id_list=N document_page.document.invalidate_cached_image(document_page.page_number) for transformation in document_page.documentpagetransformation_set.all(): transformation.delete() - messages.success(request, _(u'All the page transformations for document: %s, have been deleted successfully.') % document) + messages.success(request, _('All the page transformations for document: %s, have been deleted successfully.') % document) except Exception as exception: - messages.error(request, _(u'Error deleting the page transformations for document: %(document)s; %(error)s.') % { + messages.error(request, _('Error deleting the page transformations for document: %(document)s; %(error)s.') % { 'document': document, 'error': exception}) return HttpResponseRedirect(next) @@ -542,9 +546,9 @@ def document_clear_transformations(request, document_id=None, document_id_list=N if len(documents) == 1: context['object'] = documents[0] - context['title'] = _(u'Are you sure you wish to clear all the page transformations for document: %s?') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Are you sure you wish to clear all the page transformations for document: %s?') % ', '.join([unicode(d) for d in documents]) elif len(documents) > 1: - context['title'] = _(u'Are you sure you wish to clear all the page transformations for documents: %s?') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Are you sure you wish to clear all the page transformations for documents: %s?') % ', '.join([unicode(d) for d in documents]) return render_to_response('main/generic_confirm.html', context, context_instance=RequestContext(request)) @@ -566,17 +570,17 @@ def document_page_view(request, document_page_id): rotation = int(request.GET.get('rotation', DEFAULT_ROTATION)) document_page_form = DocumentPageForm(instance=document_page, zoom=zoom, rotation=rotation) - base_title = _(u'Details for: %s') % document_page + base_title = _('Details for: %s') % document_page if zoom != DEFAULT_ZOOM_LEVEL: - zoom_text = u'(%d%%)' % zoom + zoom_text = '(%d%%)' % zoom else: - zoom_text = u'' + zoom_text = '' if rotation != 0 and rotation != 360: - rotation_text = u'(%d°)' % rotation + rotation_text = '(%d°)' % rotation else: - rotation_text = u'' + rotation_text = '' return render_to_response('main/generic_detail.html', { 'page': document_page, @@ -584,7 +588,7 @@ def document_page_view(request, document_page_id): 'navigation_object_name': 'page', 'web_theme_hide_menus': True, 'form': document_page_form, - 'title': u' '.join([base_title, zoom_text, rotation_text]), + 'title': ' '.join([base_title, zoom_text, rotation_text]), 'zoom': zoom, 'rotation': rotation, }, context_instance=RequestContext(request)) @@ -608,7 +612,7 @@ def document_page_text(request, document_page_id): 'navigation_object_name': 'page', 'web_theme_hide_menus': True, 'form': document_page_form, - 'title': _(u'Details for: %s') % document_page, + 'title': _('Details for: %s') % document_page, 'access_object': document_page.document, }, context_instance=RequestContext(request)) @@ -627,7 +631,7 @@ def document_page_edit(request, document_page_id): document_page.page_label = form.cleaned_data['page_label'] document_page.content = form.cleaned_data['content'] document_page.save() - messages.success(request, _(u'Document page edited successfully.')) + messages.success(request, _('Document page edited successfully.')) return HttpResponseRedirect(document_page.get_absolute_url()) else: form = DocumentPageForm_edit(instance=document_page) @@ -636,7 +640,7 @@ def document_page_edit(request, document_page_id): 'form': form, 'page': document_page, 'navigation_object_name': 'page', - 'title': _(u'Edit: %s') % document_page, + 'title': _('Edit: %s') % document_page, 'web_theme_hide_menus': True, 'access_object': document_page.document, }, context_instance=RequestContext(request)) @@ -653,7 +657,7 @@ def document_page_navigation_next(request, document_page_id): view = resolve_to_name(urlparse.urlparse(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))).path) if document_page.page_number >= document_page.siblings.count(): - messages.warning(request, _(u'There are no more pages in this document')) + messages.warning(request, _('There are no more pages in this document')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) else: document_page = get_object_or_404(document_page.siblings, page_number=document_page.page_number + 1) @@ -671,7 +675,7 @@ def document_page_navigation_previous(request, document_page_id): view = resolve_to_name(urlparse.urlparse(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))).path) if document_page.page_number <= 1: - messages.warning(request, _(u'You are already at the first page of this document')) + messages.warning(request, _('You are already at the first page of this document')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) else: document_page = get_object_or_404(document_page.siblings, page_number=document_page.page_number - 1) @@ -710,7 +714,7 @@ def document_list_recent(request): return document_list( request, object_list=RecentDocument.objects.get_for_user(request.user), - title=_(u'Recent documents'), + title=_('Recent documents'), extra_context={ 'recent_count': RECENT_COUNT } @@ -741,7 +745,7 @@ def transform_page(request, document_page_id, zoom_function=None, rotation_funct rotation = rotation_function(rotation) return HttpResponseRedirect( - u'?'.join([ + '?'.join([ reverse(view, args=[document_page.pk]), urlencode({'zoom': zoom, 'rotation': rotation}) ]) @@ -808,14 +812,14 @@ def document_print(request, document_id): if hard_copy_arguments: new_url.append(urlquote(hard_copy_arguments)) - new_window_url = u'?'.join(new_url) + new_window_url = '?'.join(new_url) else: form = PrintForm() return render_to_response('main/generic_form.html', { 'form': form, 'object': document, - 'title': _(u'Print: %s') % document, + 'title': _('Print: %s') % document, 'next': next, 'html_redirect': html_redirect if html_redirect else html_redirect, 'new_window_url': new_window_url if new_window_url else new_window_url @@ -833,7 +837,7 @@ def document_hard_copy(request, document_id): document.add_as_recent_document_for_user(request.user) - page_range = request.GET.get('page_range', u'') + page_range = request.GET.get('page_range', '') if page_range: page_range = parse_range(page_range) @@ -853,7 +857,7 @@ def document_type_list(request): context = { 'object_list': DocumentType.objects.all(), - 'title': _(u'Document types'), + 'title': _('Document types'), 'hide_link': True, 'list_object_variable_name': 'document_type', 'extra_columns': [ @@ -877,15 +881,15 @@ def document_type_edit(request, document_type_id): if form.is_valid(): try: form.save() - messages.success(request, _(u'Document type edited successfully')) + messages.success(request, _('Document type edited successfully')) return HttpResponseRedirect(next) except Exception as exception: - messages.error(request, _(u'Error editing document type; %s') % exception) + messages.error(request, _('Error editing document type; %s') % exception) else: form = DocumentTypeForm(instance=document_type) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit document type: %s') % document_type, + 'title': _('Edit document type: %s') % document_type, 'form': form, 'navigation_object_name': 'document_type', 'document_type': document_type, @@ -905,9 +909,9 @@ def document_type_delete(request, document_type_id): if request.method == 'POST': try: document_type.delete() - messages.success(request, _(u'Document type: %s deleted successfully.') % document_type) + messages.success(request, _('Document type: %s deleted successfully.') % document_type) except Exception as exception: - messages.error(request, _(u'Document type: %(document_type)s delete error: %(error)s') % { + messages.error(request, _('Document type: %(document_type)s delete error: %(error)s') % { 'document_type': document_type, 'error': exception}) return HttpResponseRedirect(next) @@ -918,8 +922,8 @@ def document_type_delete(request, document_type_id): 'navigation_object_name': 'document_type', 'next': next, 'previous': previous, - 'title': _(u'Are you sure you wish to delete the document type: %s?') % document_type, - 'message': _(u'All documents of this type will be deleted too.'), + 'title': _('Are you sure you wish to delete the document type: %s?') % document_type, + 'message': _('All documents of this type will be deleted too.'), } return render_to_response('main/generic_confirm.html', context, @@ -934,16 +938,16 @@ def document_type_create(request): if form.is_valid(): try: form.save() - messages.success(request, _(u'Document type created successfully')) + messages.success(request, _('Document type created successfully')) return HttpResponseRedirect(reverse('documents:document_type_list')) except Exception as exception: - messages.error(request, _(u'Error creating document type; %(error)s') % { + messages.error(request, _('Error creating document type; %(error)s') % { 'error': exception}) else: form = DocumentTypeForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Create document type'), + 'title': _('Create document type'), 'form': form, }, context_instance=RequestContext(request)) @@ -954,14 +958,14 @@ def document_type_filename_list(request, document_type_id): context = { 'object_list': document_type.filenames.all(), - 'title': _(u'Filenames for document type: %s') % document_type, + 'title': _('Filenames for document type: %s') % document_type, 'navigation_object_name': 'document_type', 'document_type': document_type, 'list_object_variable_name': 'filename', 'hide_link': True, 'extra_columns': [ { - 'name': _(u'Enabled'), + 'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled)), } ] @@ -984,15 +988,15 @@ def document_type_filename_edit(request, document_type_filename_id): document_type_filename.filename = form.cleaned_data['filename'] document_type_filename.enabled = form.cleaned_data['enabled'] document_type_filename.save() - messages.success(request, _(u'Document type filename edited successfully')) + messages.success(request, _('Document type filename edited successfully')) return HttpResponseRedirect(next) except Exception as exception: - messages.error(request, _(u'Error editing document type filename; %s') % exception) + messages.error(request, _('Error editing document type filename; %s') % exception) else: form = DocumentTypeFilenameForm(instance=document_type_filename) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit filename "%(filename)s" from document type "%(document_type)s"') % { + 'title': _('Edit filename "%(filename)s" from document type "%(document_type)s"') % { 'document_type': document_type_filename.document_type, 'filename': document_type_filename }, 'form': form, @@ -1000,8 +1004,8 @@ def document_type_filename_edit(request, document_type_filename_id): 'filename': document_type_filename, 'document_type': document_type_filename.document_type, 'navigation_object_list': [ - {'object': 'document_type', 'name': _(u'Document type')}, - {'object': 'filename', 'name': _(u'Document type filename')} + {'object': 'document_type', 'name': _('Document type')}, + {'object': 'filename', 'name': _('Document type filename')} ], }, context_instance=RequestContext(request)) @@ -1018,9 +1022,9 @@ def document_type_filename_delete(request, document_type_filename_id): if request.method == 'POST': try: document_type_filename.delete() - messages.success(request, _(u'Document type filename: %s deleted successfully.') % document_type_filename) + messages.success(request, _('Document type filename: %s deleted successfully.') % document_type_filename) except Exception as exception: - messages.error(request, _(u'Document type filename: %(document_type_filename)s delete error: %(error)s') % { + messages.error(request, _('Document type filename: %(document_type_filename)s delete error: %(error)s') % { 'document_type_filename': document_type_filename, 'error': exception}) return HttpResponseRedirect(next) @@ -1032,10 +1036,10 @@ def document_type_filename_delete(request, document_type_filename_id): 'filename': document_type_filename, 'document_type': document_type_filename.document_type, 'navigation_object_list': [ - {'object': 'document_type', 'name': _(u'Document type')}, - {'object': 'filename', 'name': _(u'Document type filename')} + {'object': 'document_type', 'name': _('Document type')}, + {'object': 'filename', 'name': _('Document type filename')} ], - 'title': _(u'Are you sure you wish to delete the filename: %(filename)s, from document type "%(document_type)s"?') % { + 'title': _('Are you sure you wish to delete the filename: %(filename)s, from document type "%(document_type)s"?') % { 'document_type': document_type_filename.document_type, 'filename': document_type_filename }, } @@ -1059,20 +1063,20 @@ def document_type_filename_create(request, document_type_id): enabled=True ) document_type_filename.save() - messages.success(request, _(u'Document type filename created successfully')) + messages.success(request, _('Document type filename created successfully')) return HttpResponseRedirect(reverse('documents:document_type_filename_list', args=[document_type_id])) except Exception as exception: - messages.error(request, _(u'Error creating document type filename; %(error)s') % { + messages.error(request, _('Error creating document type filename; %(error)s') % { 'error': exception}) else: form = DocumentTypeFilenameForm_create() return render_to_response('main/generic_form.html', { - 'title': _(u'Create filename for document type: %s') % document_type, + 'title': _('Create filename for document type: %s') % document_type, 'form': form, 'document_type': document_type, 'navigation_object_list': [ - {'object': 'document_type', 'name': _(u'Document type')}, + {'object': 'document_type', 'name': _('Document type')}, ], }, context_instance=RequestContext(request)) @@ -1084,13 +1088,13 @@ def document_clear_image_cache(request): if request.method == 'POST': task_clear_image_cache.apply_async(queue='tools') - messages.success(request, _(u'Document image cache clearing queued successfully.')) + messages.success(request, _('Document image cache clearing queued successfully.')) return HttpResponseRedirect(previous) return render_to_response('main/generic_confirm.html', { 'previous': previous, - 'title': _(u'Are you sure you wish to clear the document image cache?'), + 'title': _('Are you sure you wish to clear the document image cache?'), }, context_instance=RequestContext(request)) @@ -1106,25 +1110,25 @@ def document_version_list(request, document_pk): context = { 'object_list': document.versions.order_by('-timestamp'), - 'title': _(u'Document versions'), + 'title': _('Document versions'), 'hide_object': True, 'object': document, 'access_object': document, 'extra_columns': [ { - 'name': _(u'Time and date'), + 'name': _('Time and date'), 'attribute': 'timestamp', }, { - 'name': _(u'MIME type'), + 'name': _('MIME type'), 'attribute': 'mimetype', }, { - 'name': _(u'Encoding'), + 'name': _('Encoding'), 'attribute': 'encoding', }, { - 'name': _(u'Comment'), + 'name': _('Comment'), 'attribute': 'comment', }, ] @@ -1147,17 +1151,17 @@ def document_version_revert(request, document_version_pk): if request.method == 'POST': try: document_version.revert() - messages.success(request, _(u'Document version reverted successfully')) + messages.success(request, _('Document version reverted successfully')) except Exception as exception: - messages.error(request, _(u'Error reverting document version; %s') % exception) + messages.error(request, _('Error reverting document version; %s') % exception) return HttpResponseRedirect(previous) return render_to_response('main/generic_confirm.html', { 'previous': previous, 'object': document_version.document, - 'title': _(u'Are you sure you wish to revert to this version?'), - 'message': _(u'All later version after this one will be deleted too.'), + 'title': _('Are you sure you wish to revert to this version?'), + 'message': _('All later version after this one will be deleted too.'), }, context_instance=RequestContext(request)) @@ -1176,13 +1180,13 @@ def document_page_transformation_list(request, document_page_id): 'object_list': document_page.documentpagetransformation_set.all(), 'page': document_page, 'navigation_object_name': 'page', - 'title': _(u'Transformations for: %s') % document_page, + 'title': _('Transformations for: %s') % document_page, 'web_theme_hide_menus': True, 'list_object_variable_name': 'transformation', 'extra_columns': [ - {'name': _(u'Order'), 'attribute': 'order'}, - {'name': _(u'Transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())}, - {'name': _(u'Arguments'), 'attribute': 'arguments'} + {'name': _('Order'), 'attribute': 'order'}, + {'name': _('Transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())}, + {'name': _('Arguments'), 'attribute': 'arguments'} ], 'hide_link': True, 'hide_object': True, @@ -1205,7 +1209,7 @@ def document_page_transformation_create(request, document_page_id): if form.is_valid(): document_page.document.invalidate_cached_image(document_page.page_number) form.save() - messages.success(request, _(u'Document page transformation created successfully.')) + messages.success(request, _('Document page transformation created successfully.')) return HttpResponseRedirect(reverse('documents:document_page_transformation_list', args=[document_page_id])) else: form = DocumentPageTransformationForm(initial={'document_page': document_page}) @@ -1214,7 +1218,7 @@ def document_page_transformation_create(request, document_page_id): 'form': form, 'page': document_page, 'navigation_object_name': 'page', - 'title': _(u'Create new transformation for page: %(page)s of document: %(document)s') % { + 'title': _('Create new transformation for page: %(page)s of document: %(document)s') % { 'page': document_page.page_number, 'document': document_page.document}, 'web_theme_hide_menus': True, }, context_instance=RequestContext(request)) @@ -1233,7 +1237,7 @@ def document_page_transformation_edit(request, document_page_transformation_id): if form.is_valid(): document_page_transformation.document_page.document.invalidate_cached_image(document_page_transformation.document_page.page_number) form.save() - messages.success(request, _(u'Document page transformation edited successfully.')) + messages.success(request, _('Document page transformation edited successfully.')) return HttpResponseRedirect(reverse('documents:document_page_transformation_list', args=[document_page_transformation.document_page_id])) else: form = DocumentPageTransformationForm(instance=document_page_transformation) @@ -1244,9 +1248,9 @@ def document_page_transformation_edit(request, document_page_transformation_id): 'page': document_page_transformation.document_page, 'navigation_object_list': [ {'object': 'page'}, - {'object': 'transformation', 'name': _(u'Transformation')} + {'object': 'transformation', 'name': _('Transformation')} ], - 'title': _(u'Edit transformation "%(transformation)s" for: %(document_page)s') % { + 'title': _('Edit transformation "%(transformation)s" for: %(document_page)s') % { 'transformation': document_page_transformation.get_transformation_display(), 'document_page': document_page_transformation.document_page}, 'web_theme_hide_menus': True, @@ -1266,7 +1270,7 @@ def document_page_transformation_delete(request, document_page_transformation_id if request.method == 'POST': document_page_transformation.document_page.document.invalidate_cached_image(document_page_transformation.document_page.page_number) document_page_transformation.delete() - messages.success(request, _(u'Document page transformation deleted successfully.')) + messages.success(request, _('Document page transformation deleted successfully.')) return HttpResponseRedirect(redirect_view) return render_to_response('main/generic_confirm.html', { @@ -1275,9 +1279,9 @@ def document_page_transformation_delete(request, document_page_transformation_id 'transformation': document_page_transformation, 'navigation_object_list': [ {'object': 'page'}, - {'object': 'transformation', 'name': _(u'Transformation')} + {'object': 'transformation', 'name': _('Transformation')} ], - 'title': _(u'Are you sure you wish to delete transformation "%(transformation)s" for: %(document_page)s') % { + 'title': _('Are you sure you wish to delete transformation "%(transformation)s" for: %(document_page)s') % { 'transformation': document_page_transformation.get_transformation_display(), 'document_page': document_page_transformation.document_page}, 'web_theme_hide_menus': True, diff --git a/mayan/apps/documents/widgets.py b/mayan/apps/documents/widgets.py index 00bb0a6050..da2f5791a1 100644 --- a/mayan/apps/documents/widgets.py +++ b/mayan/apps/documents/widgets.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms from django.conf import settings @@ -25,9 +25,9 @@ class DocumentPageImageWidget(forms.widgets.Widget): output.append('
') output.append(document_html_widget(value.document, page=value.page_number, zoom=zoom, rotation=rotation, image_class='lazy-load-interactive', nolazyload=False, size=DISPLAY_SIZE)) output.append('
') - return mark_safe(u''.join(output)) + return mark_safe(''.join(output)) else: - return u'' + return '' class DocumentPagesCarouselWidget(forms.widgets.Widget): @@ -36,7 +36,7 @@ class DocumentPagesCarouselWidget(forms.widgets.Widget): """ def render(self, name, value, attrs=None): output = [] - output.append(u'') - return mark_safe(u''.join(output)) + return mark_safe(''.join(output)) def document_thumbnail(document, **kwargs): @@ -74,13 +74,13 @@ def document_thumbnail(document, **kwargs): def document_link(document): - return mark_safe(u'%s' % (document.get_absolute_url(), document)) + return mark_safe('%s' % (document.get_absolute_url(), document)) def document_html_widget(document, click_view=None, click_view_arguments=None, page=DEFAULT_PAGE_NUMBER, zoom=DEFAULT_ZOOM_LEVEL, rotation=DEFAULT_ROTATION, gallery_name=None, fancybox_class='fancybox', version=None, image_class='lazy-load', title=None, size=THUMBNAIL_SIZE, nolazyload=False, post_load_class=None): result = [] - alt_text = _(u'Document page image') + alt_text = _('Document page image') if not version: try: @@ -97,31 +97,31 @@ def document_html_widget(document, click_view=None, click_view_arguments=None, p } if gallery_name: - gallery_template = u'rel="%s"' % gallery_name + gallery_template = 'rel="%s"' % gallery_name else: - gallery_template = u'' + gallery_template = '' query_string = urlencode(query_dict) - preview_view = u'%s?%s' % (reverse('document-image', args=[document.pk]), query_string) + preview_view = '%s?%s' % (reverse('document-image', args=[document.pk]), query_string) - result.append(u'') - return mark_safe(u''.join(result)) + return mark_safe(''.join(result)) diff --git a/mayan/apps/dynamic_search/__init__.py b/mayan/apps/dynamic_search/__init__.py index a816f15a26..eec3135ea8 100644 --- a/mayan/apps/dynamic_search/__init__.py +++ b/mayan/apps/dynamic_search/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from navigation.api import register_links from rest_api.classes import APIEndPoint diff --git a/mayan/apps/dynamic_search/admin.py b/mayan/apps/dynamic_search/admin.py index fcf2e43c3b..ae944b8f80 100644 --- a/mayan/apps/dynamic_search/admin.py +++ b/mayan/apps/dynamic_search/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin diff --git a/mayan/apps/dynamic_search/api.py b/mayan/apps/dynamic_search/api.py index efe586c3d1..5af0530142 100644 --- a/mayan/apps/dynamic_search/api.py +++ b/mayan/apps/dynamic_search/api.py @@ -1,6 +1,6 @@ # original code from: # http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime import re @@ -41,11 +41,11 @@ def get_query(terms, search_fields): or_query = None for field in search_fields: if isinstance(field, types.StringTypes): - comparison = u'icontains' + comparison = 'icontains' field_name = field elif isinstance(field, types.DictType): - comparison = field.get('comparison', u'icontains') - field_name = field.get('field_name', u'') + comparison = field.get('comparison', 'icontains') + field_name = field.get('field_name', '') if field_name: q = Q(**{'%s__%s' % (field_name, comparison): term}) @@ -69,7 +69,7 @@ def perform_search(query_string, field_list=None): search_dict = {} if query_string: - simple_query_string = query_string.get('q', u'').strip() + simple_query_string = query_string.get('q', '').strip() if simple_query_string: for model, values in registered_search_dict.items(): search_dict.setdefault(values['model'], {'query_entries': [], 'title': values['title']}) diff --git a/mayan/apps/dynamic_search/api_views.py b/mayan/apps/dynamic_search/api_views.py index 7d2f082ea5..70603aff86 100644 --- a/mayan/apps/dynamic_search/api_views.py +++ b/mayan/apps/dynamic_search/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from rest_framework import generics from rest_framework.exceptions import ParseError diff --git a/mayan/apps/dynamic_search/classes.py b/mayan/apps/dynamic_search/classes.py index f0f59bae58..72f22b2112 100644 --- a/mayan/apps/dynamic_search/classes.py +++ b/mayan/apps/dynamic_search/classes.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import datetime import logging @@ -98,7 +98,7 @@ class SearchModel(object): search_dict[search_field.get_model()]['searches'].append( { 'field_name': [search_field.field], - 'terms': self.normalize_query(query_string.get('q', u'').strip()) + 'terms': self.normalize_query(query_string.get('q', '').strip()) } ) else: diff --git a/mayan/apps/dynamic_search/forms.py b/mayan/apps/dynamic_search/forms.py index a09756e0e1..c5da1eb4e5 100644 --- a/mayan/apps/dynamic_search/forms.py +++ b/mayan/apps/dynamic_search/forms.py @@ -1,11 +1,11 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms from django.utils.translation import ugettext_lazy as _ class SearchForm(forms.Form): - q = forms.CharField(max_length=128, label=_(u'Search terms')) + q = forms.CharField(max_length=128, label=_('Search terms')) source = forms.CharField( max_length=32, required=False, diff --git a/mayan/apps/dynamic_search/links.py b/mayan/apps/dynamic_search/links.py index 0e0fd09984..23e57d9ce1 100644 --- a/mayan/apps/dynamic_search/links.py +++ b/mayan/apps/dynamic_search/links.py @@ -1,5 +1,7 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ -search = {'text': _(u'Search'), 'view': 'search:search', 'famfam': 'zoom'} -search_advanced = {'text': _(u'Advanced search'), 'view': 'search:search_advanced', 'famfam': 'zoom_in'} -search_again = {'text': _(u'Search again'), 'view': 'search:search_again', 'famfam': 'arrow_undo'} +search = {'text': _('Search'), 'view': 'search:search', 'famfam': 'zoom'} +search_advanced = {'text': _('Advanced search'), 'view': 'search:search_advanced', 'famfam': 'zoom_in'} +search_again = {'text': _('Search again'), 'view': 'search:search_again', 'famfam': 'arrow_undo'} diff --git a/mayan/apps/dynamic_search/managers.py b/mayan/apps/dynamic_search/managers.py index f295b64e03..6df88790fa 100644 --- a/mayan/apps/dynamic_search/managers.py +++ b/mayan/apps/dynamic_search/managers.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import urlparse from django.contrib.auth.models import AnonymousUser diff --git a/mayan/apps/dynamic_search/models.py b/mayan/apps/dynamic_search/models.py index f58641e962..bddca5e547 100644 --- a/mayan/apps/dynamic_search/models.py +++ b/mayan/apps/dynamic_search/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import urllib import urlparse @@ -16,15 +16,15 @@ class RecentSearch(models.Model): """ Keeps a list of the n most recent search keywords for a given user """ - user = models.ForeignKey(User, verbose_name=_(u'User'), editable=True) + user = models.ForeignKey(User, verbose_name=_('User'), editable=True) # Setting editable to True to workaround Django REST framework issue # 1604 - https://github.com/tomchristie/django-rest-framework/issues/1604 # Should be fixed by DRF v2.4.4 # TODO: Fix after upgrade to DRF v2.4.4 - query = models.TextField(verbose_name=_(u'Query'), editable=False) - datetime_created = models.DateTimeField(verbose_name=_(u'Datetime created'), auto_now=True, db_index=True) - hits = models.IntegerField(verbose_name=_(u'Hits'), editable=False) + query = models.TextField(verbose_name=_('Query'), editable=False) + datetime_created = models.DateTimeField(verbose_name=_('Datetime created'), auto_now=True, db_index=True) + hits = models.IntegerField(verbose_name=_('Hits'), editable=False) objects = RecentSearchManager() @@ -40,14 +40,14 @@ class RecentSearch(models.Model): advanced_string = [] for key, value in query_dict.items(): search_field = document_search.get_search_field(key) - advanced_string.append(u'%s: %s' % (search_field.label, smart_unicode(' '.join(value)))) + advanced_string.append('%s: %s' % (search_field.label, smart_unicode(' '.join(value)))) - display_string = u', '.join(advanced_string) + display_string = ', '.join(advanced_string) else: # Is a simple search display_string = smart_unicode(' '.join(query_dict['q'])) - return u'%s (%s)' % (display_string, self.hits) + return '%s (%s)' % (display_string, self.hits) def save(self, *args, **kwargs): super(RecentSearch, self).save(*args, **kwargs) @@ -61,5 +61,5 @@ class RecentSearch(models.Model): class Meta: ordering = ('-datetime_created',) - verbose_name = _(u'Recent search') - verbose_name_plural = _(u'Recent searches') + verbose_name = _('Recent search') + verbose_name_plural = _('Recent searches') diff --git a/mayan/apps/dynamic_search/serializers.py b/mayan/apps/dynamic_search/serializers.py index 5d778047a9..e2ed8d09ce 100644 --- a/mayan/apps/dynamic_search/serializers.py +++ b/mayan/apps/dynamic_search/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from rest_framework import serializers diff --git a/mayan/apps/dynamic_search/settings.py b/mayan/apps/dynamic_search/settings.py index fd06e80d31..f4f1d151d7 100644 --- a/mayan/apps/dynamic_search/settings.py +++ b/mayan/apps/dynamic_search/settings.py @@ -1,15 +1,15 @@ -"""Configuration options for the dynamic_search app""" +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from smart_settings.api import register_settings register_settings( - namespace=u'dynamic_search', - module=u'dynamic_search.settings', + namespace='dynamic_search', + module='dynamic_search.settings', settings=[ - {'name': u'SHOW_OBJECT_TYPE', 'global_name': u'SEARCH_SHOW_OBJECT_TYPE', 'default': True, 'hidden': True}, - {'name': u'LIMIT', 'global_name': u'SEARCH_LIMIT', 'default': 100, 'description': _(u'Maximum amount search hits to fetch and display.')}, - {'name': u'RECENT_COUNT', 'global_name': u'SEARCH_RECENT_COUNT', 'default': 5, 'description': _(u'Maximum number of search queries to remember per user.')}, + {'name': 'SHOW_OBJECT_TYPE', 'global_name': 'SEARCH_SHOW_OBJECT_TYPE', 'default': True, 'hidden': True}, + {'name': 'LIMIT', 'global_name': 'SEARCH_LIMIT', 'default': 100, 'description': _('Maximum amount search hits to fetch and display.')}, + {'name': 'RECENT_COUNT', 'global_name': 'SEARCH_RECENT_COUNT', 'default': 5, 'description': _('Maximum number of search queries to remember per user.')}, ] ) diff --git a/mayan/apps/dynamic_search/templatetags/search_tags.py b/mayan/apps/dynamic_search/templatetags/search_tags.py index 5ae869b176..ac9eff9cc1 100644 --- a/mayan/apps/dynamic_search/templatetags/search_tags.py +++ b/mayan/apps/dynamic_search/templatetags/search_tags.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.core.urlresolvers import reverse from django.template import Library from django.utils.translation import ugettext as _ @@ -16,8 +18,8 @@ def search_form(context): 'request': context['request'], 'STATIC_URL': context['STATIC_URL'], 'form_action': reverse('search'), - 'form_title': _(u'Search'), - 'submit_label': _(u'Search'), + 'form_title': _('Search'), + 'submit_label': _('Search'), 'submit_icon_famfam': 'zoom', }) return context @@ -34,9 +36,9 @@ def recent_searches_template(context): 'request': context['request'], 'STATIC_URL': context['STATIC_URL'], 'side_bar': True, - 'title': _(u'Recent searches (maximum of %d)') % RECENT_COUNT, + 'title': _('Recent searches (maximum of %d)') % RECENT_COUNT, 'paragraphs': [ - u'%(text)s' % { + '%(text)s' % { 'text': rs, 'url': rs.url(), 'icon': 'zoom_in' if rs.is_advanced() else 'zoom', diff --git a/mayan/apps/dynamic_search/tests.py b/mayan/apps/dynamic_search/tests.py index 8a9f7aed60..9cebe6f292 100644 --- a/mayan/apps/dynamic_search/tests.py +++ b/mayan/apps/dynamic_search/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os diff --git a/mayan/apps/dynamic_search/urls.py b/mayan/apps/dynamic_search/urls.py index dcb42c8ff5..0455acbefa 100644 --- a/mayan/apps/dynamic_search/urls.py +++ b/mayan/apps/dynamic_search/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url from .api_views import (APIRecentSearchListView, APIRecentSearchView, diff --git a/mayan/apps/dynamic_search/views.py b/mayan/apps/dynamic_search/views.py index c0b266b8c6..55c106d425 100644 --- a/mayan/apps/dynamic_search/views.py +++ b/mayan/apps/dynamic_search/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging import urlparse @@ -35,7 +35,7 @@ def results(request, extra_context=None): context.update({ 'object_list': queryset, 'time_delta': timedelta, - 'title': _(u'Results'), + 'title': _('Results'), }) if extra_context: @@ -43,7 +43,7 @@ def results(request, extra_context=None): if SHOW_OBJECT_TYPE: context.update({ - 'extra_columns': [{'name': _(u'Type'), 'attribute': lambda x: x._meta.verbose_name[0].upper() + x._meta.verbose_name[1:]}] + 'extra_columns': [{'name': _('Type'), 'attribute': lambda x: x._meta.verbose_name[0].upper() + x._meta.verbose_name[1:]}] }) return render_to_response('search_results.html', context, @@ -59,19 +59,19 @@ def search(request, advanced=False): 'main/generic_form.html', { 'form': form, - 'title': _(u'Advanced search'), + 'title': _('Advanced search'), 'form_action': reverse('search:results'), 'submit_method': 'GET', 'search_results_limit': LIMIT, - 'submit_label': _(u'Search'), + 'submit_label': _('Search'), 'submit_icon_famfam': 'zoom', }, context_instance=RequestContext(request) ) else: extra_context = { - 'submit_label': _(u'Search'), + 'submit_label': _('Search'), 'submit_icon_famfam': 'zoom', - 'form_title': _(u'Search'), + 'form_title': _('Search'), 'form_hide_required_text': True, } if ('q' in request.GET) and request.GET['q'].strip(): diff --git a/mayan/apps/events/__init__.py b/mayan/apps/events/__init__.py index 41c3555ac6..f3e35f2e05 100644 --- a/mayan/apps/events/__init__.py +++ b/mayan/apps/events/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from project_tools.api import register_tool diff --git a/mayan/apps/events/admin.py b/mayan/apps/events/admin.py index d3a218665d..56fbd9403f 100644 --- a/mayan/apps/events/admin.py +++ b/mayan/apps/events/admin.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.contrib import admin from .models import EventType diff --git a/mayan/apps/events/classes.py b/mayan/apps/events/classes.py index 38366dc37b..dd47b4c5ac 100644 --- a/mayan/apps/events/classes.py +++ b/mayan/apps/events/classes.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals from django.db import models from django.utils.translation import ugettext as _ diff --git a/mayan/apps/events/models.py b/mayan/apps/events/models.py index 75ee75c1a9..9d14be45de 100644 --- a/mayan/apps/events/models.py +++ b/mayan/apps/events/models.py @@ -35,7 +35,7 @@ register_model_list_columns(Action, [ 'attribute': 'actor', }, { - 'name': _(u'Verb'), + 'name': _('Verb'), 'attribute': encapsulate(lambda entry: event_type_link(entry)) }, ]) diff --git a/mayan/apps/events/urls.py b/mayan/apps/events/urls.py index e2c247db5c..5d7d9ceb0d 100644 --- a/mayan/apps/events/urls.py +++ b/mayan/apps/events/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('events.views', diff --git a/mayan/apps/folders/__init__.py b/mayan/apps/folders/__init__.py index cdd59fb576..0e6ccde80a 100644 --- a/mayan/apps/folders/__init__.py +++ b/mayan/apps/folders/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -6,21 +6,24 @@ from acls.api import class_permissions from acls.permissions import ACLS_EDIT_ACL, ACLS_VIEW_ACL from common.utils import encapsulate from documents.models import Document -from navigation.api import (register_links, register_model_list_columns, - register_top_menu) +from navigation.api import ( + register_links, register_model_list_columns, register_top_menu +) from navigation.links import link_spacer from rest_api.classes import APIEndPoint -from .links import (document_folder_list, folder_acl_list, - folder_add_document, folder_add_multiple_documents, - folder_create, folder_delete, - folder_document_multiple_remove, folder_edit, folder_list, - folder_view, folders_main_menu_link) +from .links import ( + document_folder_list, folder_acl_list, folder_add_document, + folder_add_multiple_documents, folder_create, folder_delete, + folder_document_multiple_remove, folder_edit, folder_list, folder_view, + folders_main_menu_link +) from .models import Folder -from .permissions import (PERMISSION_FOLDER_ADD_DOCUMENT, - PERMISSION_FOLDER_DELETE, PERMISSION_FOLDER_EDIT, - PERMISSION_FOLDER_REMOVE_DOCUMENT, - PERMISSION_FOLDER_VIEW) +from .permissions import ( + PERMISSION_FOLDER_ADD_DOCUMENT, PERMISSION_FOLDER_DELETE, + PERMISSION_FOLDER_EDIT, PERMISSION_FOLDER_REMOVE_DOCUMENT, + PERMISSION_FOLDER_VIEW +) register_links(Folder, [folder_view, folder_edit, folder_acl_list, folder_delete]) register_links([Folder, 'folders:folder_list', 'folders:folder_create'], [folder_list, folder_create], menu_name='secondary_menu') @@ -30,16 +33,18 @@ register_links([Document], [folder_add_multiple_documents, folder_document_multi register_top_menu(name='folders', link=folders_main_menu_link) -class_permissions(Folder, [ACLS_EDIT_ACL, ACLS_VIEW_ACL, - PERMISSION_FOLDER_DELETE, PERMISSION_FOLDER_EDIT, - PERMISSION_FOLDER_VIEW]) +class_permissions(Folder, [ + ACLS_EDIT_ACL, ACLS_VIEW_ACL, PERMISSION_FOLDER_DELETE, + PERMISSION_FOLDER_EDIT, PERMISSION_FOLDER_VIEW +]) -class_permissions(Document, [PERMISSION_FOLDER_ADD_DOCUMENT, - PERMISSION_FOLDER_REMOVE_DOCUMENT]) +class_permissions(Document, [ + PERMISSION_FOLDER_ADD_DOCUMENT, PERMISSION_FOLDER_REMOVE_DOCUMENT +]) register_model_list_columns(Folder, [ - {'name': _(u'Created'), 'attribute': 'datetime_created'}, - {'name': _(u'Documents'), 'attribute': encapsulate(lambda x: x.documents.count())}, + {'name': _('Created'), 'attribute': 'datetime_created'}, + {'name': _('Documents'), 'attribute': encapsulate(lambda x: x.documents.count())}, ]) APIEndPoint('folders') diff --git a/mayan/apps/folders/admin.py b/mayan/apps/folders/admin.py index e5389bc895..f3f614a839 100644 --- a/mayan/apps/folders/admin.py +++ b/mayan/apps/folders/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from .models import Folder diff --git a/mayan/apps/folders/api_views.py b/mayan/apps/folders/api_views.py index e1b03e3a1b..7cd387a84b 100644 --- a/mayan/apps/folders/api_views.py +++ b/mayan/apps/folders/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 diff --git a/mayan/apps/folders/forms.py b/mayan/apps/folders/forms.py index ae3b6bbada..4e94bb9a19 100644 --- a/mayan/apps/folders/forms.py +++ b/mayan/apps/folders/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging @@ -35,4 +35,4 @@ class FolderListForm(forms.Form): self.fields['folder'] = forms.ModelChoiceField( queryset=queryset, - label=_(u'Folder')) + label=_('Folder')) diff --git a/mayan/apps/folders/links.py b/mayan/apps/folders/links.py index 7a305da238..2d62410b4b 100644 --- a/mayan/apps/folders/links.py +++ b/mayan/apps/folders/links.py @@ -1,24 +1,25 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from acls.permissions import ACLS_VIEW_ACL from documents.permissions import PERMISSION_DOCUMENT_VIEW -from .permissions import (PERMISSION_FOLDER_ADD_DOCUMENT, - PERMISSION_FOLDER_CREATE, PERMISSION_FOLDER_DELETE, - PERMISSION_FOLDER_EDIT, PERMISSION_FOLDER_VIEW, - PERMISSION_FOLDER_REMOVE_DOCUMENT) +from .permissions import ( + PERMISSION_FOLDER_ADD_DOCUMENT, PERMISSION_FOLDER_CREATE, + PERMISSION_FOLDER_DELETE, PERMISSION_FOLDER_EDIT, PERMISSION_FOLDER_VIEW, + PERMISSION_FOLDER_REMOVE_DOCUMENT +) -folder_list = {'text': _(u'Folders'), 'view': 'folders:folder_list', 'famfam': 'folder_user'} +folder_list = {'text': _('Folders'), 'view': 'folders:folder_list', 'famfam': 'folder_user'} folder_create = {'text': _('Create folder'), 'view': 'folders:folder_create', 'famfam': 'folder_add', 'permissions': [PERMISSION_FOLDER_CREATE]} folder_edit = {'text': _('Edit'), 'view': 'folders:folder_edit', 'args': 'object.pk', 'famfam': 'folder_edit', 'permissions': [PERMISSION_FOLDER_EDIT]} folder_delete = {'text': _('Delete'), 'view': 'folders:folder_delete', 'args': 'object.pk', 'famfam': 'folder_delete', 'permissions': [PERMISSION_FOLDER_DELETE]} folder_document_multiple_remove = {'text': _('Remove from folder'), 'view': 'folders:folder_document_multiple_remove', 'args': 'object.pk', 'famfam': 'folder_delete', 'permissions': [PERMISSION_FOLDER_REMOVE_DOCUMENT]} -folder_view = {'text': _(u'Documents'), 'view': 'folders:folder_view', 'args': 'object.pk', 'famfam': 'page', 'permissions': [PERMISSION_FOLDER_VIEW]} +folder_view = {'text': _('Documents'), 'view': 'folders:folder_view', 'args': 'object.pk', 'famfam': 'page', 'permissions': [PERMISSION_FOLDER_VIEW]} folder_add_document = {'text': _('Add to a folder'), 'view': 'folders:folder_add_document', 'args': 'object.pk', 'famfam': 'folder_add', 'permissions': [PERMISSION_FOLDER_ADD_DOCUMENT]} folder_add_multiple_documents = {'text': _('Add to folder'), 'view': 'folders:folder_add_multiple_documents', 'famfam': 'folder_add'} -document_folder_list = {'text': _(u'Folders'), 'view': 'folders:document_folder_list', 'args': 'object.pk', 'famfam': 'folder_user', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +document_folder_list = {'text': _('Folders'), 'view': 'folders:document_folder_list', 'args': 'object.pk', 'famfam': 'folder_user', 'permissions': [PERMISSION_DOCUMENT_VIEW]} -folder_acl_list = {'text': _(u'ACLs'), 'view': 'folders:folder_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} +folder_acl_list = {'text': _('ACLs'), 'view': 'folders:folder_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} folders_main_menu_link = {'text': _('Folders'), 'famfam': 'folder_user', 'view': 'folders:folder_list'} diff --git a/mayan/apps/folders/models.py b/mayan/apps/folders/models.py index 4eadc93107..3218d10da8 100644 --- a/mayan/apps/folders/models.py +++ b/mayan/apps/folders/models.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.contrib.auth.models import User from django.db import models from django.utils.translation import ugettext as _ @@ -6,9 +8,9 @@ from documents.models import Document class Folder(models.Model): - title = models.CharField(max_length=128, verbose_name=_(u'Title'), db_index=True) - user = models.ForeignKey(User, verbose_name=_(u'User')) - datetime_created = models.DateTimeField(verbose_name=_(u'Datetime created'), auto_now_add=True) + 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): @@ -21,5 +23,5 @@ class Folder(models.Model): class Meta: unique_together = ('title', 'user') ordering = ('title',) - verbose_name = _(u'Folder') - verbose_name_plural = _(u'Folders') + verbose_name = _('Folder') + verbose_name_plural = _('Folders') diff --git a/mayan/apps/folders/permissions.py b/mayan/apps/folders/permissions.py index 5538a70214..cbe34bc1d1 100644 --- a/mayan/apps/folders/permissions.py +++ b/mayan/apps/folders/permissions.py @@ -1,14 +1,14 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -folder_namespace = PermissionNamespace('folders', _(u'Folders')) +folder_namespace = PermissionNamespace('folders', _('Folders')) -PERMISSION_FOLDER_CREATE = Permission.objects.register(folder_namespace, 'folder_create', _(u'Create new folders')) -PERMISSION_FOLDER_EDIT = Permission.objects.register(folder_namespace, 'folder_edit', _(u'Edit new folders')) -PERMISSION_FOLDER_DELETE = Permission.objects.register(folder_namespace, 'folder_delete', _(u'Delete new folders')) -PERMISSION_FOLDER_REMOVE_DOCUMENT = Permission.objects.register(folder_namespace, 'folder_remove_document', _(u'Remove documents from folders')) -PERMISSION_FOLDER_VIEW = Permission.objects.register(folder_namespace, 'folder_view', _(u'View existing folders')) -PERMISSION_FOLDER_ADD_DOCUMENT = Permission.objects.register(folder_namespace, 'folder_add_document', _(u'Add documents to existing folders')) +PERMISSION_FOLDER_CREATE = Permission.objects.register(folder_namespace, 'folder_create', _('Create new folders')) +PERMISSION_FOLDER_EDIT = Permission.objects.register(folder_namespace, 'folder_edit', _('Edit new folders')) +PERMISSION_FOLDER_DELETE = Permission.objects.register(folder_namespace, 'folder_delete', _('Delete new folders')) +PERMISSION_FOLDER_REMOVE_DOCUMENT = Permission.objects.register(folder_namespace, 'folder_remove_document', _('Remove documents from folders')) +PERMISSION_FOLDER_VIEW = Permission.objects.register(folder_namespace, 'folder_view', _('View existing folders')) +PERMISSION_FOLDER_ADD_DOCUMENT = Permission.objects.register(folder_namespace, 'folder_add_document', _('Add documents to existing folders')) diff --git a/mayan/apps/folders/serializers.py b/mayan/apps/folders/serializers.py index 6f884d89fd..9074fbc3f6 100644 --- a/mayan/apps/folders/serializers.py +++ b/mayan/apps/folders/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from rest_framework import serializers diff --git a/mayan/apps/folders/tests.py b/mayan/apps/folders/tests.py index 0142ff0e5c..41d7b4c3a4 100644 --- a/mayan/apps/folders/tests.py +++ b/mayan/apps/folders/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os diff --git a/mayan/apps/folders/urls.py b/mayan/apps/folders/urls.py index b625ed37fa..d8c2870920 100644 --- a/mayan/apps/folders/urls.py +++ b/mayan/apps/folders/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url from .api_views import (APIDocumentFolderListView, APIFolderDocumentListView, diff --git a/mayan/apps/folders/views.py b/mayan/apps/folders/views.py index 7110d6263f..09e99f5301 100644 --- a/mayan/apps/folders/views.py +++ b/mayan/apps/folders/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging @@ -21,10 +21,11 @@ from permissions.models import Permission from .forms import FolderForm, FolderListForm from .models import Folder -from .permissions import (PERMISSION_FOLDER_ADD_DOCUMENT, - PERMISSION_FOLDER_CREATE, PERMISSION_FOLDER_DELETE, - PERMISSION_FOLDER_EDIT, PERMISSION_FOLDER_VIEW, - PERMISSION_FOLDER_REMOVE_DOCUMENT) +from .permissions import ( + PERMISSION_FOLDER_ADD_DOCUMENT, PERMISSION_FOLDER_CREATE, + PERMISSION_FOLDER_DELETE, PERMISSION_FOLDER_EDIT, PERMISSION_FOLDER_VIEW, + PERMISSION_FOLDER_REMOVE_DOCUMENT +) logger = logging.getLogger(__name__) @@ -35,7 +36,7 @@ class FolderListView(SingleObjectListView): def get_extra_context(self): return { - 'title': _(u'Folders'), + 'title': _('Folders'), 'hide_link': True, } @@ -49,15 +50,15 @@ def folder_create(request): folder, created = Folder.objects.get_or_create(user=request.user, title=form.cleaned_data['title']) if created: apply_default_acls(folder, request.user) - messages.success(request, _(u'Folder created successfully')) + messages.success(request, _('Folder created successfully')) return HttpResponseRedirect(reverse('folders:folder_list')) else: - messages.error(request, _(u'A folder named: %s, already exists.') % form.cleaned_data['title']) + messages.error(request, _('A folder named: %s, already exists.') % form.cleaned_data['title']) else: form = FolderForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Create folder'), + 'title': _('Create folder'), 'form': form, }, context_instance=RequestContext(request)) @@ -75,15 +76,15 @@ def folder_edit(request, folder_id): if form.is_valid(): try: form.save() - messages.success(request, _(u'Folder edited successfully')) + messages.success(request, _('Folder edited successfully')) return HttpResponseRedirect(reverse('folders:folder_list')) except Exception as exception: - messages.error(request, _(u'Error editing folder; %s') % exception) + messages.error(request, _('Error editing folder; %s') % exception) else: form = FolderForm(instance=folder) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit folder: %s') % folder, + 'title': _('Edit folder: %s') % folder, 'form': form, 'object': folder, }, context_instance=RequestContext(request)) @@ -105,9 +106,9 @@ def folder_delete(request, folder_id): if request.method == 'POST': try: folder.delete() - messages.success(request, _(u'Folder: %s deleted successfully.') % folder) + messages.success(request, _('Folder: %s deleted successfully.') % folder) except Exception as exception: - messages.error(request, _(u'Folder: %(folder)s delete error: %(error)s') % { + messages.error(request, _('Folder: %(folder)s delete error: %(error)s') % { 'folder': folder, 'error': exception}) return HttpResponseRedirect(next) @@ -117,7 +118,7 @@ def folder_delete(request, folder_id): 'previous': previous, 'next': next, 'object': folder, - 'title': _(u'Are you sure you with to delete the folder: %s?') % folder, + 'title': _('Are you sure you with to delete the folder: %s?') % folder, } return render_to_response('main/generic_confirm.html', context, @@ -140,7 +141,7 @@ class FolderDetailView(DocumentListView): def get_extra_context(self): return { - 'title': _(u'Documents in folder: %s') % self.get_folder(), + 'title': _('Documents in folder: %s') % self.get_folder(), 'hide_links': True, 'object': self.get_folder(), } @@ -153,7 +154,7 @@ def folder_add_document(request, document_id=None, document_id_list=None): elif document_id_list: documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) try: @@ -172,10 +173,10 @@ def folder_add_document(request, document_id=None, document_id_list=None): for document in documents: if document.pk not in folder.documents.values_list('pk', flat=True): folder.documents.add(document) - messages.success(request, _(u'Document: %(document)s added to folder: %(folder)s successfully.') % { + messages.success(request, _('Document: %(document)s added to folder: %(folder)s successfully.') % { 'document': document, 'folder': folder}) else: - messages.warning(request, _(u'Document: %(document)s is already in folder: %(folder)s.') % { + messages.warning(request, _('Document: %(document)s is already in folder: %(folder)s.') % { 'document': document, 'folder': folder}) return HttpResponseRedirect(next) @@ -190,9 +191,9 @@ def folder_add_document(request, document_id=None, document_id_list=None): if len(documents) == 1: context['object'] = documents[0] - context['title'] = _(u'Add document: %s to folder.') % documents[0] + context['title'] = _('Add document: %s to folder.') % documents[0] elif len(documents) > 1: - context['title'] = _(u'Add documents: %s to folder.') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Add documents: %s to folder.') % ', '.join([unicode(d) for d in documents]) return render_to_response('main/generic_form.html', context, context_instance=RequestContext(request)) @@ -207,7 +208,7 @@ def document_folder_list(request, document_id): AccessEntry.objects.check_access(PERMISSION_DOCUMENT_VIEW, request.user, document) context = { - 'title': _(u'Folders containing this document'), + 'title': _('Folders containing this document'), 'object': document, 'hide_link': True, } @@ -235,7 +236,7 @@ def folder_document_remove(request, folder_id, document_id=None, document_id_lis elif document_id_list: folder_documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one folder document.')) + messages.error(request, _('Must provide at least one folder document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) logger.debug('folder_documents (pre permission check): %s', folder_documents) @@ -253,9 +254,9 @@ def folder_document_remove(request, folder_id, document_id=None, document_id_lis for folder_document in folder_documents: try: folder.documents.remove(folder_document) - messages.success(request, _(u'Document: %s removed successfully.') % folder_document) + messages.success(request, _('Document: %s removed successfully.') % folder_document) except Exception as exception: - messages.error(request, _(u'Document: %(document)s delete error: %(error)s') % { + messages.error(request, _('Document: %(document)s delete error: %(error)s') % { 'document': folder_document, 'error': exception}) return HttpResponseRedirect(next) @@ -267,10 +268,10 @@ def folder_document_remove(request, folder_id, document_id=None, document_id_lis } if len(folder_documents) == 1: context['object'] = folder_documents[0] - context['title'] = _(u'Are you sure you wish to remove the document: %(document)s from the folder "%(folder)s"?') % { + context['title'] = _('Are you sure you wish to remove the document: %(document)s from the folder "%(folder)s"?') % { 'document': ', '.join([unicode(d) for d in folder_documents]), 'folder': folder} elif len(folder_documents) > 1: - context['title'] = _(u'Are you sure you wish to remove the documents: %(documents)s from the folder "%(folder)s"?') % { + context['title'] = _('Are you sure you wish to remove the documents: %(documents)s from the folder "%(folder)s"?') % { 'documents': ', '.join([unicode(d) for d in folder_documents]), 'folder': folder} return render_to_response('main/generic_confirm.html', context, diff --git a/mayan/apps/history/models.py b/mayan/apps/history/models.py index 4167352687..137941ffae 100644 --- a/mayan/apps/history/models.py +++ b/mayan/apps/history/models.py @@ -1,3 +1 @@ from django.db import models - - diff --git a/mayan/apps/installation/__init__.py b/mayan/apps/installation/__init__.py index 06c4deb935..dc41396ade 100644 --- a/mayan/apps/installation/__init__.py +++ b/mayan/apps/installation/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db.utils import DatabaseError from django.dispatch import receiver @@ -35,22 +35,22 @@ def check_first_run(): register_model_list_columns(PropertyNamespace, [ { - 'name': _(u'Label'), + 'name': _('Label'), 'attribute': 'label' }, { - 'name': _(u'Items'), + 'name': _('Items'), 'attribute': encapsulate(lambda entry: len(entry.get_properties())) } ]) register_model_list_columns(Property, [ { - 'name': _(u'Label'), + 'name': _('Label'), 'attribute': 'label' }, { - 'name': _(u'Value'), + 'name': _('Value'), 'attribute': 'value' } ]) diff --git a/mayan/apps/installation/classes.py b/mayan/apps/installation/classes.py index fadfd82c55..5aaab193b5 100644 --- a/mayan/apps/installation/classes.py +++ b/mayan/apps/installation/classes.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from collections import namedtuple from json import dumps diff --git a/mayan/apps/installation/links.py b/mayan/apps/installation/links.py index 1ca63706e3..d74ec84591 100644 --- a/mayan/apps/installation/links.py +++ b/mayan/apps/installation/links.py @@ -1,9 +1,9 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from .permissions import PERMISSION_INSTALLATION_DETAILS -link_menu_link = {'text': _(u'Installation details'), 'view': 'installation:namespace_list', 'icon': 'interface_preferences.png', 'permissions': [PERMISSION_INSTALLATION_DETAILS]} -link_namespace_list = {'text': _(u'Installation property namespaces'), 'view': 'installation:namespace_list', 'famfam': 'layout', 'permissions': [PERMISSION_INSTALLATION_DETAILS]} -link_namespace_details = {'text': _(u'Details'), 'view': 'installation:namespace_details', 'args': 'object.id', 'famfam': 'layout_link', 'permissions': [PERMISSION_INSTALLATION_DETAILS]} +link_menu_link = {'text': _('Installation details'), 'view': 'installation:namespace_list', 'icon': 'interface_preferences.png', 'permissions': [PERMISSION_INSTALLATION_DETAILS]} +link_namespace_list = {'text': _('Installation property namespaces'), 'view': 'installation:namespace_list', 'famfam': 'layout', 'permissions': [PERMISSION_INSTALLATION_DETAILS]} +link_namespace_details = {'text': _('Details'), 'view': 'installation:namespace_details', 'args': 'object.id', 'famfam': 'layout_link', 'permissions': [PERMISSION_INSTALLATION_DETAILS]} diff --git a/mayan/apps/installation/literals.py b/mayan/apps/installation/literals.py index 685d69c302..adc6b3cc9c 100644 --- a/mayan/apps/installation/literals.py +++ b/mayan/apps/installation/literals.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + FORM_SUBMIT_URL = 'https://docs.google.com/spreadsheet/formResponse' FORM_KEY = 'dGZrYkw3SDl5OENMTG15emp1UFFEUWc6MQ' FORM_RECEIVER_FIELD = 'entry.0.single' diff --git a/mayan/apps/installation/models.py b/mayan/apps/installation/models.py index c7e4dcd13b..bc502460d4 100644 --- a/mayan/apps/installation/models.py +++ b/mayan/apps/installation/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os import sys @@ -49,90 +49,90 @@ class Installation(SingletonModel): return self._properties.values() def os_properties(self): - namespace = PropertyNamespace('os', _(u'Operating system')) + namespace = PropertyNamespace('os', _('Operating system')) if LSB: - namespace.add_property('is_lsb', _(u'LSB OS'), True, True) - namespace.add_property('distributor_id', _(u'Distributor ID'), lsb_release('-i', '-s'), True) - namespace.add_property('description', _(u'Description'), lsb_release('-d', '-s'), True) - namespace.add_property('release', _(u'Release'), lsb_release('-r', '-s'), True) - namespace.add_property('codename', _(u'Codename'), lsb_release('-c', '-s'), True) - namespace.add_property('sysinfo', _(u'System info'), uname('-a'), True) + namespace.add_property('is_lsb', _('LSB OS'), True, True) + namespace.add_property('distributor_id', _('Distributor ID'), lsb_release('-i', '-s'), True) + namespace.add_property('description', _('Description'), lsb_release('-d', '-s'), True) + namespace.add_property('release', _('Release'), lsb_release('-r', '-s'), True) + namespace.add_property('codename', _('Codename'), lsb_release('-c', '-s'), True) + namespace.add_property('sysinfo', _('System info'), uname('-a'), True) else: - namespace.add_property('is_lsb', _(u'LSB OS'), False) + namespace.add_property('is_lsb', _('LSB OS'), False) - namespace.add_property('architecture', _(u'OS architecture'), platform.architecture(), report=True) - namespace.add_property('python_version', _(u'Python version'), platform.python_version(), report=True) - namespace.add_property('hostname', _(u'Hostname'), platform.node()) - namespace.add_property('platform', _(u'Platform'), sys.platform, report=True) - namespace.add_property('machine', _(u'Machine'), platform.machine(), report=True) - namespace.add_property('processor', _(u'Processor'), platform.processor(), report=True) - namespace.add_property('cpus', _(u'Number of CPUs'), psutil.cpu_count(), report=True) - namespace.add_property('total_phymem', _(u'Total physical memory'), pretty_size(psutil.virtual_memory().total), report=True) - namespace.add_property('disk_partitions', _(u'Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()])) + namespace.add_property('architecture', _('OS architecture'), platform.architecture(), report=True) + namespace.add_property('python_version', _('Python version'), platform.python_version(), report=True) + namespace.add_property('hostname', _('Hostname'), platform.node()) + namespace.add_property('platform', _('Platform'), sys.platform, report=True) + namespace.add_property('machine', _('Machine'), platform.machine(), report=True) + namespace.add_property('processor', _('Processor'), platform.processor(), report=True) + namespace.add_property('cpus', _('Number of CPUs'), psutil.cpu_count(), report=True) + namespace.add_property('total_phymem', _('Total physical memory'), pretty_size(psutil.virtual_memory().total), report=True) + namespace.add_property('disk_partitions', _('Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()])) def binary_dependencies(self): - namespace = PropertyNamespace('bins', _(u'Binary dependencies')) + namespace = PropertyNamespace('bins', _('Binary dependencies')) try: tesseract = sh.Command(TESSERACT_PATH) except sh.CommandNotFound: - namespace.add_property('tesseract', _(u'tesseract version'), _(u'not found'), report=True) + namespace.add_property('tesseract', _('tesseract version'), _('not found'), report=True) except Exception: - namespace.add_property('tesseract', _(u'tesseract version'), _(u'error getting version'), report=True) + namespace.add_property('tesseract', _('tesseract version'), _('error getting version'), report=True) else: - namespace.add_property('tesseract', _(u'tesseract version'), tesseract('-v').stderr, report=True) + namespace.add_property('tesseract', _('tesseract version'), tesseract('-v').stderr, report=True) try: unpaper = sh.Command(UNPAPER_PATH) except sh.CommandNotFound: - namespace.add_property('unpaper', _(u'unpaper version'), _(u'not found'), report=True) + namespace.add_property('unpaper', _('unpaper version'), _('not found'), report=True) except Exception: - namespace.add_property('unpaper', _(u'unpaper version'), _(u'error getting version'), report=True) + namespace.add_property('unpaper', _('unpaper version'), _('error getting version'), report=True) else: - namespace.add_property('unpaper', _(u'unpaper version'), unpaper('-V').stdout, report=True) + namespace.add_property('unpaper', _('unpaper version'), unpaper('-V').stdout, report=True) try: pdftotext = sh.Command(PDFTOTEXT_PATH) except sh.CommandNotFound: - namespace.add_property('pdftotext', _(u'pdftotext version'), _(u'not found'), report=True) + namespace.add_property('pdftotext', _('pdftotext version'), _('not found'), report=True) except Exception: - namespace.add_property('pdftotext', _(u'pdftotext version'), _(u'error getting version'), report=True) + namespace.add_property('pdftotext', _('pdftotext version'), _('error getting version'), report=True) else: - namespace.add_property('pdftotext', _(u'pdftotext version'), pdftotext('-v').stderr, report=True) + namespace.add_property('pdftotext', _('pdftotext version'), pdftotext('-v').stderr, report=True) def mayan_properties(self): - namespace = PropertyNamespace('mayan', _(u'Mayan EDMS')) + namespace = PropertyNamespace('mayan', _('Mayan EDMS')) - namespace.add_property('uuid', _(u'UUID'), self.uuid, report=True) - namespace.add_property('mayan_version', _(u'Mayan EDMS version'), mayan_version, report=True) + namespace.add_property('uuid', _('UUID'), self.uuid, report=True) + namespace.add_property('mayan_version', _('Mayan EDMS version'), mayan_version, report=True) def git_properties(self): - namespace = PropertyNamespace('git', _(u'Git repository')) + namespace = PropertyNamespace('git', _('Git repository')) try: repo = Repo(os.path.abspath(os.path.join(settings.BASE_DIR, '..'))) except: - namespace.add_property('is_git_repo', _(u'Running from a Git repository'), False) + namespace.add_property('is_git_repo', _('Running from a Git repository'), False) else: repo.config_reader() headcommit = repo.head.commit - namespace.add_property('is_git_repo', _(u'Running from a Git repository'), True) - namespace.add_property('repo_remotes', _(u'Repository remotes'), ', '.join([unicode(remote) for remote in repo.remotes]), report=True) - namespace.add_property('repo_remotes_urls', _(u'Repository remotes URLs'), ', '.join([unicode(remote.url) for remote in repo.remotes]), report=True) - namespace.add_property('repo_head_reference', _(u'Branch'), repo.head.reference, report=True) - namespace.add_property('headcommit_hexsha', _(u'HEAD commit hex SHA'), headcommit.hexsha, report=True) - namespace.add_property('headcommit_author', _(u'HEAD commit author'), headcommit.author) - namespace.add_property('headcommit_authored_date', _(u'HEAD commit authored date'), time.asctime(time.gmtime(headcommit.authored_date)), report=True) - namespace.add_property('headcommit_committer', _(u'HEAD commit committer'), headcommit.committer) - namespace.add_property('headcommit_committed_date', _(u'HEAD commit committed date'), time.asctime(time.gmtime(headcommit.committed_date)), report=True) - namespace.add_property('headcommit_message', _(u'HEAD commit message'), headcommit.message, report=True) + namespace.add_property('is_git_repo', _('Running from a Git repository'), True) + namespace.add_property('repo_remotes', _('Repository remotes'), ', '.join([unicode(remote) for remote in repo.remotes]), report=True) + namespace.add_property('repo_remotes_urls', _('Repository remotes URLs'), ', '.join([unicode(remote.url) for remote in repo.remotes]), report=True) + namespace.add_property('repo_head_reference', _('Branch'), repo.head.reference, report=True) + namespace.add_property('headcommit_hexsha', _('HEAD commit hex SHA'), headcommit.hexsha, report=True) + namespace.add_property('headcommit_author', _('HEAD commit author'), headcommit.author) + namespace.add_property('headcommit_authored_date', _('HEAD commit authored date'), time.asctime(time.gmtime(headcommit.authored_date)), report=True) + namespace.add_property('headcommit_committer', _('HEAD commit committer'), headcommit.committer) + namespace.add_property('headcommit_committed_date', _('HEAD commit committed date'), time.asctime(time.gmtime(headcommit.committed_date)), report=True) + namespace.add_property('headcommit_message', _('HEAD commit message'), headcommit.message, report=True) def virtualenv_properties(self): - namespace = PropertyNamespace('venv', _(u'VirtualEnv')) + namespace = PropertyNamespace('venv', _('VirtualEnv')) try: venv = VirtualEnv() except PIPNotFound: - namespace.add_property('pip', 'pip', _(u'pip not found.'), report=True) + namespace.add_property('pip', 'pip', _('pip not found.'), report=True) else: for item, version, result in venv.get_results(): namespace.add_property(item, '%s (%s)' % (item, version), result, report=True) @@ -171,4 +171,4 @@ class Installation(SingletonModel): lock.release() class Meta: - verbose_name = verbose_name_plural = _(u'Installation details') + verbose_name = verbose_name_plural = _('Installation details') diff --git a/mayan/apps/installation/permissions.py b/mayan/apps/installation/permissions.py index 9b85bb458a..fd08eaac50 100644 --- a/mayan/apps/installation/permissions.py +++ b/mayan/apps/installation/permissions.py @@ -1,8 +1,8 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -namespace = PermissionNamespace('installation', _(u'Installation')) -PERMISSION_INSTALLATION_DETAILS = Permission.objects.register(namespace, 'installation_details', _(u'View installation environment details')) +namespace = PermissionNamespace('installation', _('Installation')) +PERMISSION_INSTALLATION_DETAILS = Permission.objects.register(namespace, 'installation_details', _('View installation environment details')) diff --git a/mayan/apps/installation/tasks.py b/mayan/apps/installation/tasks.py index 22badfa96a..f3845c4a31 100644 --- a/mayan/apps/installation/tasks.py +++ b/mayan/apps/installation/tasks.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import requests from mayan.celery import app @@ -5,6 +7,7 @@ from mayan.celery import app from .models import Installation +# TODO: move rate_limit to literals.py @app.task(bind=True, ignore_result=True, max_retries=None, rate_limit='1/m') def task_details_submit(self): try: diff --git a/mayan/apps/installation/urls.py b/mayan/apps/installation/urls.py index f321b5f583..198f846238 100644 --- a/mayan/apps/installation/urls.py +++ b/mayan/apps/installation/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('installation.views', diff --git a/mayan/apps/installation/views.py b/mayan/apps/installation/views.py index ea45ba1074..97f3cce40c 100644 --- a/mayan/apps/installation/views.py +++ b/mayan/apps/installation/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.shortcuts import render_to_response from django.template import RequestContext @@ -18,7 +18,7 @@ def namespace_list(request): return render_to_response('main/generic_list.html', { 'object_list': PropertyNamespace.get_all(), - 'title': _(u'Installation property namespaces'), + 'title': _('Installation property namespaces'), 'hide_object': True, }, context_instance=RequestContext(request)) @@ -30,7 +30,7 @@ def namespace_details(request, namespace_id): namespace = PropertyNamespace.get(namespace_id) object_list = namespace.get_properties() - title = _(u'Installation namespace details for: %s') % namespace.label + title = _('Installation namespace details for: %s') % namespace.label return render_to_response('main/generic_list.html', { 'object_list': object_list, diff --git a/mayan/apps/linking/__init__.py b/mayan/apps/linking/__init__.py index 780c10397a..e215691cec 100644 --- a/mayan/apps/linking/__init__.py +++ b/mayan/apps/linking/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from acls.api import class_permissions from acls.permissions import ACLS_EDIT_ACL, ACLS_VIEW_ACL @@ -7,17 +7,18 @@ from navigation.api import register_links from project_setup.api import register_setup from .classes import ResolvedSmartLink -from .links import (smart_link_acl_list, - smart_link_create, smart_link_condition_create, - smart_link_condition_delete, smart_link_condition_edit, - smart_link_condition_list, smart_link_delete, - smart_link_document_types, smart_link_edit, - smart_link_instance_view, smart_link_instances_for_document, smart_link_list, - smart_link_setup) +from .links import ( + smart_link_acl_list, smart_link_create, smart_link_condition_create, + smart_link_condition_delete, smart_link_condition_edit, + smart_link_condition_list, smart_link_delete, smart_link_document_types, + smart_link_edit, smart_link_instance_view, + smart_link_instances_for_document, smart_link_list, smart_link_setup +) from .models import SmartLink, SmartLinkCondition -from .permissions import (PERMISSION_SMART_LINK_DELETE, - PERMISSION_SMART_LINK_EDIT, - PERMISSION_SMART_LINK_VIEW) +from .permissions import ( + PERMISSION_SMART_LINK_DELETE, PERMISSION_SMART_LINK_EDIT, + PERMISSION_SMART_LINK_VIEW +) register_links(Document, [smart_link_instances_for_document], menu_name='form_header') register_links(SmartLink, [smart_link_edit, smart_link_document_types, smart_link_condition_list, smart_link_acl_list, smart_link_delete]) diff --git a/mayan/apps/linking/admin.py b/mayan/apps/linking/admin.py index 2116114693..ca28f53962 100644 --- a/mayan/apps/linking/admin.py +++ b/mayan/apps/linking/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin diff --git a/mayan/apps/linking/classes.py b/mayan/apps/linking/classes.py index d2ca5a8e9a..a7fa0724cd 100644 --- a/mayan/apps/linking/classes.py +++ b/mayan/apps/linking/classes.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from collections import namedtuple ResolvedSmartLink = namedtuple('ResolvedSmartLink', ['smart_link', 'queryset']) diff --git a/mayan/apps/linking/forms.py b/mayan/apps/linking/forms.py index fe638d81ca..fbe90ac1f4 100644 --- a/mayan/apps/linking/forms.py +++ b/mayan/apps/linking/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms from django.utils.translation import ugettext_lazy as _ diff --git a/mayan/apps/linking/links.py b/mayan/apps/linking/links.py index dce31a288d..393e8aab28 100644 --- a/mayan/apps/linking/links.py +++ b/mayan/apps/linking/links.py @@ -1,28 +1,28 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from acls.permissions import ACLS_VIEW_ACL from documents.permissions import PERMISSION_DOCUMENT_VIEW -from .permissions import (PERMISSION_SMART_LINK_CREATE, - PERMISSION_SMART_LINK_DELETE, - PERMISSION_SMART_LINK_EDIT, - PERMISSION_SMART_LINK_VIEW) +from .permissions import ( + PERMISSION_SMART_LINK_CREATE, PERMISSION_SMART_LINK_DELETE, + PERMISSION_SMART_LINK_EDIT, PERMISSION_SMART_LINK_VIEW +) -smart_link_setup = {'text': _(u'Smart links'), 'view': 'linking:smart_link_list', 'icon': 'link.png', 'permissions': [PERMISSION_SMART_LINK_CREATE]} -smart_link_list = {'text': _(u'Smart links'), 'view': 'linking:smart_link_list', 'famfam': 'link', 'permissions': [PERMISSION_SMART_LINK_CREATE]} -smart_link_create = {'text': _(u'Create new smart link'), 'view': 'linking:smart_link_create', 'famfam': 'link_add', 'permissions': [PERMISSION_SMART_LINK_CREATE]} -smart_link_edit = {'text': _(u'Edit'), 'view': 'linking:smart_link_edit', 'args': 'object.pk', 'famfam': 'link_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]} -smart_link_delete = {'text': _(u'Delete'), 'view': 'linking:smart_link_delete', 'args': 'object.pk', 'famfam': 'link_delete', 'permissions': [PERMISSION_SMART_LINK_DELETE]} +smart_link_setup = {'text': _('Smart links'), 'view': 'linking:smart_link_list', 'icon': 'link.png', 'permissions': [PERMISSION_SMART_LINK_CREATE]} +smart_link_list = {'text': _('Smart links'), 'view': 'linking:smart_link_list', 'famfam': 'link', 'permissions': [PERMISSION_SMART_LINK_CREATE]} +smart_link_create = {'text': _('Create new smart link'), 'view': 'linking:smart_link_create', 'famfam': 'link_add', 'permissions': [PERMISSION_SMART_LINK_CREATE]} +smart_link_edit = {'text': _('Edit'), 'view': 'linking:smart_link_edit', 'args': 'object.pk', 'famfam': 'link_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]} +smart_link_delete = {'text': _('Delete'), 'view': 'linking:smart_link_delete', 'args': 'object.pk', 'famfam': 'link_delete', 'permissions': [PERMISSION_SMART_LINK_DELETE]} smart_link_document_types = {'text': _('Document types'), 'view': 'linking:smart_link_document_types', 'args': 'object.pk', 'famfam': 'layout', 'permissions': [PERMISSION_SMART_LINK_EDIT]} -smart_link_instances_for_document = {'text': _(u'Smart links'), 'view': 'linking:smart_link_instances_for_document', 'args': 'object.pk', 'famfam': 'page_link', 'permissions': [PERMISSION_DOCUMENT_VIEW]} +smart_link_instances_for_document = {'text': _('Smart links'), 'view': 'linking:smart_link_instances_for_document', 'args': 'object.pk', 'famfam': 'page_link', 'permissions': [PERMISSION_DOCUMENT_VIEW]} smart_link_instance_view = {'text': _('Documents'), 'view': 'linking:smart_link_instance_view', 'args': ['document.pk', 'object.smart_link.pk'], 'famfam': 'layout', 'page': [PERMISSION_SMART_LINK_VIEW]} -smart_link_condition_list = {'text': _(u'Conditions'), 'view': 'linking:smart_link_condition_list', 'args': 'object.pk', 'famfam': 'cog', 'permissions': [PERMISSION_SMART_LINK_EDIT]} -smart_link_condition_create = {'text': _(u'Create condition'), 'view': 'linking:smart_link_condition_create', 'args': 'object.pk', 'famfam': 'cog_add', 'permissions': [PERMISSION_SMART_LINK_EDIT]} -smart_link_condition_edit = {'text': _(u'Edit'), 'view': 'linking:smart_link_condition_edit', 'args': 'condition.pk', 'famfam': 'cog_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]} -smart_link_condition_delete = {'text': _(u'Delete'), 'view': 'linking:smart_link_condition_delete', 'args': 'condition.pk', 'famfam': 'cog_delete', 'permissions': [PERMISSION_SMART_LINK_EDIT]} +smart_link_condition_list = {'text': _('Conditions'), 'view': 'linking:smart_link_condition_list', 'args': 'object.pk', 'famfam': 'cog', 'permissions': [PERMISSION_SMART_LINK_EDIT]} +smart_link_condition_create = {'text': _('Create condition'), 'view': 'linking:smart_link_condition_create', 'args': 'object.pk', 'famfam': 'cog_add', 'permissions': [PERMISSION_SMART_LINK_EDIT]} +smart_link_condition_edit = {'text': _('Edit'), 'view': 'linking:smart_link_condition_edit', 'args': 'condition.pk', 'famfam': 'cog_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]} +smart_link_condition_delete = {'text': _('Delete'), 'view': 'linking:smart_link_condition_delete', 'args': 'condition.pk', 'famfam': 'cog_delete', 'permissions': [PERMISSION_SMART_LINK_EDIT]} -smart_link_acl_list = {'text': _(u'ACLs'), 'view': 'linking:smart_link_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} +smart_link_acl_list = {'text': _('ACLs'), 'view': 'linking:smart_link_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} diff --git a/mayan/apps/linking/literals.py b/mayan/apps/linking/literals.py index d40935b621..c34c8fd873 100644 --- a/mayan/apps/linking/literals.py +++ b/mayan/apps/linking/literals.py @@ -1,27 +1,29 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ -INCLUSION_AND = u'&' -INCLUSION_OR = u'|' +INCLUSION_AND = '&' +INCLUSION_OR = '|' INCLUSION_CHOICES = ( - (INCLUSION_AND, _(u'and')), - (INCLUSION_OR, _(u'or')), + (INCLUSION_AND, _('and')), + (INCLUSION_OR, _('or')), ) OPERATOR_CHOICES = ( - (u'exact', _(u'is equal to')), - (u'iexact', _(u'is equal to (case insensitive)')), - (u'contains', _(u'contains')), - (u'icontains', _(u'contains (case insensitive)')), - (u'in', _(u'is in')), - (u'gt', _(u'is greater than')), - (u'gte', _(u'is greater than or equal to')), - (u'lt', _(u'is less than')), - (u'lte', _(u'is less than or equal to')), - (u'startswith', _(u'starts with')), - (u'istartswith', _(u'starts with (case insensitive)')), - (u'endswith', _(u'ends with')), - (u'iendswith', _(u'ends with (case insensitive)')), - (u'regex', _(u'is in regular expression')), - (u'iregex', _(u'is in regular expression (case insensitive)')), + ('exact', _('is equal to')), + ('iexact', _('is equal to (case insensitive)')), + ('contains', _('contains')), + ('icontains', _('contains (case insensitive)')), + ('in', _('is in')), + ('gt', _('is greater than')), + ('gte', _('is greater than or equal to')), + ('lt', _('is less than')), + ('lte', _('is less than or equal to')), + ('startswith', _('starts with')), + ('istartswith', _('starts with (case insensitive)')), + ('endswith', _('ends with')), + ('iendswith', _('ends with (case insensitive)')), + ('regex', _('is in regular expression')), + ('iregex', _('is in regular expression (case insensitive)')), ) diff --git a/mayan/apps/linking/managers.py b/mayan/apps/linking/managers.py index 6337d95b69..2ed942ae7a 100644 --- a/mayan/apps/linking/managers.py +++ b/mayan/apps/linking/managers.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.db import models from .classes import ResolvedSmartLink diff --git a/mayan/apps/linking/models.py b/mayan/apps/linking/models.py index 3c1abb562e..ccddbaca1b 100644 --- a/mayan/apps/linking/models.py +++ b/mayan/apps/linking/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models from django.db.models import Q @@ -13,10 +13,10 @@ from .managers import SmartLinkManager class SmartLink(models.Model): - title = models.CharField(max_length=96, verbose_name=_(u'Title')) - dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_(u'Dynamic title'), help_text=ugettext(u'This expression will be evaluated against the current selected document.')) - enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled')) - document_types = models.ManyToManyField(DocumentType, verbose_name=_(u'Document types')) + title = models.CharField(max_length=96, verbose_name=_('Title')) + dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_('Dynamic title'), help_text=ugettext('This expression will be evaluated against the current selected document.')) + enabled = models.BooleanField(default=True, verbose_name=_('Enabled')) + document_types = models.ManyToManyField(DocumentType, verbose_name=_('Document types')) objects = SmartLinkManager() @@ -56,22 +56,22 @@ class SmartLink(models.Model): return Document.objects.none() class Meta: - verbose_name = _(u'Smart link') - verbose_name_plural = _(u'Smart links') + verbose_name = _('Smart link') + verbose_name_plural = _('Smart links') class SmartLinkCondition(models.Model): - smart_link = models.ForeignKey(SmartLink, related_name='conditions', verbose_name=_(u'Smart link')) - inclusion = models.CharField(default=INCLUSION_AND, max_length=16, choices=INCLUSION_CHOICES, help_text=_(u'The inclusion is ignored for the first item.')) - foreign_document_data = models.CharField(max_length=128, verbose_name=_(u'Foreign document attribute'), help_text=_(u'This represents the metadata of all other documents.')) + 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.')) + foreign_document_data = models.CharField(max_length=128, verbose_name=_('Foreign document attribute'), help_text=_('This represents the metadata of all other documents.')) operator = models.CharField(max_length=16, choices=OPERATOR_CHOICES) - expression = models.TextField(verbose_name=_(u'Expression'), help_text=ugettext(u'This expression will be evaluated against the current document.')) - negated = models.BooleanField(default=False, verbose_name=_(u'Negated'), help_text=_(u'Inverts the logic of the operator.')) - enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled')) + expression = models.TextField(verbose_name=_('Expression'), help_text=ugettext('This expression will be evaluated against the current document.')) + 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): - return u'%s foreign %s %s %s %s' % (self.get_inclusion_display(), self.foreign_document_data, _(u'not') if self.negated else u'', self.get_operator_display(), self.expression) + 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: - verbose_name = _(u'Link condition') - verbose_name_plural = _(u'Link conditions') + verbose_name = _('Link condition') + verbose_name_plural = _('Link conditions') diff --git a/mayan/apps/linking/permissions.py b/mayan/apps/linking/permissions.py index f5e7cc30b7..15f93cf7da 100644 --- a/mayan/apps/linking/permissions.py +++ b/mayan/apps/linking/permissions.py @@ -1,12 +1,12 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -linking_namespace = PermissionNamespace('linking', _(u'Smart links')) +linking_namespace = PermissionNamespace('linking', _('Smart links')) -PERMISSION_SMART_LINK_VIEW = Permission.objects.register(linking_namespace, 'smart_link_view', _(u'View existing smart links')) -PERMISSION_SMART_LINK_CREATE = Permission.objects.register(linking_namespace, 'smart_link_create', _(u'Create new smart links')) -PERMISSION_SMART_LINK_DELETE = Permission.objects.register(linking_namespace, 'smart_link_delete', _(u'Delete smart links')) -PERMISSION_SMART_LINK_EDIT = Permission.objects.register(linking_namespace, 'smart_link_edit', _(u'Edit smart links')) +PERMISSION_SMART_LINK_VIEW = Permission.objects.register(linking_namespace, 'smart_link_view', _('View existing smart links')) +PERMISSION_SMART_LINK_CREATE = Permission.objects.register(linking_namespace, 'smart_link_create', _('Create new smart links')) +PERMISSION_SMART_LINK_DELETE = Permission.objects.register(linking_namespace, 'smart_link_delete', _('Delete smart links')) +PERMISSION_SMART_LINK_EDIT = Permission.objects.register(linking_namespace, 'smart_link_edit', _('Edit smart links')) diff --git a/mayan/apps/linking/urls.py b/mayan/apps/linking/urls.py index f16b9e95c3..5fcf0efb56 100644 --- a/mayan/apps/linking/urls.py +++ b/mayan/apps/linking/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('linking.views', diff --git a/mayan/apps/linking/views.py b/mayan/apps/linking/views.py index be15ebbf41..4ecf16a85b 100644 --- a/mayan/apps/linking/views.py +++ b/mayan/apps/linking/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging @@ -22,10 +22,10 @@ from permissions.models import Permission from .forms import SmartLinkConditionForm, SmartLinkForm from .models import SmartLink, SmartLinkCondition -from .permissions import (PERMISSION_SMART_LINK_CREATE, - PERMISSION_SMART_LINK_DELETE, - PERMISSION_SMART_LINK_EDIT, - PERMISSION_SMART_LINK_VIEW) +from .permissions import ( + PERMISSION_SMART_LINK_CREATE, PERMISSION_SMART_LINK_DELETE, + PERMISSION_SMART_LINK_EDIT, PERMISSION_SMART_LINK_VIEW +) logger = logging.getLogger(__name__) @@ -45,11 +45,11 @@ def smart_link_instance_view(request, document_id, smart_link_pk): object_list = [] if request.user.is_staff or request.user.is_superuser: - messages.error(request, _(u'Smart link query error: %s' % exception)) + messages.error(request, _('Smart link query error: %s' % exception)) return document_list( request, - title=_(u'Documents in smart link: %s') % smart_link.get_dynamic_title(document), + title=_('Documents in smart link: %s') % smart_link.get_dynamic_title(document), object_list=object_list, extra_context={ 'object': document @@ -64,7 +64,7 @@ def smart_link_instances_for_document(request, document_id): queryset = SmartLink.objects.get_for(document) except Exception as exception: queryset = [] - messages.error(request, _(u'Error calculating smart link for: %(document)s; %(exception)s.') % + messages.error(request, _('Error calculating smart link for: %(document)s; %(exception)s.') % {'document': document, 'exception': exception} ) @@ -79,7 +79,7 @@ def smart_link_instances_for_document(request, document_id): 'document': document, 'object': document, 'object_list': smart_links, - 'title': _(u'Document smart links'), + 'title': _('Document smart links'), 'extra_columns': [ {'name': _('Indentifier'), 'attribute': encapsulate(lambda resolved_smart_link: resolved_smart_link.smart_link.get_dynamic_title(document))}, {'name': _('Documents'), 'attribute': encapsulate(lambda resolved_smart_link: resolved_smart_link.queryset.count())} @@ -109,11 +109,11 @@ def smart_link_list(request): qs = AccessEntry.objects.filter_objects_by_access(PERMISSION_SMART_LINK_VIEW, request.user, qs) return render_to_response('main/generic_list.html', { - 'title': _(u'Smart links'), + 'title': _('Smart links'), 'object_list': qs, 'extra_columns': [ - {'name': _(u'Dynamic title'), 'attribute': 'dynamic_title'}, - {'name': _(u'Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, + {'name': _('Dynamic title'), 'attribute': 'dynamic_title'}, + {'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, ], 'hide_link': True, 'list_object_variable_name': 'smart_link', @@ -129,14 +129,14 @@ def smart_link_create(request): if form.is_valid(): document_group = form.save() apply_default_acls(document_group, request.user) - messages.success(request, _(u'Smart link: %s created successfully.') % document_group) + messages.success(request, _('Smart link: %s created successfully.') % document_group) return HttpResponseRedirect(reverse('linking:smart_link_list')) else: form = SmartLinkForm() return render_to_response('main/generic_form.html', { 'form': form, - 'title': _(u'Create new smart link') + 'title': _('Create new smart link') }, context_instance=RequestContext(request)) @@ -152,7 +152,7 @@ def smart_link_edit(request, smart_link_pk): form = SmartLinkForm(request.POST, instance=smart_link) if form.is_valid(): smart_link = form.save() - messages.success(request, _(u'Smart link: %s edited successfully.') % smart_link) + messages.success(request, _('Smart link: %s edited successfully.') % smart_link) return HttpResponseRedirect(reverse('linking:smart_link_list')) else: form = SmartLinkForm(instance=smart_link) @@ -160,7 +160,7 @@ def smart_link_edit(request, smart_link_pk): return render_to_response('main/generic_form.html', { 'object': smart_link, 'form': form, - 'title': _(u'Edit smart link: %s') % smart_link + 'title': _('Edit smart link: %s') % smart_link }, context_instance=RequestContext(request)) @@ -178,9 +178,9 @@ def smart_link_delete(request, smart_link_pk): if request.method == 'POST': try: smart_link.delete() - messages.success(request, _(u'Smart link: %s deleted successfully.') % smart_link) + messages.success(request, _('Smart link: %s deleted successfully.') % smart_link) except Exception as exception: - messages.error(request, _(u'Error deleting smart link: %(smart_link)s; %(exception)s.') % { + messages.error(request, _('Error deleting smart link: %(smart_link)s; %(exception)s.') % { 'smart_link': smart_link, 'exception': exception }) @@ -189,7 +189,7 @@ def smart_link_delete(request, smart_link_pk): return render_to_response('main/generic_confirm.html', { 'delete_view': True, 'object': smart_link, - 'title': _(u'Are you sure you wish to delete smart link: %s?') % smart_link, + 'title': _('Are you sure you wish to delete smart link: %s?') % smart_link, 'next': next, 'previous': previous, }, context_instance=RequestContext(request)) @@ -226,10 +226,10 @@ def smart_link_condition_list(request, smart_link_pk): AccessEntry.objects.check_accesses([PERMISSION_SMART_LINK_EDIT], request.user, smart_link) return render_to_response('main/generic_list.html', { - 'title': _(u'Conditions for smart link: %s') % smart_link, + 'title': _('Conditions for smart link: %s') % smart_link, 'object_list': smart_link.conditions.all(), 'extra_columns': [ - {'name': _(u'Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, + {'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))}, ], 'hide_link': True, 'object': smart_link, @@ -251,14 +251,14 @@ def smart_link_condition_create(request, smart_link_pk): new_smart_link_condition = form.save(commit=False) new_smart_link_condition.smart_link = smart_link new_smart_link_condition.save() - messages.success(request, _(u'Smart link condition: "%s" created successfully.') % new_smart_link_condition) + messages.success(request, _('Smart link condition: "%s" created successfully.') % new_smart_link_condition) return HttpResponseRedirect(reverse('linking:smart_link_condition_list', args=[smart_link.pk])) else: form = SmartLinkConditionForm() return render_to_response('main/generic_form.html', { 'form': form, - 'title': _(u'Add new conditions to smart link: "%s"') % smart_link, + 'title': _('Add new conditions to smart link: "%s"') % smart_link, 'object': smart_link, }, context_instance=RequestContext(request)) @@ -278,21 +278,21 @@ def smart_link_condition_edit(request, smart_link_condition_pk): form = SmartLinkConditionForm(request.POST, instance=smart_link_condition) if form.is_valid(): smart_link_condition = form.save() - messages.success(request, _(u'Smart link condition: "%s" edited successfully.') % smart_link_condition) + messages.success(request, _('Smart link condition: "%s" edited successfully.') % smart_link_condition) return HttpResponseRedirect(next) else: form = SmartLinkConditionForm(instance=smart_link_condition) return render_to_response('main/generic_form.html', { 'form': form, - 'title': _(u'Edit smart link condition'), + 'title': _('Edit smart link condition'), 'next': next, 'previous': previous, 'condition': smart_link_condition, 'object': smart_link_condition.smart_link, 'navigation_object_list': [ - {'object': 'object', 'name': _(u'Smart link')}, - {'object': 'condition', 'name': _(u'Condition')} + {'object': 'object', 'name': _('Smart link')}, + {'object': 'condition', 'name': _('Condition')} ], }, context_instance=RequestContext(request)) @@ -312,9 +312,9 @@ def smart_link_condition_delete(request, smart_link_condition_pk): if request.method == 'POST': try: smart_link_condition.delete() - messages.success(request, _(u'Smart link condition: "%s" deleted successfully.') % smart_link_condition) + messages.success(request, _('Smart link condition: "%s" deleted successfully.') % smart_link_condition) except Exception as exception: - messages.error(request, _(u'Error deleting smart link condition: %(smart_link_condition)s; %(exception)s.') % { + messages.error(request, _('Error deleting smart link condition: %(smart_link_condition)s; %(exception)s.') % { 'smart_link_condition': smart_link_condition, 'exception': exception }) @@ -325,10 +325,10 @@ def smart_link_condition_delete(request, smart_link_condition_pk): 'condition': smart_link_condition, 'object': smart_link_condition.smart_link, 'navigation_object_list': [ - {'object': 'object', 'name': _(u'Smart link')}, - {'object': 'condition', 'name': _(u'Condition')} + {'object': 'object', 'name': _('Smart link')}, + {'object': 'condition', 'name': _('Condition')} ], - 'title': _(u'Are you sure you wish to delete smart link condition: "%s"?') % smart_link_condition, + 'title': _('Are you sure you wish to delete smart link condition: "%s"?') % smart_link_condition, 'next': next, 'previous': previous, }, context_instance=RequestContext(request)) diff --git a/mayan/apps/lock_manager/__init__.py b/mayan/apps/lock_manager/__init__.py index 0f834c7d6b..b5258b2251 100644 --- a/mayan/apps/lock_manager/__init__.py +++ b/mayan/apps/lock_manager/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from .exceptions import LockError # NOQA from .models import Lock as LockModel diff --git a/mayan/apps/lock_manager/admin.py b/mayan/apps/lock_manager/admin.py index d8c353e7e3..b6f1a48744 100644 --- a/mayan/apps/lock_manager/admin.py +++ b/mayan/apps/lock_manager/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from .models import Lock diff --git a/mayan/apps/lock_manager/managers.py b/mayan/apps/lock_manager/managers.py index ec5baf9192..9ffaa6f8a3 100644 --- a/mayan/apps/lock_manager/managers.py +++ b/mayan/apps/lock_manager/managers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import datetime import logging diff --git a/mayan/apps/lock_manager/models.py b/mayan/apps/lock_manager/models.py index e1b1a3257b..3de78a7d1b 100644 --- a/mayan/apps/lock_manager/models.py +++ b/mayan/apps/lock_manager/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -8,9 +8,9 @@ from .settings import DEFAULT_LOCK_TIMEOUT class Lock(models.Model): - creation_datetime = models.DateTimeField(verbose_name=_(u'Creation datetime'), auto_now_add=True) - timeout = models.IntegerField(default=DEFAULT_LOCK_TIMEOUT, verbose_name=_(u'Timeout')) - name = models.CharField(max_length=48, verbose_name=_(u'Name'), unique=True) + creation_datetime = models.DateTimeField(verbose_name=_('Creation datetime'), auto_now_add=True) + timeout = models.IntegerField(default=DEFAULT_LOCK_TIMEOUT, verbose_name=_('Timeout')) + name = models.CharField(max_length=48, verbose_name=_('Name'), unique=True) objects = LockManager() @@ -33,5 +33,5 @@ class Lock(models.Model): lock.delete() class Meta: - verbose_name = _(u'Lock') - verbose_name_plural = _(u'Locks') + verbose_name = _('Lock') + verbose_name_plural = _('Locks') diff --git a/mayan/apps/lock_manager/settings.py b/mayan/apps/lock_manager/settings.py index 869e121f4d..bbbbd3bbcc 100644 --- a/mayan/apps/lock_manager/settings.py +++ b/mayan/apps/lock_manager/settings.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf import settings DEFAULT_LOCK_TIMEOUT_VALUE = 30 diff --git a/mayan/apps/lock_manager/tests.py b/mayan/apps/lock_manager/tests.py index 96ec3491e4..4235064cef 100644 --- a/mayan/apps/lock_manager/tests.py +++ b/mayan/apps/lock_manager/tests.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import time diff --git a/mayan/apps/mailer/__init__.py b/mayan/apps/mailer/__init__.py index 862148eef4..96f514d073 100644 --- a/mayan/apps/mailer/__init__.py +++ b/mayan/apps/mailer/__init__.py @@ -1,13 +1,14 @@ -from __future__ import absolute_import - from acls.api import class_permissions from documents.models import Document from navigation.api import register_links from .links import send_document_link, send_document -from .permissions import PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT +from .permissions import ( + PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT +) register_links([Document], [send_document_link, send_document]) -class_permissions(Document, [PERMISSION_MAILING_LINK, - PERMISSION_MAILING_SEND_DOCUMENT]) +class_permissions(Document, [ + PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT +]) diff --git a/mayan/apps/mailer/forms.py b/mayan/apps/mailer/forms.py index 95716677fe..b9fce99998 100644 --- a/mayan/apps/mailer/forms.py +++ b/mayan/apps/mailer/forms.py @@ -1,10 +1,12 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms from django.utils.translation import ugettext as _ -from .settings import (DOCUMENT_BODY_TEMPLATE, DOCUMENT_SUBJECT_TEMPLATE, - LINK_BODY_TEMPLATE, LINK_SUBJECT_TEMPLATE) +from .settings import ( + DOCUMENT_BODY_TEMPLATE, DOCUMENT_SUBJECT_TEMPLATE, LINK_BODY_TEMPLATE, + LINK_SUBJECT_TEMPLATE +) class DocumentMailForm(forms.Form): @@ -18,6 +20,6 @@ class DocumentMailForm(forms.Form): self.fields['subject'].initial = LINK_SUBJECT_TEMPLATE self.fields['body'].initial = LINK_BODY_TEMPLATE - email = forms.EmailField(label=_(u'Email address')) - subject = forms.CharField(label=_(u'Subject'), required=False) - body = forms.CharField(label=_(u'Body'), widget=forms.widgets.Textarea(), required=False) + email = forms.EmailField(label=_('Email address')) + subject = forms.CharField(label=_('Subject'), required=False) + body = forms.CharField(label=_('Body'), widget=forms.widgets.Textarea(), required=False) diff --git a/mayan/apps/mailer/links.py b/mayan/apps/mailer/links.py index 589abdaef9..efff6e070f 100644 --- a/mayan/apps/mailer/links.py +++ b/mayan/apps/mailer/links.py @@ -1,8 +1,8 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from .permissions import PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT send_document_link = {'text': _('Email link'), 'view': 'mailer:send_document_link', 'args': 'object.pk', 'famfam': 'email_link', 'permissions': [PERMISSION_MAILING_LINK]} -send_document = {'text': _(u'Email document'), 'view': 'mailer:send_document', 'args': 'object.pk', 'famfam': 'email_open', 'permissions': [PERMISSION_MAILING_SEND_DOCUMENT]} +send_document = {'text': _('Email document'), 'view': 'mailer:send_document', 'args': 'object.pk', 'famfam': 'email_open', 'permissions': [PERMISSION_MAILING_SEND_DOCUMENT]} diff --git a/mayan/apps/mailer/permissions.py b/mayan/apps/mailer/permissions.py index a318bd7085..9b79a02e94 100644 --- a/mayan/apps/mailer/permissions.py +++ b/mayan/apps/mailer/permissions.py @@ -1,10 +1,10 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import Permission, PermissionNamespace -mailer_namespace = PermissionNamespace('mailing', _(u'Mailing')) +mailer_namespace = PermissionNamespace('mailing', _('Mailing')) -PERMISSION_MAILING_LINK = Permission.objects.register(mailer_namespace, 'mail_link', _(u'Send document link via email')) -PERMISSION_MAILING_SEND_DOCUMENT = Permission.objects.register(mailer_namespace, 'mail_document', _(u'Send document via email')) +PERMISSION_MAILING_LINK = Permission.objects.register(mailer_namespace, 'mail_link', _('Send document link via email')) +PERMISSION_MAILING_SEND_DOCUMENT = Permission.objects.register(mailer_namespace, 'mail_document', _('Send document via email')) diff --git a/mayan/apps/mailer/settings.py b/mayan/apps/mailer/settings.py index e1e58936ed..35bb3434ff 100644 --- a/mayan/apps/mailer/settings.py +++ b/mayan/apps/mailer/settings.py @@ -1,4 +1,4 @@ -"""Configuration options for the mailer app""" +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -9,8 +9,8 @@ register_settings( module='mailer.settings', settings=[ {'name': 'LINK_SUBJECT_TEMPLATE', 'global_name': 'MAILER_LINK_SUBJECT_TEMPLATE', 'default': _('Link for document: {{ document }}'), 'description': _('Template for the document link email form subject line.')}, - {'name': 'LINK_BODY_TEMPLATE', 'global_name': 'MAILER_LINK_BODY_TEMPLATE', 'default': _(u'To access this document click on the following link: {{ link }}

\n\n--------
\nThis email has been sent from Mayan EDMS (http://www.mayan-edms.com)'), 'description': _(u'Template for the document link email form body line.')}, - {'name': 'DOCUMENT_SUBJECT_TEMPLATE', 'global_name': 'MAILER_DOCUMENT_SUBJECT_TEMPLATE', 'default': _(u'Document: {{ document }}'), 'description': _(u'Template for the document email form subject line.')}, - {'name': 'DOCUMENT_BODY_TEMPLATE', 'global_name': 'MAILER_DOCUMENT_BODY_TEMPLATE', 'default': _(u'Attached to this email is the document: {{ document }}

\n\n--------
\nThis email has been sent from Mayan EDMS (http://www.mayan-edms.com)'), 'description': _(u'Template for the document email form body line.')}, + {'name': 'LINK_BODY_TEMPLATE', 'global_name': 'MAILER_LINK_BODY_TEMPLATE', 'default': _('To access this document click on the following link: {{ link }}

\n\n--------
\nThis email has been sent from Mayan EDMS (http://www.mayan-edms.com)'), 'description': _('Template for the document link email form body line.')}, + {'name': 'DOCUMENT_SUBJECT_TEMPLATE', 'global_name': 'MAILER_DOCUMENT_SUBJECT_TEMPLATE', 'default': _('Document: {{ document }}'), 'description': _('Template for the document email form subject line.')}, + {'name': 'DOCUMENT_BODY_TEMPLATE', 'global_name': 'MAILER_DOCUMENT_BODY_TEMPLATE', 'default': _('Attached to this email is the document: {{ document }}

\n\n--------
\nThis email has been sent from Mayan EDMS (http://www.mayan-edms.com)'), 'description': _('Template for the document email form body line.')}, ] ) diff --git a/mayan/apps/mailer/tasks.py b/mayan/apps/mailer/tasks.py index 42e60c9920..9bc09613c8 100644 --- a/mayan/apps/mailer/tasks.py +++ b/mayan/apps/mailer/tasks.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.core.mail import EmailMultiAlternatives from documents.models import Document diff --git a/mayan/apps/mailer/urls.py b/mayan/apps/mailer/urls.py index f880bd7fd9..73b5ecdaf6 100644 --- a/mayan/apps/mailer/urls.py +++ b/mayan/apps/mailer/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('mailer.views', diff --git a/mayan/apps/mailer/views.py b/mayan/apps/mailer/views.py index 17b68b7eb2..30ebc5f0c4 100644 --- a/mayan/apps/mailer/views.py +++ b/mayan/apps/mailer/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.contrib import messages from django.contrib.sites.models import Site @@ -15,8 +15,9 @@ from documents.models import Document from permissions.models import Permission from .forms import DocumentMailForm -from .permissions import (PERMISSION_MAILING_LINK, - PERMISSION_MAILING_SEND_DOCUMENT) +from .permissions import ( + PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT +) from .tasks import task_send_document diff --git a/mayan/apps/main/__init__.py b/mayan/apps/main/__init__.py index a4e36e49b2..86bd0ce7b2 100644 --- a/mayan/apps/main/__init__.py +++ b/mayan/apps/main/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -8,6 +8,6 @@ from project_tools.api import register_tool from .links import admin_site, maintenance_menu -register_top_menu('home', link={'text': _(u'Home'), 'view': 'main:home', 'famfam': 'house'}, position=0) +register_top_menu('home', link={'text': _('Home'), 'view': 'main:home', 'famfam': 'house'}, position=0) register_setup(admin_site) register_tool(maintenance_menu) diff --git a/mayan/apps/main/api.py b/mayan/apps/main/api.py index 3f781eb075..9d32452296 100644 --- a/mayan/apps/main/api.py +++ b/mayan/apps/main/api.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.core.urlresolvers import reverse from django.utils.functional import lazy diff --git a/mayan/apps/main/links.py b/mayan/apps/main/links.py index 9af605cc23..a7b992b5cf 100644 --- a/mayan/apps/main/links.py +++ b/mayan/apps/main/links.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ @@ -5,5 +7,5 @@ def is_superuser(context): return context['request'].user.is_staff or context['request'].user.is_superuser -maintenance_menu = {'text': _(u'Maintenance'), 'view': 'main:maintenance_menu', 'famfam': 'wrench', 'icon': 'wrench.png'} -admin_site = {'text': _(u'Admin site'), 'view': 'admin:index', 'famfam': 'keyboard', 'icon': 'keyboard.png', 'condition': is_superuser} +maintenance_menu = {'text': _('Maintenance'), 'view': 'main:maintenance_menu', 'famfam': 'wrench', 'icon': 'wrench.png'} +admin_site = {'text': _('Admin site'), 'view': 'admin:index', 'famfam': 'keyboard', 'icon': 'keyboard.png', 'condition': is_superuser} diff --git a/mayan/apps/main/management/commands/initialsetup.py b/mayan/apps/main/management/commands/initialsetup.py index 524b7a55fc..bfe52f2a14 100644 --- a/mayan/apps/main/management/commands/initialsetup.py +++ b/mayan/apps/main/management/commands/initialsetup.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import os from django.conf import settings diff --git a/mayan/apps/main/templatetags/styling.py b/mayan/apps/main/templatetags/styling.py index 4b1f0b5ff3..79d9bcca94 100644 --- a/mayan/apps/main/templatetags/styling.py +++ b/mayan/apps/main/templatetags/styling.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django import forms from django.template import Library, Node, Variable @@ -14,16 +16,16 @@ class StylingNode(Node): if isinstance(field.widget, forms.widgets.TextInput): # Don't overwrite any existing CSS class, append - css_class = field.widget.attrs.get('class', u'text_field') - field.widget.attrs['class'] = u' '.join([css_class, 'text_field']) + css_class = field.widget.attrs.get('class', 'text_field') + field.widget.attrs['class'] = ' '.join([css_class, 'text_field']) elif isinstance(field.widget, forms.widgets.PasswordInput): # Don't overwrite any existing CSS class, append - css_class = field.widget.attrs.get('class', u'text_field') - field.widget.attrs['class'] = u' '.join([css_class, 'text_field']) + css_class = field.widget.attrs.get('class', 'text_field') + field.widget.attrs['class'] = ' '.join([css_class, 'text_field']) elif isinstance(field.widget, forms.widgets.Textarea): # Don't overwrite any existing CSS class, append - css_class = field.widget.attrs.get('class', u'text_area') - field.widget.attrs['class'] = u' '.join([css_class, 'text_area']) + css_class = field.widget.attrs.get('class', 'text_area') + field.widget.attrs['class'] = ' '.join([css_class, 'text_area']) context[self.form_name] = form return '' diff --git a/mayan/apps/main/templatetags/theme_tags.py b/mayan/apps/main/templatetags/theme_tags.py index 1b1f89fd7d..83b9848971 100644 --- a/mayan/apps/main/templatetags/theme_tags.py +++ b/mayan/apps/main/templatetags/theme_tags.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf import settings from django.core.urlresolvers import reverse diff --git a/mayan/apps/main/urls.py b/mayan/apps/main/urls.py index 444d4f81a9..a9abfe1706 100644 --- a/mayan/apps/main/urls.py +++ b/mayan/apps/main/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('main.views', diff --git a/mayan/apps/main/views.py b/mayan/apps/main/views.py index cb82a47e9c..60329956f7 100644 --- a/mayan/apps/main/views.py +++ b/mayan/apps/main/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse @@ -29,7 +29,7 @@ def home(request): context.update({ 'object_list': queryset, 'time_delta': timedelta, - 'title': _(u'Results'), + 'title': _('Results'), }) return render_to_response('main/home.html', context, context_instance=RequestContext(request)) @@ -52,12 +52,12 @@ def maintenance_menu(request): return render_to_response('main/tools.html', { 'blocks': user_tools, - 'title': _(u'Maintenance menu') + 'title': _('Maintenance menu') }, context_instance=RequestContext(request)) def diagnostics_view(request): return render_to_response('main/diagnostics.html', { 'blocks': diagnostics, - 'title': _(u'Diagnostics') + 'title': _('Diagnostics') }, context_instance=RequestContext(request)) diff --git a/mayan/apps/metadata/__init__.py b/mayan/apps/metadata/__init__.py index 97f1aebc90..6608d6ec28 100644 --- a/mayan/apps/metadata/__init__.py +++ b/mayan/apps/metadata/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -19,19 +19,19 @@ from rest_api.classes import APIEndPoint from .api import get_metadata_string from .classes import DocumentMetadataHelper -from .links import (metadata_add, metadata_edit, metadata_multiple_add, - metadata_multiple_edit, metadata_multiple_remove, - metadata_remove, metadata_view, - setup_document_type_metadata, - setup_document_type_metadata_required, - setup_metadata_type_create, setup_metadata_type_delete, - setup_metadata_type_edit, setup_metadata_type_list, - link_documents_missing_required_metadata) +from .links import ( + metadata_add, metadata_edit, metadata_multiple_add, metadata_multiple_edit, + metadata_multiple_remove, metadata_remove, metadata_view, + setup_document_type_metadata, setup_document_type_metadata_required, + setup_metadata_type_create, setup_metadata_type_delete, + setup_metadata_type_edit, setup_metadata_type_list, + link_documents_missing_required_metadata +) from .models import DocumentMetadata, DocumentTypeMetadataType, MetadataType -from .permissions import (PERMISSION_METADATA_DOCUMENT_ADD, - PERMISSION_METADATA_DOCUMENT_EDIT, - PERMISSION_METADATA_DOCUMENT_REMOVE, - PERMISSION_METADATA_DOCUMENT_VIEW) +from .permissions import ( + PERMISSION_METADATA_DOCUMENT_ADD, PERMISSION_METADATA_DOCUMENT_EDIT, + PERMISSION_METADATA_DOCUMENT_REMOVE, PERMISSION_METADATA_DOCUMENT_VIEW +) from .tasks import task_add_required_metadata_type, task_remove_metadata_type logger = logging.getLogger(__name__) @@ -83,7 +83,7 @@ class_permissions(Document, [ register_model_list_columns(Document, [ { - 'name': _(u'Metadata'), 'attribute': encapsulate(lambda x: get_metadata_string(x)) + 'name': _('Metadata'), 'attribute': encapsulate(lambda x: get_metadata_string(x)) }, ]) diff --git a/mayan/apps/metadata/admin.py b/mayan/apps/metadata/admin.py index 2f2b9f2a72..4e85946372 100644 --- a/mayan/apps/metadata/admin.py +++ b/mayan/apps/metadata/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin diff --git a/mayan/apps/metadata/api.py b/mayan/apps/metadata/api.py index 8980f651b5..50c9f68024 100644 --- a/mayan/apps/metadata/api.py +++ b/mayan/apps/metadata/api.py @@ -1,5 +1,4 @@ -"""Metadata handling commonalities""" -from __future__ import absolute_import +from __future__ import unicode_literals from urllib import unquote_plus @@ -83,7 +82,7 @@ def metadata_repr(metadata_list): """ Return a printable representation of a metadata list """ - return u', '.join(metadata_repr_as_list(metadata_list)) + return ', '.join(metadata_repr_as_list(metadata_list)) def metadata_repr_as_list(metadata_list): @@ -93,7 +92,7 @@ def metadata_repr_as_list(metadata_list): output = [] for metadata_dict in metadata_list: try: - output.append(u'%s - %s' % (MetadataType.objects.get( + output.append('%s - %s' % (MetadataType.objects.get( pk=metadata_dict['id']), metadata_dict.get('value', ''))) except: pass @@ -105,7 +104,7 @@ def get_metadata_string(document): """ Return a formated representation of a document's metadata values """ - return u', '.join([u'%s - %s' % (document_metadata.metadata_type, document_metadata.value) for document_metadata in document.metadata.all()]) + return ', '.join(['%s - %s' % (document_metadata.metadata_type, document_metadata.value) for document_metadata in document.metadata.all()]) def convert_dict_to_dict_list(dictionary): diff --git a/mayan/apps/metadata/api_views.py b/mayan/apps/metadata/api_views.py index b341f80d83..8921117b5f 100644 --- a/mayan/apps/metadata/api_views.py +++ b/mayan/apps/metadata/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 @@ -8,26 +8,25 @@ from rest_framework.response import Response from acls.models import AccessEntry from documents.models import Document, DocumentType -from documents.permissions import (PERMISSION_DOCUMENT_TYPE_VIEW, - PERMISSION_DOCUMENT_TYPE_EDIT) +from documents.permissions import ( + PERMISSION_DOCUMENT_TYPE_VIEW, PERMISSION_DOCUMENT_TYPE_EDIT +) from permissions.models import Permission from rest_api.filters import MayanObjectPermissionsFilter from rest_api.permissions import MayanPermission from .models import DocumentMetadata, MetadataType -from .permissions import (PERMISSION_METADATA_DOCUMENT_ADD, - PERMISSION_METADATA_DOCUMENT_REMOVE, - PERMISSION_METADATA_DOCUMENT_EDIT, - PERMISSION_METADATA_DOCUMENT_VIEW, - PERMISSION_METADATA_TYPE_CREATE, - PERMISSION_METADATA_TYPE_DELETE, - PERMISSION_METADATA_TYPE_EDIT, - PERMISSION_METADATA_TYPE_VIEW) -from .serializers import (DocumentMetadataSerializer, - DocumentNewMetadataSerializer, - DocumentTypeNewMetadataTypeSerializer, - MetadataTypeSerializer) +from .permissions import ( + PERMISSION_METADATA_DOCUMENT_ADD, PERMISSION_METADATA_DOCUMENT_REMOVE, + PERMISSION_METADATA_DOCUMENT_EDIT, PERMISSION_METADATA_DOCUMENT_VIEW, + PERMISSION_METADATA_TYPE_CREATE, PERMISSION_METADATA_TYPE_DELETE, + PERMISSION_METADATA_TYPE_EDIT, PERMISSION_METADATA_TYPE_VIEW +) +from .serializers import ( + DocumentMetadataSerializer, DocumentNewMetadataSerializer, + DocumentTypeNewMetadataTypeSerializer, MetadataTypeSerializer +) class APIMetadataTypeListView(generics.ListCreateAPIView): diff --git a/mayan/apps/metadata/classes.py b/mayan/apps/metadata/classes.py index 467b8e1c9e..d85bd60827 100644 --- a/mayan/apps/metadata/classes.py +++ b/mayan/apps/metadata/classes.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ from .models import MetadataType @@ -16,4 +18,4 @@ class DocumentMetadataHelper(object): try: return self.instance.metadata.get(metadata_type__name=name).value except MetadataType.DoesNotExist: - raise AttributeError(_(u'\'metadata\' object has no attribute \'%s\'') % name) + raise AttributeError(_('\'metadata\' object has no attribute \'%s\'') % name) diff --git a/mayan/apps/metadata/forms.py b/mayan/apps/metadata/forms.py index c358b924b8..c835fabc0c 100644 --- a/mayan/apps/metadata/forms.py +++ b/mayan/apps/metadata/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms from django.core.exceptions import ValidationError @@ -34,7 +34,7 @@ class MetadataForm(forms.Form): # Otherwise we extract whatever single message the exception # included. try: - message = u', '.join(exception.messages) + message = ', '.join(exception.messages) except AttributeError: message = unicode(exception) @@ -56,11 +56,11 @@ class MetadataForm(forms.Form): if 'initial' in kwargs: self.metadata_type = kwargs['initial'].pop('metadata_type', None) required = kwargs['initial'].pop('required', False) - required_string = u'' + required_string = '' if required: self.fields['value'].required = True - required_string = u' (%s)' % _('Required') + required_string = ' (%s)' % _('Required') else: self.fields['value'].required = False @@ -86,17 +86,17 @@ class MetadataForm(forms.Form): except Exception as exception: self.fields['value'].initial = exception - id = forms.CharField(label=_(u'ID'), widget=forms.HiddenInput) + id = forms.CharField(label=_('ID'), widget=forms.HiddenInput) - name = forms.CharField(label=_(u'Name'), required=False, widget=forms.TextInput(attrs={'readonly': 'readonly'})) - value = forms.CharField(label=_(u'Value'), required=False) - update = forms.BooleanField(initial=True, label=_(u'Update'), required=False) + name = forms.CharField(label=_('Name'), required=False, widget=forms.TextInput(attrs={'readonly': 'readonly'})) + value = forms.CharField(label=_('Value'), required=False) + update = forms.BooleanField(initial=True, label=_('Update'), required=False) MetadataFormSet = formset_factory(MetadataForm, extra=0) class AddMetadataForm(forms.Form): - metadata_type = forms.ModelChoiceField(queryset=MetadataType.objects.all(), label=_(u'Metadata type')) + metadata_type = forms.ModelChoiceField(queryset=MetadataType.objects.all(), label=_('Metadata type')) def __init__(self, *args, **kwargs): document_type = kwargs.pop('document_type') @@ -105,7 +105,7 @@ class AddMetadataForm(forms.Form): class MetadataRemoveForm(MetadataForm): - update = forms.BooleanField(initial=False, label=_(u'Remove'), required=False) + update = forms.BooleanField(initial=False, label=_('Remove'), required=False) def __init__(self, *args, **kwargs): super(MetadataRemoveForm, self).__init__(*args, **kwargs) diff --git a/mayan/apps/metadata/links.py b/mayan/apps/metadata/links.py index eb269380f0..c51fcf960e 100644 --- a/mayan/apps/metadata/links.py +++ b/mayan/apps/metadata/links.py @@ -1,33 +1,31 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from documents.permissions import PERMISSION_DOCUMENT_TYPE_EDIT -from .permissions import (PERMISSION_METADATA_DOCUMENT_ADD, - PERMISSION_METADATA_DOCUMENT_EDIT, - PERMISSION_METADATA_DOCUMENT_REMOVE, - PERMISSION_METADATA_DOCUMENT_VIEW, - PERMISSION_METADATA_TYPE_CREATE, - PERMISSION_METADATA_TYPE_DELETE, - PERMISSION_METADATA_TYPE_EDIT, - PERMISSION_METADATA_TYPE_VIEW) +from .permissions import ( + PERMISSION_METADATA_DOCUMENT_ADD, PERMISSION_METADATA_DOCUMENT_EDIT, + PERMISSION_METADATA_DOCUMENT_REMOVE, PERMISSION_METADATA_DOCUMENT_VIEW, + PERMISSION_METADATA_TYPE_CREATE, PERMISSION_METADATA_TYPE_DELETE, + PERMISSION_METADATA_TYPE_EDIT, PERMISSION_METADATA_TYPE_VIEW +) -metadata_edit = {'text': _(u'Edit metadata'), 'view': 'metadata:metadata_edit', 'args': 'object.pk', 'famfam': 'xhtml_go', 'permissions': [PERMISSION_METADATA_DOCUMENT_EDIT]} -metadata_view = {'text': _(u'Metadata'), 'view': 'metadata:metadata_view', 'args': 'object.pk', 'famfam': 'xhtml_go', 'permissions': [PERMISSION_METADATA_DOCUMENT_VIEW]} -metadata_multiple_edit = {'text': _(u'Edit metadata'), 'view': 'metadata:metadata_multiple_edit', 'famfam': 'xhtml_go', 'permissions': [PERMISSION_METADATA_DOCUMENT_EDIT]} -metadata_add = {'text': _(u'Add metadata'), 'view': 'metadata:metadata_add', 'args': 'object.pk', 'famfam': 'xhtml_add', 'permissions': [PERMISSION_METADATA_DOCUMENT_ADD]} -metadata_multiple_add = {'text': _(u'Add metadata'), 'view': 'metadata:metadata_multiple_add', 'famfam': 'xhtml_add', 'permissions': [PERMISSION_METADATA_DOCUMENT_ADD]} -metadata_remove = {'text': _(u'Remove metadata'), 'view': 'metadata:metadata_remove', 'args': 'object.pk', 'famfam': 'xhtml_delete', 'permissions': [PERMISSION_METADATA_DOCUMENT_REMOVE]} -metadata_multiple_remove = {'text': _(u'Remove metadata'), 'view': 'metadata:metadata_multiple_remove', 'famfam': 'xhtml_delete', 'permissions': [PERMISSION_METADATA_DOCUMENT_REMOVE]} +metadata_edit = {'text': _('Edit metadata'), 'view': 'metadata:metadata_edit', 'args': 'object.pk', 'famfam': 'xhtml_go', 'permissions': [PERMISSION_METADATA_DOCUMENT_EDIT]} +metadata_view = {'text': _('Metadata'), 'view': 'metadata:metadata_view', 'args': 'object.pk', 'famfam': 'xhtml_go', 'permissions': [PERMISSION_METADATA_DOCUMENT_VIEW]} +metadata_multiple_edit = {'text': _('Edit metadata'), 'view': 'metadata:metadata_multiple_edit', 'famfam': 'xhtml_go', 'permissions': [PERMISSION_METADATA_DOCUMENT_EDIT]} +metadata_add = {'text': _('Add metadata'), 'view': 'metadata:metadata_add', 'args': 'object.pk', 'famfam': 'xhtml_add', 'permissions': [PERMISSION_METADATA_DOCUMENT_ADD]} +metadata_multiple_add = {'text': _('Add metadata'), 'view': 'metadata:metadata_multiple_add', 'famfam': 'xhtml_add', 'permissions': [PERMISSION_METADATA_DOCUMENT_ADD]} +metadata_remove = {'text': _('Remove metadata'), 'view': 'metadata:metadata_remove', 'args': 'object.pk', 'famfam': 'xhtml_delete', 'permissions': [PERMISSION_METADATA_DOCUMENT_REMOVE]} +metadata_multiple_remove = {'text': _('Remove metadata'), 'view': 'metadata:metadata_multiple_remove', 'famfam': 'xhtml_delete', 'permissions': [PERMISSION_METADATA_DOCUMENT_REMOVE]} -setup_document_type_metadata = {'text': _(u'Optional metadata'), 'view': 'metadata:setup_document_type_metadata', 'args': 'document_type.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} -setup_document_type_metadata_required = {'text': _(u'Required metadata'), 'view': 'metadata:setup_document_type_metadata_required', 'args': 'document_type.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} +setup_document_type_metadata = {'text': _('Optional metadata'), 'view': 'metadata:setup_document_type_metadata', 'args': 'document_type.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} +setup_document_type_metadata_required = {'text': _('Required metadata'), 'view': 'metadata:setup_document_type_metadata_required', 'args': 'document_type.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]} -setup_metadata_type_list = {'text': _(u'Metadata types'), 'view': 'metadata:setup_metadata_type_list', 'famfam': 'xhtml_go', 'icon': 'xhtml.png', 'permissions': [PERMISSION_METADATA_TYPE_VIEW]} -setup_metadata_type_edit = {'text': _(u'Edit'), 'view': 'metadata:setup_metadata_type_edit', 'args': 'object.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_METADATA_TYPE_EDIT]} -setup_metadata_type_delete = {'text': _(u'Delete'), 'view': 'metadata:setup_metadata_type_delete', 'args': 'object.pk', 'famfam': 'xhtml_delete', 'permissions': [PERMISSION_METADATA_TYPE_DELETE]} -setup_metadata_type_create = {'text': _(u'Create new'), 'view': 'metadata:setup_metadata_type_create', 'famfam': 'xhtml_add', 'permissions': [PERMISSION_METADATA_TYPE_CREATE]} +setup_metadata_type_list = {'text': _('Metadata types'), 'view': 'metadata:setup_metadata_type_list', 'famfam': 'xhtml_go', 'icon': 'xhtml.png', 'permissions': [PERMISSION_METADATA_TYPE_VIEW]} +setup_metadata_type_edit = {'text': _('Edit'), 'view': 'metadata:setup_metadata_type_edit', 'args': 'object.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_METADATA_TYPE_EDIT]} +setup_metadata_type_delete = {'text': _('Delete'), 'view': 'metadata:setup_metadata_type_delete', 'args': 'object.pk', 'famfam': 'xhtml_delete', 'permissions': [PERMISSION_METADATA_TYPE_DELETE]} +setup_metadata_type_create = {'text': _('Create new'), 'view': 'metadata:setup_metadata_type_create', 'famfam': 'xhtml_add', 'permissions': [PERMISSION_METADATA_TYPE_CREATE]} -link_documents_missing_required_metadata = {'text': _(u'Missing metadata'), 'view': 'metadata:documents_missing_required_metadata', 'icon': 'to_do_list.png'} +link_documents_missing_required_metadata = {'text': _('Missing metadata'), 'view': 'metadata:documents_missing_required_metadata', 'icon': 'to_do_list.png'} diff --git a/mayan/apps/metadata/managers.py b/mayan/apps/metadata/managers.py index a74372af40..5f2fcd3dae 100644 --- a/mayan/apps/metadata/managers.py +++ b/mayan/apps/metadata/managers.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.db import models diff --git a/mayan/apps/metadata/models.py b/mayan/apps/metadata/models.py index 6b810aed00..61d1d746af 100644 --- a/mayan/apps/metadata/models.py +++ b/mayan/apps/metadata/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import ValidationError from django.db import models @@ -14,18 +14,18 @@ class MetadataType(models.Model): """ Define a type of metadata """ - name = models.CharField(unique=True, max_length=48, verbose_name=_(u'Name'), help_text=_(u'Do not use python reserved words, or spaces.')) + name = models.CharField(unique=True, max_length=48, verbose_name=_('Name'), help_text=_('Do not use python reserved words, or spaces.')) # TODO: normalize 'title' to 'label' - title = models.CharField(max_length=48, verbose_name=_(u'Title')) + title = models.CharField(max_length=48, verbose_name=_('Title')) default = models.CharField(max_length=128, blank=True, null=True, - verbose_name=_(u'Default'), - help_text=_(u'Enter a string to be evaluated.')) + verbose_name=_('Default'), + help_text=_('Enter a string to be evaluated.')) # TODO: Add enable_lookup boolean to allow users to switch the lookup on and # off without losing the lookup expression lookup = models.TextField(blank=True, null=True, - verbose_name=_(u'Lookup'), - help_text=_(u'Enter a string to be evaluated that returns an iterable.')) - validation = models.CharField(blank=True, choices=zip(AVAILABLE_VALIDATORS, AVAILABLE_VALIDATORS), max_length=64, verbose_name=_(u'Validation function name')) + verbose_name=_('Lookup'), + help_text=_('Enter a string to be evaluated that returns an iterable.')) + validation = models.CharField(blank=True, choices=zip(AVAILABLE_VALIDATORS, AVAILABLE_VALIDATORS), max_length=64, verbose_name=_('Validation function name')) # TODO: Find a different way to let users know what models and functions are # available now that we removed these from the help_text objects = MetadataTypeManager() @@ -38,8 +38,8 @@ class MetadataType(models.Model): class Meta: ordering = ('title',) - verbose_name = _(u'Metadata type') - verbose_name_plural = _(u'Metadata types') + verbose_name = _('Metadata type') + verbose_name_plural = _('Metadata types') class DocumentMetadata(models.Model): @@ -47,9 +47,9 @@ class DocumentMetadata(models.Model): Link a document to a specific instance of a metadata type with it's current value """ - document = models.ForeignKey(Document, related_name='metadata', verbose_name=_(u'Document')) - metadata_type = models.ForeignKey(MetadataType, verbose_name=_(u'Type')) - value = models.CharField(max_length=255, blank=True, null=True, verbose_name=_(u'Value'), db_index=True) + document = models.ForeignKey(Document, related_name='metadata', verbose_name=_('Document')) + 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): return unicode(self.metadata_type) @@ -68,13 +68,13 @@ class DocumentMetadata(models.Model): class Meta: unique_together = ('document', 'metadata_type') - verbose_name = _(u'Document metadata') - verbose_name_plural = _(u'Document metadata') + verbose_name = _('Document metadata') + verbose_name_plural = _('Document metadata') class DocumentTypeMetadataType(models.Model): - document_type = models.ForeignKey(DocumentType, related_name='metadata', verbose_name=_(u'Document type')) - metadata_type = models.ForeignKey(MetadataType, verbose_name=_(u'Metadata type')) + 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): @@ -82,5 +82,5 @@ class DocumentTypeMetadataType(models.Model): class Meta: unique_together = ('document_type', 'metadata_type') - verbose_name = _(u'Document type metadata type options') - verbose_name_plural = _(u'Document type metadata types options') + verbose_name = _('Document type metadata type options') + verbose_name_plural = _('Document type metadata types options') diff --git a/mayan/apps/metadata/permissions.py b/mayan/apps/metadata/permissions.py index 1ca36fe4e4..4af727ef6e 100644 --- a/mayan/apps/metadata/permissions.py +++ b/mayan/apps/metadata/permissions.py @@ -1,17 +1,17 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import Permission, PermissionNamespace -metadata_namespace = PermissionNamespace('metadata', _(u'Metadata')) -PERMISSION_METADATA_DOCUMENT_EDIT = Permission.objects.register(metadata_namespace, 'metadata_document_edit', _(u'Edit a document\'s metadata')) -PERMISSION_METADATA_DOCUMENT_ADD = Permission.objects.register(metadata_namespace, 'metadata_document_add', _(u'Add metadata to a document')) -PERMISSION_METADATA_DOCUMENT_REMOVE = Permission.objects.register(metadata_namespace, 'metadata_document_remove', _(u'Remove metadata from a document')) -PERMISSION_METADATA_DOCUMENT_VIEW = Permission.objects.register(metadata_namespace, 'metadata_document_view', _(u'View metadata from a document')) +metadata_namespace = PermissionNamespace('metadata', _('Metadata')) +PERMISSION_METADATA_DOCUMENT_EDIT = Permission.objects.register(metadata_namespace, 'metadata_document_edit', _('Edit a document\'s metadata')) +PERMISSION_METADATA_DOCUMENT_ADD = Permission.objects.register(metadata_namespace, 'metadata_document_add', _('Add metadata to a document')) +PERMISSION_METADATA_DOCUMENT_REMOVE = Permission.objects.register(metadata_namespace, 'metadata_document_remove', _('Remove metadata from a document')) +PERMISSION_METADATA_DOCUMENT_VIEW = Permission.objects.register(metadata_namespace, 'metadata_document_view', _('View metadata from a document')) -metadata_setup_namespace = PermissionNamespace('metadata_setup', _(u'Metadata setup')) -PERMISSION_METADATA_TYPE_EDIT = Permission.objects.register(metadata_setup_namespace, 'metadata_type_edit', _(u'Edit metadata types')) -PERMISSION_METADATA_TYPE_CREATE = Permission.objects.register(metadata_setup_namespace, 'metadata_type_create', _(u'Create new metadata types')) -PERMISSION_METADATA_TYPE_DELETE = Permission.objects.register(metadata_setup_namespace, 'metadata_type_delete', _(u'Delete metadata types')) -PERMISSION_METADATA_TYPE_VIEW = Permission.objects.register(metadata_setup_namespace, 'metadata_type_view', _(u'View metadata types')) +metadata_setup_namespace = PermissionNamespace('metadata_setup', _('Metadata setup')) +PERMISSION_METADATA_TYPE_EDIT = Permission.objects.register(metadata_setup_namespace, 'metadata_type_edit', _('Edit metadata types')) +PERMISSION_METADATA_TYPE_CREATE = Permission.objects.register(metadata_setup_namespace, 'metadata_type_create', _('Create new metadata types')) +PERMISSION_METADATA_TYPE_DELETE = Permission.objects.register(metadata_setup_namespace, 'metadata_type_delete', _('Delete metadata types')) +PERMISSION_METADATA_TYPE_VIEW = Permission.objects.register(metadata_setup_namespace, 'metadata_type_view', _('View metadata types')) diff --git a/mayan/apps/metadata/serializers.py b/mayan/apps/metadata/serializers.py index b322c6d43c..c0193d1b0c 100644 --- a/mayan/apps/metadata/serializers.py +++ b/mayan/apps/metadata/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ diff --git a/mayan/apps/metadata/settings.py b/mayan/apps/metadata/settings.py index 93398c3e61..52e1abb021 100644 --- a/mayan/apps/metadata/settings.py +++ b/mayan/apps/metadata/settings.py @@ -1,4 +1,4 @@ -"""Configuration options for the metadata app""" +from __future__ import unicode_literals from dateutil.parser import parse @@ -20,12 +20,12 @@ default_available_validators = { } register_settings( - namespace=u'metadata', - module=u'metadata.settings', + namespace='metadata', + module='metadata.settings', settings=[ # Definition - {'name': u'AVAILABLE_FUNCTIONS', 'global_name': u'METADATA_AVAILABLE_FUNCTIONS', 'default': default_available_functions}, - {'name': u'AVAILABLE_MODELS', 'global_name': u'METADATA_AVAILABLE_MODELS', 'default': default_available_models}, - {'name': u'AVAILABLE_VALIDATORS', 'global_name': u'METADATA_AVAILABLE_VALIDATORS', 'default': default_available_validators}, + {'name': 'AVAILABLE_FUNCTIONS', 'global_name': 'METADATA_AVAILABLE_FUNCTIONS', 'default': default_available_functions}, + {'name': 'AVAILABLE_MODELS', 'global_name': 'METADATA_AVAILABLE_MODELS', 'default': default_available_models}, + {'name': 'AVAILABLE_VALIDATORS', 'global_name': 'METADATA_AVAILABLE_VALIDATORS', 'default': default_available_validators}, ] ) diff --git a/mayan/apps/metadata/urls.py b/mayan/apps/metadata/urls.py index 95128dd731..342972e26c 100644 --- a/mayan/apps/metadata/urls.py +++ b/mayan/apps/metadata/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url from .api_views import (APIDocumentMetadataListView, APIDocumentMetadataView, diff --git a/mayan/apps/metadata/views.py b/mayan/apps/metadata/views.py index eb85974f42..54bf4720fd 100644 --- a/mayan/apps/metadata/views.py +++ b/mayan/apps/metadata/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.conf import settings from django.contrib import messages @@ -22,17 +22,16 @@ from common.utils import encapsulate, generate_choices_w_labels from common.views import assign_remove from .api import save_metadata_list -from .forms import (AddMetadataForm, MetadataFormSet, MetadataRemoveFormSet, - MetadataTypeForm) +from .forms import ( + AddMetadataForm, MetadataFormSet, MetadataRemoveFormSet, MetadataTypeForm +) from .models import DocumentMetadata, MetadataType -from .permissions import (PERMISSION_METADATA_DOCUMENT_ADD, - PERMISSION_METADATA_DOCUMENT_EDIT, - PERMISSION_METADATA_DOCUMENT_REMOVE, - PERMISSION_METADATA_DOCUMENT_VIEW, - PERMISSION_METADATA_TYPE_CREATE, - PERMISSION_METADATA_TYPE_DELETE, - PERMISSION_METADATA_TYPE_EDIT, - PERMISSION_METADATA_TYPE_VIEW) +from .permissions import ( + PERMISSION_METADATA_DOCUMENT_ADD, PERMISSION_METADATA_DOCUMENT_EDIT, + PERMISSION_METADATA_DOCUMENT_REMOVE, PERMISSION_METADATA_DOCUMENT_VIEW, + PERMISSION_METADATA_TYPE_CREATE, PERMISSION_METADATA_TYPE_DELETE, + PERMISSION_METADATA_TYPE_EDIT, PERMISSION_METADATA_TYPE_VIEW +) def metadata_edit(request, document_id=None, document_id_list=None): @@ -50,17 +49,17 @@ def metadata_edit(request, document_id=None, document_id_list=None): if document_id: raise Http404 else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) if len(set([document.document_type.pk for document in documents])) > 1: - messages.error(request, _(u'Only select documents of the same type.')) + messages.error(request, _('Only select documents of the same type.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) if set(documents.values_list('metadata__value' ,flat=True)) == set([None]): message = ungettext( - u'The selected document doesn\'t have any metadata.', - u'The selected documents don\'t have any metadata.', + 'The selected document doesn\'t have any metadata.', + 'The selected documents don\'t have any metadata.', len(documents) ) messages.warning(request, message) @@ -87,7 +86,7 @@ def metadata_edit(request, document_id=None, document_id_list=None): for key, value in metadata.items(): initial.append({ 'metadata_type': key, - 'value': u', '.join(value) if value else '', + 'value': ', '.join(value) if value else '', 'required': key in document.document_type.metadata.filter(required=True), }) @@ -110,10 +109,10 @@ def metadata_edit(request, document_id=None, document_id_list=None): if settings.DEBUG: raise else: - messages.error(request, _(u'Error editing metadata for document %(document)s; %(exception)s.') % { + messages.error(request, _('Error editing metadata for document %(document)s; %(exception)s.') % { 'document': document, 'exception': ', '.join(exception.messages)}) else: - messages.success(request, _(u'Metadata for document %s edited successfully.') % document) + messages.success(request, _('Metadata for document %s edited successfully.') % document) return HttpResponseRedirect(next) @@ -127,8 +126,8 @@ def metadata_edit(request, document_id=None, document_id_list=None): context['object'] = documents[0] context['title'] = ungettext( - u'Edit document metadata', - u'Edit documents metadata', + 'Edit document metadata', + 'Edit documents metadata', len(documents) ) @@ -146,7 +145,7 @@ def metadata_add(request, document_id=None, document_id_list=None): elif document_id_list: documents = [get_object_or_404(Document.objects.select_related('document_type'), pk=document_id) for document_id in document_id_list.split(',')] if len(set([document.document_type.pk for document in documents])) > 1: - messages.error(request, _(u'Only select documents of the same type.')) + messages.error(request, _('Only select documents of the same type.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) try: @@ -155,7 +154,7 @@ def metadata_add(request, document_id=None, document_id_list=None): documents = AccessEntry.objects.filter_objects_by_access(PERMISSION_METADATA_DOCUMENT_ADD, request.user, documents) if not documents: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) for document in documents: @@ -171,28 +170,28 @@ def metadata_add(request, document_id=None, document_id_list=None): metadata_type = form.cleaned_data['metadata_type'] for document in documents: try: - document_metadata, created = DocumentMetadata.objects.get_or_create(document=document, metadata_type=metadata_type.metadata_type, defaults={'value': u''}) + document_metadata, created = DocumentMetadata.objects.get_or_create(document=document, metadata_type=metadata_type.metadata_type, defaults={'value': ''}) except Exception as exception: if getattr(settings, 'DEBUG', False): raise else: - messages.error(request, _(u'Error adding metadata type "%(metadata_type)s" to document: %(document)s; %(exception)s') % { + messages.error(request, _('Error adding metadata type "%(metadata_type)s" to document: %(document)s; %(exception)s') % { 'metadata_type': metadata_type, 'document': document, 'exception': ', '.join(getattr(exception, 'messages', exception))}) else: if created: - messages.success(request, _(u'Metadata type: %(metadata_type)s successfully added to document %(document)s.') % { + messages.success(request, _('Metadata type: %(metadata_type)s successfully added to document %(document)s.') % { 'metadata_type': metadata_type, 'document': document}) else: - messages.warning(request, _(u'Metadata type: %(metadata_type)s already present in document %(document)s.') % { + messages.warning(request, _('Metadata type: %(metadata_type)s already present in document %(document)s.') % { 'metadata_type': metadata_type, 'document': document}) if len(documents) == 1: - return HttpResponseRedirect(u'%s?%s' % ( + return HttpResponseRedirect('%s?%s' % ( reverse('metadata:metadata_edit', args=[document.pk]), urlencode({'next': next})) ) elif len(documents) > 1: - return HttpResponseRedirect(u'%s?%s' % ( + return HttpResponseRedirect('%s?%s' % ( reverse('metadata:metadata_multiple_edit'), urlencode({'id_list': document_id_list, 'next': next})) ) @@ -209,8 +208,8 @@ def metadata_add(request, document_id=None, document_id_list=None): context['object'] = documents[0] context['title'] = ungettext( - u'Add metadata types to document', - u'Add metadata types to documents', + 'Add metadata types to document', + 'Add metadata types to documents', len(documents) ) @@ -237,17 +236,17 @@ def metadata_remove(request, document_id=None, document_id_list=None): if document_id: raise Http404 else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) if len(set([document.document_type.pk for document in documents])) > 1: - messages.error(request, _(u'Only select documents of the same type.')) + messages.error(request, _('Only select documents of the same type.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('main:home'))) if set(documents.values_list('metadata__value' ,flat=True)) == set([None]): message = ungettext( - u'The selected document doesn\'t have any metadata.', - u'The selected documents doesn\'t have any metadata.', + 'The selected document doesn\'t have any metadata.', + 'The selected documents doesn\'t have any metadata.', len(documents) ) messages.warning(request, message) @@ -267,13 +266,13 @@ def metadata_remove(request, document_id=None, document_id_list=None): if value not in metadata[item.metadata_type]: metadata[item.metadata_type].append(value) else: - metadata[item.metadata_type] = [value] if value else u'' + metadata[item.metadata_type] = [value] if value else '' initial = [] for key, value in metadata.items(): initial.append({ 'metadata_type': key, - 'value': u', '.join(value) + 'value': ', '.join(value) }) formset = MetadataRemoveFormSet(initial=initial) @@ -288,10 +287,10 @@ def metadata_remove(request, document_id=None, document_id_list=None): try: document_metadata = DocumentMetadata.objects.get(document=document, metadata_type=metadata_type) document_metadata.delete() - messages.success(request, _(u'Successfully remove metadata type "%(metadata_type)s" from document: %(document)s.') % { + messages.success(request, _('Successfully remove metadata type "%(metadata_type)s" from document: %(document)s.') % { 'metadata_type': metadata_type, 'document': document}) except Exception as exception: - messages.error(request, _(u'Error removing metadata type "%(metadata_type)s" from document: %(document)s; %(exception)s') % { + messages.error(request, _('Error removing metadata type "%(metadata_type)s" from document: %(document)s; %(exception)s') % { 'metadata_type': metadata_type, 'document': document, 'exception': ', '.join(exception.messages)}) return HttpResponseRedirect(next) @@ -306,8 +305,8 @@ def metadata_remove(request, document_id=None, document_id_list=None): context['object'] = documents[0] context['title'] = ungettext( - u'Remove metadata types from the document', - u'Remove metadata types from the documents', + 'Remove metadata types from the document', + 'Remove metadata types from the documents', len(documents) ) @@ -328,11 +327,11 @@ def metadata_view(request, document_id): AccessEntry.objects.check_access(PERMISSION_METADATA_DOCUMENT_VIEW, request.user, document) return render_to_response('main/generic_list.html', { - 'title': _(u'Document metadata'), + 'title': _('Document metadata'), 'object_list': document.metadata.all(), 'extra_columns': [ - {'name': _(u'Value'), 'attribute': 'value'}, - {'name': _(u'Required'), 'attribute': encapsulate(lambda x: x.metadata_type in document.document_type.metadata.filter(required=True))} + {'name': _('Value'), 'attribute': 'value'}, + {'name': _('Required'), 'attribute': encapsulate(lambda x: x.metadata_type in document.document_type.metadata.filter(required=True))} ], 'hide_link': True, 'object': document, @@ -371,11 +370,11 @@ def setup_metadata_type_list(request): context = { 'object_list': MetadataType.objects.all(), - 'title': _(u'Metadata types'), + 'title': _('Metadata types'), 'hide_link': True, 'extra_columns': [ { - 'name': _(u'Internal name'), + 'name': _('Internal name'), 'attribute': 'name', }, ] @@ -395,16 +394,16 @@ def setup_metadata_type_edit(request, metadatatype_id): if form.is_valid(): try: form.save() - messages.success(request, _(u'Metadata type edited successfully')) + messages.success(request, _('Metadata type edited successfully')) return HttpResponseRedirect(reverse('metadata:setup_metadata_type_list')) except Exception as exception: - messages.error(request, _(u'Error editing metadata type; %s') % exception) + messages.error(request, _('Error editing metadata type; %s') % exception) pass else: form = MetadataTypeForm(instance=metadata_type) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit metadata type: %s') % metadata_type, + 'title': _('Edit metadata type: %s') % metadata_type, 'form': form, 'object': metadata_type, }, context_instance=RequestContext(request)) @@ -417,13 +416,13 @@ def setup_metadata_type_create(request): form = MetadataTypeForm(request.POST) if form.is_valid(): form.save() - messages.success(request, _(u'Metadata type created successfully')) + messages.success(request, _('Metadata type created successfully')) return HttpResponseRedirect(reverse('metadata:setup_metadata_type_list')) else: form = MetadataTypeForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Create metadata type'), + 'title': _('Create metadata type'), 'form': form, }, context_instance=RequestContext(request)) @@ -441,9 +440,9 @@ def setup_metadata_type_delete(request, metadatatype_id): if request.method == 'POST': try: metadata_type.delete() - messages.success(request, _(u'Metadata type: %s deleted successfully.') % metadata_type) + messages.success(request, _('Metadata type: %s deleted successfully.') % metadata_type) except Exception as exception: - messages.error(request, _(u'Metadata type: %(metadata_type)s delete error: %(error)s') % { + messages.error(request, _('Metadata type: %(metadata_type)s delete error: %(error)s') % { 'metadata_type': metadata_type, 'error': exception}) return HttpResponseRedirect(next) @@ -453,7 +452,7 @@ def setup_metadata_type_delete(request, metadatatype_id): 'next': next, 'previous': previous, 'object': metadata_type, - 'title': _(u'Are you sure you wish to delete the metadata type: %s?') % metadata_type, + 'title': _('Are you sure you wish to delete the metadata type: %s?') % metadata_type, } return render_to_response('main/generic_confirm.html', context, @@ -474,7 +473,7 @@ def setup_document_type_metadata(request, document_type_id): extra_context={ 'document_type': document_type, 'navigation_object_name': 'document_type', - 'main_title': _(u'Optional metadata types for document type: %s') % document_type, + 'main_title': _('Optional metadata types for document type: %s') % document_type, }, decode_content_type=True, ) diff --git a/mayan/apps/mimetype/api.py b/mayan/apps/mimetype/api.py index a0ba8c6d2d..70117f4304 100644 --- a/mayan/apps/mimetype/api.py +++ b/mayan/apps/mimetype/api.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import os try: diff --git a/mayan/apps/navigation/api.py b/mayan/apps/navigation/api.py index 8f76bb8421..c1e8ebd03a 100644 --- a/mayan/apps/navigation/api.py +++ b/mayan/apps/navigation/api.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + object_navigation = {} model_list_columns = {} top_menu_entries = [] diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index 362ef3bbb1..543900387d 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import inspect import logging @@ -113,7 +113,7 @@ class Link(object): else: resolved_link.url = reverse(self.view, args=args) if self.keep_query: - resolved_link.url = u'%s?%s' % (urlquote(resolved_link.url), urlencode(parsed_query_string, doseq=True)) + resolved_link.url = '%s?%s' % (urlquote(resolved_link.url), urlencode(parsed_query_string, doseq=True)) except NoReverseMatch, exc: resolved_link.url = '#' @@ -127,7 +127,7 @@ class Link(object): else: resolved_link.url = self.url % args if self.keep_query: - resolved_link.url = u'%s?%s' % (urlquote(resolved_link.url), urlencode(parsed_query_string, doseq=True)) + resolved_link.url = '%s?%s' % (urlquote(resolved_link.url), urlencode(parsed_query_string, doseq=True)) else: resolved_link.active = False diff --git a/mayan/apps/navigation/forms.py b/mayan/apps/navigation/forms.py index 52d97adc6e..7dd16fce4c 100644 --- a/mayan/apps/navigation/forms.py +++ b/mayan/apps/navigation/forms.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django import forms from django.utils.translation import ugettext as _ @@ -24,4 +26,4 @@ class MultiItemForm(forms.Form): else: self.fields['action'].choices = group - action = forms.ChoiceField(label=_(u'Actions'), required=False) + action = forms.ChoiceField(label=_('Actions'), required=False) diff --git a/mayan/apps/navigation/links.py b/mayan/apps/navigation/links.py index 6c0bba5d46..72721b2505 100644 --- a/mayan/apps/navigation/links.py +++ b/mayan/apps/navigation/links.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- +from __future__ import unicode_literals link_spacer = {'text': ('───────────────'), 'url': ''} diff --git a/mayan/apps/navigation/templatetags/navigation_tags.py b/mayan/apps/navigation/templatetags/navigation_tags.py index c188054956..30012e7341 100644 --- a/mayan/apps/navigation/templatetags/navigation_tags.py +++ b/mayan/apps/navigation/templatetags/navigation_tags.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import copy import inspect diff --git a/mayan/apps/navigation/widgets.py b/mayan/apps/navigation/widgets.py index 0f58a02f43..bb06f7eaba 100644 --- a/mayan/apps/navigation/widgets.py +++ b/mayan/apps/navigation/widgets.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import urlparse @@ -22,7 +22,7 @@ def button_navigation_widget(request, link): Permission.objects.check_permissions(request.user, link['permissions']) return render_widget(request, link) except PermissionDenied: - return u'' + return '' else: return render_widget(request, link) @@ -40,7 +40,7 @@ def render_widget(request, link): links = resolve_links(context, [link], current_view, current_path, parsed_query_string) if links: link = links[0] - return mark_safe(u'\ + return mark_safe('\ \

\
\ @@ -50,7 +50,7 @@ def render_widget(request, link): 'url': reverse(link['view']) if 'view' in link else link['url'], 'static_url': staticfiles_storage.url('main/icons/{0}'.format(link.get('icon', 'link_button.png'))), 'string': link['text'], - 'image_alt': _(u'Icon'), + 'image_alt': _('Icon'), }) else: - return u'' + return '' diff --git a/mayan/apps/permissions/__init__.py b/mayan/apps/permissions/__init__.py index b3c3db582f..41ef123eb0 100644 --- a/mayan/apps/permissions/__init__.py +++ b/mayan/apps/permissions/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist diff --git a/mayan/apps/permissions/admin.py b/mayan/apps/permissions/admin.py index e38f1f81d0..9d40c1820e 100644 --- a/mayan/apps/permissions/admin.py +++ b/mayan/apps/permissions/admin.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin diff --git a/mayan/apps/permissions/api_views.py b/mayan/apps/permissions/api_views.py index 65c5a956d4..6d6fb9d1dd 100644 --- a/mayan/apps/permissions/api_views.py +++ b/mayan/apps/permissions/api_views.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from rest_framework import generics, views from rest_api.filters import MayanObjectPermissionsFilter diff --git a/mayan/apps/permissions/forms.py b/mayan/apps/permissions/forms.py index 64cd5dd5df..4b75990771 100644 --- a/mayan/apps/permissions/forms.py +++ b/mayan/apps/permissions/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django import forms diff --git a/mayan/apps/permissions/links.py b/mayan/apps/permissions/links.py index ee1743edbb..d4e434520f 100644 --- a/mayan/apps/permissions/links.py +++ b/mayan/apps/permissions/links.py @@ -1,18 +1,19 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ -from .permissions import (PERMISSION_PERMISSION_GRANT, - PERMISSION_PERMISSION_REVOKE, PERMISSION_ROLE_CREATE, - PERMISSION_ROLE_DELETE, PERMISSION_ROLE_EDIT, - PERMISSION_ROLE_VIEW) +from .permissions import ( + PERMISSION_PERMISSION_GRANT, PERMISSION_PERMISSION_REVOKE, + PERMISSION_ROLE_CREATE, PERMISSION_ROLE_DELETE, PERMISSION_ROLE_EDIT, + PERMISSION_ROLE_VIEW +) -permission_grant = {'text': _(u'Grant'), 'view': 'permissions:permission_multiple_grant', 'famfam': 'key_add', 'permissions': [PERMISSION_PERMISSION_GRANT]} -permission_revoke = {'text': _(u'Revoke'), 'view': 'permissions:permission_multiple_revoke', 'famfam': 'key_delete', 'permissions': [PERMISSION_PERMISSION_REVOKE]} +permission_grant = {'text': _('Grant'), 'view': 'permissions:permission_multiple_grant', 'famfam': 'key_add', 'permissions': [PERMISSION_PERMISSION_GRANT]} +permission_revoke = {'text': _('Revoke'), 'view': 'permissions:permission_multiple_revoke', 'famfam': 'key_delete', 'permissions': [PERMISSION_PERMISSION_REVOKE]} -role_create = {'text': _(u'Create new role'), 'view': 'permissions:role_create', 'famfam': 'medal_gold_add', 'permissions': [PERMISSION_ROLE_CREATE]} -role_delete = {'text': _(u'Delete'), 'view': 'permissions:role_delete', 'args': 'object.id', 'famfam': 'medal_gold_delete', 'permissions': [PERMISSION_ROLE_DELETE]} -role_edit = {'text': _(u'Edit'), 'view': 'permissions:role_edit', 'args': 'object.id', 'famfam': 'medal_gold_1', 'permissions': [PERMISSION_ROLE_EDIT]} -role_list = {'text': _(u'Roles'), 'view': 'permissions:role_list', 'famfam': 'medal_gold_1', 'icon': 'medal_gold_red.png', 'permissions': [PERMISSION_ROLE_VIEW]} -role_members = {'text': _(u'Members'), 'view': 'permissions:role_members', 'args': 'object.id', 'famfam': 'group_key', 'permissions': [PERMISSION_ROLE_EDIT]} -role_permissions = {'text': _(u'Role permissions'), 'view': 'permissions:role_permissions', 'args': 'object.id', 'famfam': 'key_go', 'permissions': [PERMISSION_PERMISSION_GRANT, PERMISSION_PERMISSION_REVOKE]} +role_create = {'text': _('Create new role'), 'view': 'permissions:role_create', 'famfam': 'medal_gold_add', 'permissions': [PERMISSION_ROLE_CREATE]} +role_delete = {'text': _('Delete'), 'view': 'permissions:role_delete', 'args': 'object.id', 'famfam': 'medal_gold_delete', 'permissions': [PERMISSION_ROLE_DELETE]} +role_edit = {'text': _('Edit'), 'view': 'permissions:role_edit', 'args': 'object.id', 'famfam': 'medal_gold_1', 'permissions': [PERMISSION_ROLE_EDIT]} +role_list = {'text': _('Roles'), 'view': 'permissions:role_list', 'famfam': 'medal_gold_1', 'icon': 'medal_gold_red.png', 'permissions': [PERMISSION_ROLE_VIEW]} +role_members = {'text': _('Members'), 'view': 'permissions:role_members', 'args': 'object.id', 'famfam': 'group_key', 'permissions': [PERMISSION_ROLE_EDIT]} +role_permissions = {'text': _('Role permissions'), 'view': 'permissions:role_permissions', 'args': 'object.id', 'famfam': 'key_go', 'permissions': [PERMISSION_PERMISSION_GRANT, PERMISSION_PERMISSION_REVOKE]} diff --git a/mayan/apps/permissions/managers.py b/mayan/apps/permissions/managers.py index 537acedbe9..4ea644c1d5 100644 --- a/mayan/apps/permissions/managers.py +++ b/mayan/apps/permissions/managers.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import logging from django.db import models diff --git a/mayan/apps/permissions/middleware/permission_denied_middleware.py b/mayan/apps/permissions/middleware/permission_denied_middleware.py index ea7e04b932..19a42bf7ed 100644 --- a/mayan/apps/permissions/middleware/permission_denied_middleware.py +++ b/mayan/apps/permissions/middleware/permission_denied_middleware.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf import settings from django.core.exceptions import PermissionDenied from django.http import HttpResponseForbidden @@ -11,16 +13,16 @@ class PermissionDeniedMiddleware(object): if isinstance(exception, PermissionDenied): try: # Handle import error but allow any type error from view - callback = getattr(import_module(settings.ROOT_URLCONF), u'handler403') + callback = getattr(import_module(settings.ROOT_URLCONF), 'handler403') return callback(request, exception) except (ImportError, AttributeError): # Try to get a 403 template try: # First look for a user-defined template named "403.html" - t = loader.get_template(u'403.html') + t = loader.get_template('403.html') except TemplateDoesNotExist: # If a template doesn't exist in the projct, use the following hardcoded template - t = Template(u'''{% load i18n %} + t = Template('''{% load i18n %} diff --git a/mayan/apps/permissions/models.py b/mayan/apps/permissions/models.py index 70263dc210..5dd6c74a15 100644 --- a/mayan/apps/permissions/models.py +++ b/mayan/apps/permissions/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -48,7 +48,7 @@ class PermissionManager(object): logger.debug('no permission') - raise PermissionDenied(ugettext(u'Insufficient permissions.')) + raise PermissionDenied(ugettext('Insufficient permissions.')) @classmethod def get_for_holder(cls, holder): @@ -93,7 +93,7 @@ class Permission(object): @property def uuid(self): - return u'%s.%s' % (self.namespace.name, self.name) + return '%s.%s' % (self.namespace.name, self.name) @property def stored_permission(self): @@ -123,16 +123,16 @@ Permission._default_manager = Permission.objects class StoredPermission(models.Model): - namespace = models.CharField(max_length=64, verbose_name=_(u'Namespace')) - name = models.CharField(max_length=64, verbose_name=_(u'Name')) + namespace = models.CharField(max_length=64, verbose_name=_('Namespace')) + name = models.CharField(max_length=64, verbose_name=_('Name')) objects = StoredPermissionManager() class Meta: ordering = ('namespace',) unique_together = ('namespace', 'name') - verbose_name = _(u'Permission') - verbose_name_plural = _(u'Permissions') + verbose_name = _('Permission') + verbose_name_plural = _('Permissions') def __init__(self, *args, **kwargs): super(StoredPermission, self).__init__(*args, **kwargs) @@ -193,7 +193,7 @@ class StoredPermission(models.Model): class PermissionHolder(models.Model): - permission = models.ForeignKey(StoredPermission, verbose_name=_(u'Permission')) + permission = models.ForeignKey(StoredPermission, verbose_name=_('Permission')) holder_type = models.ForeignKey(ContentType, related_name='permission_holder', limit_choices_to={'model__in': ('user', 'group', 'role')}) @@ -201,21 +201,21 @@ class PermissionHolder(models.Model): holder_object = generic.GenericForeignKey(ct_field='holder_type', fk_field='holder_id') class Meta: - verbose_name = _(u'Permission holder') - verbose_name_plural = _(u'Permission holders') + verbose_name = _('Permission holder') + verbose_name_plural = _('Permission holders') def __unicode__(self): - return u'%s: %s' % (self.holder_type, self.holder_object) + return '%s: %s' % (self.holder_type, self.holder_object) class Role(models.Model): name = models.CharField(max_length=64, unique=True) - label = models.CharField(max_length=64, unique=True, verbose_name=_(u'Label')) + label = models.CharField(max_length=64, unique=True, verbose_name=_('Label')) class Meta: ordering = ('label',) - verbose_name = _(u'Role') - verbose_name_plural = _(u'Roles') + verbose_name = _('Role') + verbose_name_plural = _('Roles') def __unicode__(self): return self.label @@ -245,7 +245,7 @@ class Role(models.Model): class RoleMember(models.Model): - role = models.ForeignKey(Role, verbose_name=_(u'Role')) + role = models.ForeignKey(Role, verbose_name=_('Role')) member_type = models.ForeignKey( ContentType, related_name='role_member', @@ -261,8 +261,8 @@ class RoleMember(models.Model): objects = RoleMemberManager() class Meta: - verbose_name = _(u'Role member') - verbose_name_plural = _(u'Role members') + verbose_name = _('Role member') + verbose_name_plural = _('Role members') def __unicode__(self): return unicode(self.member_object) diff --git a/mayan/apps/permissions/permissions.py b/mayan/apps/permissions/permissions.py index ce97e1e150..000f127770 100644 --- a/mayan/apps/permissions/permissions.py +++ b/mayan/apps/permissions/permissions.py @@ -1,14 +1,14 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from .models import Permission, PermissionNamespace -permissions_namespace = PermissionNamespace('permissions', _(u'Permissions')) +permissions_namespace = PermissionNamespace('permissions', _('Permissions')) -PERMISSION_ROLE_VIEW = Permission.objects.register(permissions_namespace, 'role_view', _(u'View roles')) -PERMISSION_ROLE_EDIT = Permission.objects.register(permissions_namespace, 'role_edit', _(u'Edit roles')) -PERMISSION_ROLE_CREATE = Permission.objects.register(permissions_namespace, 'role_create', _(u'Create roles')) -PERMISSION_ROLE_DELETE = Permission.objects.register(permissions_namespace, 'role_delete', _(u'Delete roles')) -PERMISSION_PERMISSION_GRANT = Permission.objects.register(permissions_namespace, 'permission_grant', _(u'Grant permissions')) -PERMISSION_PERMISSION_REVOKE = Permission.objects.register(permissions_namespace, 'permission_revoke', _(u'Revoke permissions')) +PERMISSION_ROLE_VIEW = Permission.objects.register(permissions_namespace, 'role_view', _('View roles')) +PERMISSION_ROLE_EDIT = Permission.objects.register(permissions_namespace, 'role_edit', _('Edit roles')) +PERMISSION_ROLE_CREATE = Permission.objects.register(permissions_namespace, 'role_create', _('Create roles')) +PERMISSION_ROLE_DELETE = Permission.objects.register(permissions_namespace, 'role_delete', _('Delete roles')) +PERMISSION_PERMISSION_GRANT = Permission.objects.register(permissions_namespace, 'permission_grant', _('Grant permissions')) +PERMISSION_PERMISSION_REVOKE = Permission.objects.register(permissions_namespace, 'permission_revoke', _('Revoke permissions')) diff --git a/mayan/apps/permissions/serializers.py b/mayan/apps/permissions/serializers.py index 1bbe1cada5..9e39fa5160 100644 --- a/mayan/apps/permissions/serializers.py +++ b/mayan/apps/permissions/serializers.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from rest_framework import serializers from .models import Role diff --git a/mayan/apps/permissions/settings.py b/mayan/apps/permissions/settings.py index 0a8c71ba76..91e64fc9cd 100644 --- a/mayan/apps/permissions/settings.py +++ b/mayan/apps/permissions/settings.py @@ -1,12 +1,13 @@ -"""Configuration options for the permissions app""" +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ from smart_settings.api import register_settings register_settings( - namespace=u'permissions', - module=u'permissions.settings', + namespace='permissions', + module='permissions.settings', settings=[ - {'name': u'DEFAULT_ROLES', 'global_name': u'ROLES_DEFAULT_ROLES', 'default': [], 'description': _('A list of existing roles that are automatically assigned to newly created users')}, + {'name': 'DEFAULT_ROLES', 'global_name': 'ROLES_DEFAULT_ROLES', 'default': [], 'description': _('A list of existing roles that are automatically assigned to newly created users')}, ] ) diff --git a/mayan/apps/permissions/templatetags/permission_tags.py b/mayan/apps/permissions/templatetags/permission_tags.py index 0d0974145b..8adad8e992 100644 --- a/mayan/apps/permissions/templatetags/permission_tags.py +++ b/mayan/apps/permissions/templatetags/permission_tags.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import, unicode_literals + from django.core.exceptions import PermissionDenied from django.template import TemplateSyntaxError, Library, Node, Variable @@ -16,16 +18,16 @@ class CheckPermissionsNode(Node): if not permission_list: # There is no permissions list to check against which means # this link is available for all - context[u'permission'] = True - return u'' + context['permission'] = True + return '' requester = Variable(self.requester).resolve(context) try: Permission.objects.check_permissions(requester, permission_list) - context[u'permission'] = True - return u'' + context['permission'] = True + return '' except PermissionDenied: - context[u'permission'] = False - return u'' + context['permission'] = False + return '' @register.tag @@ -34,6 +36,6 @@ def check_permissions(parser, token): # Splitting by None == splitting by spaces. tag_name, args = token.contents.split(None, 1) except ValueError: - raise TemplateSyntaxError(u'%r tag requires arguments' % token.contents.split()[0]) + raise TemplateSyntaxError('%r tag requires arguments' % token.contents.split()[0]) return CheckPermissionsNode(*args.split()) diff --git a/mayan/apps/permissions/urls.py b/mayan/apps/permissions/urls.py index 50d3b4d6a3..82378035bb 100644 --- a/mayan/apps/permissions/urls.py +++ b/mayan/apps/permissions/urls.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import patterns, url diff --git a/mayan/apps/permissions/views.py b/mayan/apps/permissions/views.py index 7a389b8462..6e39599697 100644 --- a/mayan/apps/permissions/views.py +++ b/mayan/apps/permissions/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import itertools from json import loads @@ -17,17 +17,20 @@ from django.utils.translation import ugettext_lazy as _ from acls.classes import EncapsulatedObject from common.models import AnonymousUserSingleton -from common.views import (SingleObjectCreateView, SingleObjectDeleteView, - SingleObjectEditView, assign_remove) +from common.views import ( + SingleObjectCreateView, SingleObjectDeleteView, SingleObjectEditView, + assign_remove +) from common.utils import encapsulate, get_object_name from common.widgets import two_state_template from .forms import RoleForm, RoleForm_view from .models import Permission, Role -from .permissions import (PERMISSION_PERMISSION_GRANT, - PERMISSION_PERMISSION_REVOKE, PERMISSION_ROLE_VIEW, - PERMISSION_ROLE_CREATE, PERMISSION_ROLE_DELETE, - PERMISSION_ROLE_EDIT) +from .permissions import ( + PERMISSION_PERMISSION_GRANT, PERMISSION_PERMISSION_REVOKE, + PERMISSION_ROLE_VIEW, PERMISSION_ROLE_CREATE, PERMISSION_ROLE_DELETE, + PERMISSION_ROLE_EDIT +) class RoleCreateView(SingleObjectCreateView): @@ -53,7 +56,7 @@ def role_list(request): context = { 'object_list': Role.objects.all(), - 'title': _(u'Roles'), + 'title': _('Roles'), 'hide_link': True, } @@ -69,15 +72,15 @@ def role_permissions(request, role_id): subtemplates_list = [ { - 'name': u'main/generic_list_subtemplate.html', + 'name': 'main/generic_list_subtemplate.html', 'context': { - 'title': _(u'Permissions'), + 'title': _('Permissions'), 'object_list': Permission.objects.all(), 'extra_columns': [ - {'name': _(u'Namespace'), 'attribute': encapsulate(lambda x: x.namespace)}, - {'name': _(u'Name'), 'attribute': encapsulate(lambda x: x.label)}, + {'name': _('Namespace'), 'attribute': encapsulate(lambda x: x.namespace)}, + {'name': _('Name'), 'attribute': encapsulate(lambda x: x.label)}, { - 'name': _(u'Has permission'), + 'name': _('Has permission'), 'attribute': encapsulate(lambda x: two_state_template(x.requester_has_this(role))), }, ], @@ -126,20 +129,20 @@ def permission_grant(request): grouped_items = [(grouper, [permission['permission'] for permission in group_data]) for grouper, group_data in groups] # Warning: trial and error black magic ahead - title_suffix = _(u' and ').join([_(u'%(permissions)s to %(requester)s') % {'permissions': ', '.join(['"%s"' % unicode(ps) for ps in p]), 'requester': unicode(r)} for r, p in grouped_items]) + title_suffix = _(' and ').join([_('%(permissions)s to %(requester)s') % {'permissions': ', '.join(['"%s"' % unicode(ps) for ps in p]), 'requester': unicode(r)} for r, p in grouped_items]) if len(grouped_items) == 1 and len(grouped_items[0][1]) == 1: - permissions_label = _(u'Permission') + permissions_label = _('Permission') else: - permissions_label = _(u'Permissions') + permissions_label = _('Permissions') if request.method == 'POST': for item in items: if item['permission'].grant_to(item['requester']): - messages.success(request, _(u'Permission "%(permission)s" granted to: %(requester)s.') % { + messages.success(request, _('Permission "%(permission)s" granted to: %(requester)s.') % { 'permission': item['permission'], 'requester': item['requester']}) else: - messages.warning(request, _(u'%(requester)s, already had the permission "%(permission)s" granted.') % { + messages.warning(request, _('%(requester)s, already had the permission "%(permission)s" granted.') % { 'requester': item['requester'], 'permission': item['permission']}) return HttpResponseRedirect(next) @@ -149,7 +152,7 @@ def permission_grant(request): 'next': next, } - context['title'] = _(u'Are you sure you wish to grant the %(permissions_label)s %(title_suffix)s?') % { + context['title'] = _('Are you sure you wish to grant the %(permissions_label)s %(title_suffix)s?') % { 'permissions_label': permissions_label, 'title_suffix': title_suffix, } @@ -187,20 +190,20 @@ def permission_revoke(request): grouped_items = [(grouper, [permission['permission'] for permission in group_data]) for grouper, group_data in groups] # Warning: trial and error black magic ahead - title_suffix = _(u' and ').join([_(u'%(permissions)s to %(requester)s') % {'permissions': ', '.join(['"%s"' % unicode(ps) for ps in p]), 'requester': unicode(r)} for r, p in grouped_items]) + title_suffix = _(' and ').join([_('%(permissions)s to %(requester)s') % {'permissions': ', '.join(['"%s"' % unicode(ps) for ps in p]), 'requester': unicode(r)} for r, p in grouped_items]) if len(grouped_items) == 1 and len(grouped_items[0][1]) == 1: - permissions_label = _(u'permission') + permissions_label = _('permission') else: - permissions_label = _(u'permissions') + permissions_label = _('permissions') if request.method == 'POST': for item in items: if item['permission'].revoke_from(item['requester']): - messages.success(request, _(u'Permission "%(permission)s" revoked from: %(requester)s.') % { + messages.success(request, _('Permission "%(permission)s" revoked from: %(requester)s.') % { 'permission': item['permission'], 'requester': item['requester']}) else: - messages.warning(request, _(u'%(requester)s, doesn\'t have the permission "%(permission)s" granted.') % { + messages.warning(request, _('%(requester)s, doesn\'t have the permission "%(permission)s" granted.') % { 'requester': item['requester'], 'permission': item['permission']}) return HttpResponseRedirect(next) @@ -210,7 +213,7 @@ def permission_revoke(request): 'next': next, } - context['title'] = _(u'Are you sure you wish to revoke the %(permissions_label)s %(title_suffix)s?') % { + context['title'] = _('Are you sure you wish to revoke the %(permissions_label)s %(title_suffix)s?') % { 'permissions_label': permissions_label, 'title_suffix': title_suffix, } @@ -223,7 +226,7 @@ def permission_revoke(request): class Member(EncapsulatedObject): - source_object_name = u'member_object' + source_object_name = 'member_object' def _as_choice_list(items): @@ -245,13 +248,13 @@ def get_role_members(role, separate=False): members = [] if users: - members.append((_(u'Users'), _as_choice_list(list(users)))) + members.append((_('Users'), _as_choice_list(list(users)))) if groups: - members.append((_(u'Groups'), _as_choice_list(list(groups)))) + members.append((_('Groups'), _as_choice_list(list(groups)))) if anonymous: - members.append((_(u'Special'), _as_choice_list(list(anonymous)))) + members.append((_('Special'), _as_choice_list(list(anonymous)))) return members @@ -269,13 +272,13 @@ def get_non_role_members(role): non_members = [] if users: - non_members.append((_(u'Users'), _as_choice_list(list(users)))) + non_members.append((_('Users'), _as_choice_list(list(users)))) if groups: - non_members.append((_(u'Groups'), _as_choice_list(list(groups)))) + non_members.append((_('Groups'), _as_choice_list(list(groups)))) if anonymous: - non_members.append((_(u'Special'), _as_choice_list(list(anonymous)))) + non_members.append((_('Special'), _as_choice_list(list(anonymous)))) return non_members @@ -300,8 +303,8 @@ def role_members(request, role_id): right_list=lambda: get_role_members(role), add_method=lambda x: add_role_member(role, x), remove_method=lambda x: remove_role_member(role, x), - left_list_title=_(u'Non members of role: %s') % role, - right_list_title=_(u'Members of role: %s') % role, + left_list_title=_('Non members of role: %s') % role, + right_list_title=_('Members of role: %s') % role, extra_context={ 'object': role, }, diff --git a/mayan/apps/permissions/widgets.py b/mayan/apps/permissions/widgets.py index 4ee2b27d01..c907bc6cb5 100644 --- a/mayan/apps/permissions/widgets.py +++ b/mayan/apps/permissions/widgets.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse from django.utils.safestring import mark_safe @@ -7,17 +9,17 @@ from django.utils.translation import ugettext def role_permission_link(requester, permission, permission_list): ct = ContentType.objects.get_for_model(requester) - template = u'
%(text)s' + template = '%(text)s' if permission in permission_list: return mark_safe(template % { 'url': reverse('permission_revoke', args=[permission.pk, ct.app_label, ct.model, requester.pk]), - 'icon': u'key_delete', 'text': ugettext(u'Revoke')}) + 'icon': 'key_delete', 'text': ugettext('Revoke')}) else: return mark_safe(template % { 'url': reverse('permission_grant', args=[permission.pk, ct.app_label, ct.model, requester.pk]), - 'icon': u'key_add', 'text': ugettext(u'Grant')}) + 'icon': 'key_add', 'text': ugettext('Grant')}) diff --git a/mayan/apps/project_setup/__init__.py b/mayan/apps/project_setup/__init__.py index a88480e966..4062089b51 100644 --- a/mayan/apps/project_setup/__init__.py +++ b/mayan/apps/project_setup/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from navigation.api import register_top_menu diff --git a/mayan/apps/project_setup/api.py b/mayan/apps/project_setup/api.py index 1790d624dd..424d250915 100644 --- a/mayan/apps/project_setup/api.py +++ b/mayan/apps/project_setup/api.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - setup_items = [] diff --git a/mayan/apps/project_setup/links.py b/mayan/apps/project_setup/links.py index d8887cff88..39f3a16e05 100644 --- a/mayan/apps/project_setup/links.py +++ b/mayan/apps/project_setup/links.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ -link_setup = {'text': _(u'Setup'), 'view': 'project_setup:setup_list', 'famfam': 'cog'} +link_setup = {'text': _('Setup'), 'view': 'project_setup:setup_list', 'famfam': 'cog'} diff --git a/mayan/apps/project_setup/urls.py b/mayan/apps/project_setup/urls.py index ae6e5c6909..5ff8a557f5 100644 --- a/mayan/apps/project_setup/urls.py +++ b/mayan/apps/project_setup/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('project_setup.views', diff --git a/mayan/apps/project_setup/views.py b/mayan/apps/project_setup/views.py index f11f15aa6a..5ba211f6d5 100644 --- a/mayan/apps/project_setup/views.py +++ b/mayan/apps/project_setup/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.shortcuts import render_to_response from django.template import RequestContext @@ -12,7 +12,7 @@ from .api import setup_items def setup_list(request): context = { 'object_list': [button_navigation_widget(request, item) for item in setup_items], - 'title': _(u'Setup items'), + 'title': _('Setup items'), } return render_to_response('main/generic_list_horizontal.html', context, diff --git a/mayan/apps/project_tools/__init__.py b/mayan/apps/project_tools/__init__.py index 3336693271..ce190dd4b5 100644 --- a/mayan/apps/project_tools/__init__.py +++ b/mayan/apps/project_tools/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from navigation.api import register_top_menu diff --git a/mayan/apps/project_tools/api.py b/mayan/apps/project_tools/api.py index ed6fba2673..873a901af4 100644 --- a/mayan/apps/project_tools/api.py +++ b/mayan/apps/project_tools/api.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - tool_items = [] diff --git a/mayan/apps/project_tools/links.py b/mayan/apps/project_tools/links.py index a506f6e2f3..91ec789208 100644 --- a/mayan/apps/project_tools/links.py +++ b/mayan/apps/project_tools/links.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ -link_tools = {'text': _(u'Tools'), 'view': 'project_tools:tools_list', 'famfam': 'wrench'} +link_tools = {'text': _('Tools'), 'view': 'project_tools:tools_list', 'famfam': 'wrench'} diff --git a/mayan/apps/project_tools/urls.py b/mayan/apps/project_tools/urls.py index c6156b0714..81725db780 100644 --- a/mayan/apps/project_tools/urls.py +++ b/mayan/apps/project_tools/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('project_tools.views', diff --git a/mayan/apps/project_tools/views.py b/mayan/apps/project_tools/views.py index f2e0490a6f..d8b650b7b9 100644 --- a/mayan/apps/project_tools/views.py +++ b/mayan/apps/project_tools/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.shortcuts import render_to_response from django.template import RequestContext @@ -12,7 +12,7 @@ from .api import tool_items def tools_list(request): context = { 'object_list': [button_navigation_widget(request, item) for item in tool_items], - 'title': _(u'Tools'), + 'title': _('Tools'), } return render_to_response('main/generic_list_horizontal.html', context, diff --git a/mayan/apps/registration/__init__.py b/mayan/apps/registration/__init__.py index 742ceab670..2ad9f22859 100644 --- a/mayan/apps/registration/__init__.py +++ b/mayan/apps/registration/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.dispatch import receiver from south.signals import post_migrate diff --git a/mayan/apps/registration/forms.py b/mayan/apps/registration/forms.py index 340efdbfcc..81ed45bd62 100644 --- a/mayan/apps/registration/forms.py +++ b/mayan/apps/registration/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -10,32 +10,32 @@ logger = logging.getLogger(__name__) class RegistrationForm(forms.Form): name = forms.CharField( - label=_(u'Your name:'), + label=_('Your name:'), required=True ) email = forms.CharField( - label=_(u'Your email:'), + label=_('Your email:'), required=True ) company = forms.CharField( - label=_(u'Company name:'), + label=_('Company name:'), required=False ) industry = forms.CharField( - label=_(u'Industry:'), + label=_('Industry:'), required=False ) website = forms.CharField( - label=_(u'Company website:'), + label=_('Company website:'), required=False ) country = forms.CharField( - label=_(u'Country:'), + label=_('Country:'), required=False ) @@ -43,6 +43,6 @@ class RegistrationForm(forms.Form): widget=forms.widgets.Textarea( attrs={'rows': 2}, ), - label=_(u'Other information:'), + label=_('Other information:'), required=False ) diff --git a/mayan/apps/registration/links.py b/mayan/apps/registration/links.py index ee0da876a8..13937e6e57 100644 --- a/mayan/apps/registration/links.py +++ b/mayan/apps/registration/links.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ diff --git a/mayan/apps/registration/literals.py b/mayan/apps/registration/literals.py index 99d3d6c331..d6c4cf47a1 100644 --- a/mayan/apps/registration/literals.py +++ b/mayan/apps/registration/literals.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + FORM_SUBMIT_URL = 'https://docs.google.com/spreadsheet/formResponse' FORM_KEY = 'dHp4cFBZNHNtc0xwcW9IazVXY1ZmVWc6MQ' FORM_RECEIVER_FIELD = 'entry.0.single' diff --git a/mayan/apps/registration/models.py b/mayan/apps/registration/models.py index 037a3920c4..967987a048 100644 --- a/mayan/apps/registration/models.py +++ b/mayan/apps/registration/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from json import dumps, loads import requests @@ -20,7 +20,7 @@ class RegistrationSingleton(SingletonModel): _registered = None registered = models.BooleanField(default=False, verbose_name=_('Registered')) - registration_data = models.TextField(verbose_name=_(u'Registration data'), blank=True) + registration_data = models.TextField(verbose_name=_('Registration data'), blank=True) @classmethod def registration_state(cls): @@ -46,7 +46,7 @@ class RegistrationSingleton(SingletonModel): if name_value: cls._cached_name = name_value - return name_value or _(u'No name') + return name_value or _('No name') @property def is_registered(self): @@ -83,4 +83,4 @@ class RegistrationSingleton(SingletonModel): lock.release() class Meta: - verbose_name = verbose_name_plural = _(u'Registration properties') + verbose_name = verbose_name_plural = _('Registration properties') diff --git a/mayan/apps/registration/tasks.py b/mayan/apps/registration/tasks.py index 8c94f8de3c..e66d742440 100644 --- a/mayan/apps/registration/tasks.py +++ b/mayan/apps/registration/tasks.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import requests from mayan.celery import app @@ -6,6 +8,7 @@ from .exceptions import AlreadyRegistered from .models import RegistrationSingleton +# TODO: move rate_limit to literals.py @app.task(bind=True, ignore_result=True, max_retries=None, rate_limit='1/m', throws=(AlreadyRegistered,)) def task_registration_register(self, form_data): try: diff --git a/mayan/apps/registration/urls.py b/mayan/apps/registration/urls.py index adcfd72a59..a028797217 100644 --- a/mayan/apps/registration/urls.py +++ b/mayan/apps/registration/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('registration.views', diff --git a/mayan/apps/registration/views.py b/mayan/apps/registration/views.py index 607fc5e9cd..46b038a6c9 100644 --- a/mayan/apps/registration/views.py +++ b/mayan/apps/registration/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import messages from django.core.urlresolvers import reverse @@ -16,19 +16,19 @@ def form_view(request): registration = RegistrationSingleton.objects.get() if registration.registered: - messages.error(request, _(u'Your copy is already registered.')) + messages.error(request, _('Your copy is already registered.')) return HttpResponseRedirect(reverse('main:home')) if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): task_registration_register.apply_async(args=[form.cleaned_data], queue='tools') - messages.success(request, _(u'Thank you for registering.')) + messages.success(request, _('Thank you for registering.')) return HttpResponseRedirect(reverse('main:home')) else: form = RegistrationForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Registration form'), + 'title': _('Registration form'), 'form': form, }, context_instance=RequestContext(request)) diff --git a/mayan/apps/rest_api/__init__.py b/mayan/apps/rest_api/__init__.py index 4302aec3ad..0f9ede78e7 100644 --- a/mayan/apps/rest_api/__init__.py +++ b/mayan/apps/rest_api/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from project_tools.api import register_tool diff --git a/mayan/apps/rest_api/classes.py b/mayan/apps/rest_api/classes.py index ffc96cba7c..b93dffb2d7 100644 --- a/mayan/apps/rest_api/classes.py +++ b/mayan/apps/rest_api/classes.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import include, patterns, url from django.conf import settings diff --git a/mayan/apps/rest_api/filters.py b/mayan/apps/rest_api/filters.py index 345e12b3c3..5132294e19 100644 --- a/mayan/apps/rest_api/filters.py +++ b/mayan/apps/rest_api/filters.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied diff --git a/mayan/apps/rest_api/links.py b/mayan/apps/rest_api/links.py index ec80d6d7f1..fdb786f9a9 100644 --- a/mayan/apps/rest_api/links.py +++ b/mayan/apps/rest_api/links.py @@ -1,4 +1,6 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ -link_api = {'text': _(u'REST API'), 'view': 'api-root', 'famfam': 'disconnect', 'icon': 'disconnect.png'} -link_api_documentation = {'text': _(u'REST API Documentation'), 'view': 'django.swagger.base.view', 'famfam': 'book', 'icon': 'book.png'} +link_api = {'text': _('REST API'), 'view': 'api-root', 'famfam': 'disconnect', 'icon': 'disconnect.png'} +link_api_documentation = {'text': _('REST API Documentation'), 'view': 'django.swagger.base.view', 'famfam': 'book', 'icon': 'book.png'} diff --git a/mayan/apps/rest_api/permissions.py b/mayan/apps/rest_api/permissions.py index 5e6c1bcaec..53686d12d0 100644 --- a/mayan/apps/rest_api/permissions.py +++ b/mayan/apps/rest_api/permissions.py @@ -1,5 +1,7 @@ from __future__ import absolute_import +from __future__ import unicode_literals + from django.core.exceptions import PermissionDenied from rest_framework.permissions import BasePermission diff --git a/mayan/apps/rest_api/serializers.py b/mayan/apps/rest_api/serializers.py index d1fb34d0d7..4faa07ceb7 100644 --- a/mayan/apps/rest_api/serializers.py +++ b/mayan/apps/rest_api/serializers.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from rest_framework import serializers diff --git a/mayan/apps/rest_api/urls.py b/mayan/apps/rest_api/urls.py index 58b96b9445..90841a6a2f 100644 --- a/mayan/apps/rest_api/urls.py +++ b/mayan/apps/rest_api/urls.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import include, patterns, url diff --git a/mayan/apps/rest_api/views.py b/mayan/apps/rest_api/views.py index 1997e4c0d1..da4e89f1eb 100644 --- a/mayan/apps/rest_api/views.py +++ b/mayan/apps/rest_api/views.py @@ -1,5 +1,4 @@ -"""Views file for the rest_api app""" -from __future__ import absolute_import +from __future__ import unicode_literals import logging diff --git a/mayan/apps/smart_settings/__init__.py b/mayan/apps/smart_settings/__init__.py index d483e386ff..3515bf79fd 100644 --- a/mayan/apps/smart_settings/__init__.py +++ b/mayan/apps/smart_settings/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from project_setup.api import register_setup from .links import check_settings diff --git a/mayan/apps/smart_settings/api.py b/mayan/apps/smart_settings/api.py index 51ff694320..e30fcce335 100644 --- a/mayan/apps/smart_settings/api.py +++ b/mayan/apps/smart_settings/api.py @@ -1,10 +1,12 @@ +from __future__ import unicode_literals + from django.conf import settings as django_settings from django.utils.importlib import import_module settings = {} -def register_setting(namespace, module, name, global_name, default, exists=False, description=u'', hidden=False): +def register_setting(namespace, module, name, global_name, default, exists=False, description='', hidden=False): # Create namespace if it doesn't exists settings.setdefault(namespace, []) @@ -43,6 +45,6 @@ def register_settings(namespace, module, settings): setting['global_name'], setting['default'], setting.get('exists', False), - setting.get('description', u''), + setting.get('description', ''), setting.get('hidden', False), ) diff --git a/mayan/apps/smart_settings/links.py b/mayan/apps/smart_settings/links.py index 593ee34df8..5714048a52 100644 --- a/mayan/apps/smart_settings/links.py +++ b/mayan/apps/smart_settings/links.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ @@ -5,4 +7,4 @@ def is_superuser(context): return context['request'].user.is_staff or context['request'].user.is_superuser -check_settings = {'text': _(u'Settings'), 'view': 'settings:setting_list', 'famfam': 'cog', 'icon': 'cog.png', 'condition': is_superuser} +check_settings = {'text': _('Settings'), 'view': 'settings:setting_list', 'famfam': 'cog', 'icon': 'cog.png', 'condition': is_superuser} diff --git a/mayan/apps/smart_settings/urls.py b/mayan/apps/smart_settings/urls.py index 014aa679b4..3547651fa8 100644 --- a/mayan/apps/smart_settings/urls.py +++ b/mayan/apps/smart_settings/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('smart_settings.views', diff --git a/mayan/apps/smart_settings/views.py b/mayan/apps/smart_settings/views.py index c4e68a1843..698bc17ae5 100644 --- a/mayan/apps/smart_settings/views.py +++ b/mayan/apps/smart_settings/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.shortcuts import render_to_response from django.template import RequestContext @@ -26,14 +26,14 @@ def setting_list(request): }) context = { - 'title': _(u'Settings'), + 'title': _('Settings'), 'object_list': sorted(new_settings, key=lambda entry: entry['global_name']), 'hide_link': True, 'hide_object': True, 'extra_columns': [ - {'name': _(u'Name'), 'attribute': encapsulate(lambda x: mark_safe(u'%s
%s' % (x.get('global_name'), x.get('description'))))}, + {'name': _('Name'), 'attribute': encapsulate(lambda x: mark_safe('%s
%s' % (x.get('global_name'), x.get('description'))))}, { - 'name': _(u'Value'), 'attribute': encapsulate(lambda x: mark_safe(u'

%s %s
' % ( + 'name': _('Value'), 'attribute': encapsulate(lambda x: mark_safe('
%s %s
' % ( return_type(getattr(x['module'], x['name'])), exists_with_famfam(getattr(x['module'], x['name'])) if x['exists'] else '' ))) diff --git a/mayan/apps/sources/__init__.py b/mayan/apps/sources/__init__.py index 25fa63260b..e31b6e01b5 100644 --- a/mayan/apps/sources/__init__.py +++ b/mayan/apps/sources/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -10,24 +10,21 @@ from project_setup.api import register_setup from rest_api.classes import APIEndPoint from .classes import StagingFile -from .links import (document_create_multiple, document_create_siblings, - setup_sources, setup_source_create_imap_email, - setup_source_create_pop3_email, - setup_source_create_watch_folder, - setup_source_create_webform, - setup_source_create_staging_folder, - setup_source_delete, setup_source_edit, - setup_source_transformation_create, - setup_source_transformation_delete, - setup_source_transformation_edit, - setup_source_transformation_list, - staging_file_delete, upload_version) +from .links import ( + document_create_multiple, document_create_siblings, setup_sources, + setup_source_create_imap_email, setup_source_create_pop3_email, + setup_source_create_watch_folder, setup_source_create_webform, + setup_source_create_staging_folder, setup_source_delete, setup_source_edit, + setup_source_transformation_create, setup_source_transformation_delete, + setup_source_transformation_edit, setup_source_transformation_list, + staging_file_delete, upload_version +) from .models import Source, SourceTransformation from .widgets import staging_file_thumbnail register_model_list_columns(StagingFile, [ { - 'name': _(u'Thumbnail'), 'attribute': + 'name': _('Thumbnail'), 'attribute': encapsulate(lambda x: staging_file_thumbnail(x, gallery_name='sources:staging_list', title=x.filename, size='100')) }, ]) diff --git a/mayan/apps/sources/admin.py b/mayan/apps/sources/admin.py index 7b7041b2e2..0ac2cc995a 100644 --- a/mayan/apps/sources/admin.py +++ b/mayan/apps/sources/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from .models import (SourceTransformation, StagingFolderSource, diff --git a/mayan/apps/sources/api_views.py b/mayan/apps/sources/api_views.py index 18cce831c1..3186eb6809 100644 --- a/mayan/apps/sources/api_views.py +++ b/mayan/apps/sources/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.shortcuts import get_object_or_404 diff --git a/mayan/apps/sources/classes.py b/mayan/apps/sources/classes.py index 9627aec3ac..9e334cc5a4 100644 --- a/mayan/apps/sources/classes.py +++ b/mayan/apps/sources/classes.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import base64 import os @@ -69,7 +69,7 @@ class StagingFile(object): image = open(converted_file_path, 'r') base64_data = base64.b64encode(image.read()) image.close() - return u'data:%s;base64,%s' % (mimetype, base64_data) + return 'data:%s;base64,%s' % (mimetype, base64_data) else: return converted_file_path diff --git a/mayan/apps/sources/forms.py b/mayan/apps/sources/forms.py index 666a9b589f..de3dde21b7 100644 --- a/mayan/apps/sources/forms.py +++ b/mayan/apps/sources/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging @@ -26,7 +26,7 @@ class NewVersionForm(forms.Form): super(NewVersionForm, self).__init__(*args, **kwargs) self.fields['comment'] = forms.CharField( - label=_(u'Comment'), + label=_('Comment'), required=False, widget=forms.widgets.Textarea(attrs={'rows': 4}), ) @@ -41,8 +41,8 @@ class UploadBaseForm(forms.Form): if show_expand: self.fields['expand'] = forms.BooleanField( - label=_(u'Expand compressed files'), required=False, - help_text=ugettext(u'Upload a compressed file\'s contained files as individual documents') + label=_('Expand compressed files'), required=False, + help_text=ugettext('Upload a compressed file\'s contained files as individual documents') ) @@ -67,11 +67,11 @@ class StagingUploadForm(UploadBaseForm): staging_list = self.fields.keyOrder.pop(staging_list_index) self.fields.keyOrder.insert(0, staging_list) - staging_file_id = forms.ChoiceField(label=_(u'Staging file')) + staging_file_id = forms.ChoiceField(label=_('Staging file')) class WebFormUploadForm(UploadBaseForm): - file = forms.FileField(label=_(u'File')) + file = forms.FileField(label=_('File')) def __init__(self, *args, **kwargs): super(WebFormUploadForm, self).__init__(*args, **kwargs) diff --git a/mayan/apps/sources/links.py b/mayan/apps/sources/links.py index ece11da841..069593b538 100644 --- a/mayan/apps/sources/links.py +++ b/mayan/apps/sources/links.py @@ -1,37 +1,39 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ -from documents.permissions import (PERMISSION_DOCUMENT_CREATE, - PERMISSION_DOCUMENT_NEW_VERSION) +from documents.permissions import ( + PERMISSION_DOCUMENT_CREATE, PERMISSION_DOCUMENT_NEW_VERSION +) -from .literals import (SOURCE_CHOICE_WEB_FORM, SOURCE_CHOICE_EMAIL_IMAP, - SOURCE_CHOICE_EMAIL_POP3, SOURCE_CHOICE_STAGING, - SOURCE_CHOICE_WATCH) -from .permissions import (PERMISSION_SOURCES_SETUP_CREATE, - PERMISSION_SOURCES_SETUP_DELETE, - PERMISSION_SOURCES_SETUP_EDIT, - PERMISSION_SOURCES_SETUP_VIEW) +from .literals import ( + SOURCE_CHOICE_WEB_FORM, SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3, + SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH +) +from .permissions import ( + PERMISSION_SOURCES_SETUP_CREATE, PERMISSION_SOURCES_SETUP_DELETE, + PERMISSION_SOURCES_SETUP_EDIT, PERMISSION_SOURCES_SETUP_VIEW +) -document_create_multiple = {'text': _(u'Upload new documents'), 'view': 'sources:document_create_multiple', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_CREATE]} -document_create_siblings = {'text': _(u'Clone'), 'view': 'sources:document_create_siblings', 'args': 'object.id', 'famfam': 'page_copy', 'permissions': [PERMISSION_DOCUMENT_CREATE]} +document_create_multiple = {'text': _('Upload new documents'), 'view': 'sources:document_create_multiple', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_CREATE]} +document_create_siblings = {'text': _('Clone'), 'view': 'sources:document_create_siblings', 'args': 'object.id', 'famfam': 'page_copy', 'permissions': [PERMISSION_DOCUMENT_CREATE]} -staging_file_delete = {'text': _(u'Delete'), 'view': 'sources:staging_file_delete', 'args': ['source.pk', 'object.encoded_filename'], 'famfam': 'delete', 'keep_query': True, 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION, PERMISSION_DOCUMENT_CREATE]} +staging_file_delete = {'text': _('Delete'), 'view': 'sources:staging_file_delete', 'args': ['source.pk', 'object.encoded_filename'], 'famfam': 'delete', 'keep_query': True, 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION, PERMISSION_DOCUMENT_CREATE]} -setup_sources = {'text': _(u'Sources'), 'view': 'sources:setup_source_list', 'famfam': 'application_form', 'icon': 'application_form.png', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]} -setup_source_create_webform = {'text': _(u'Add new webform source'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WEB_FORM, 'famfam': 'application_form_add', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WEB_FORM and 'source' not in context} -setup_source_create_staging_folder = {'text': _(u'Add new staging folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_STAGING, 'famfam': 'folder_camera', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_STAGING and 'source' not in context} -setup_source_create_watch_folder = {'text': _(u'Add new watch folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WATCH, 'famfam': 'folder_magnify', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WATCH and 'source' not in context} -setup_source_create_pop3_email = {'text': _(u'Add new POP3 email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_POP3, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_POP3 and 'source' not in context} -setup_source_create_imap_email = {'text': _(u'Add new IMAP email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_IMAP, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_IMAP and 'source' not in context} -setup_source_delete = {'text': _(u'Delete'), 'view': 'sources:setup_source_delete', 'args': ['source.pk'], 'famfam': 'application_form_delete', 'permissions': [PERMISSION_SOURCES_SETUP_DELETE]} -setup_source_edit = {'text': _(u'Edit'), 'view': 'sources:setup_source_edit', 'args': ['source.pk'], 'famfam': 'application_form_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} +setup_sources = {'text': _('Sources'), 'view': 'sources:setup_source_list', 'famfam': 'application_form', 'icon': 'application_form.png', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]} +setup_source_create_webform = {'text': _('Add new webform source'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WEB_FORM, 'famfam': 'application_form_add', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WEB_FORM and 'source' not in context} +setup_source_create_staging_folder = {'text': _('Add new staging folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_STAGING, 'famfam': 'folder_camera', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_STAGING and 'source' not in context} +setup_source_create_watch_folder = {'text': _('Add new watch folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WATCH, 'famfam': 'folder_magnify', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WATCH and 'source' not in context} +setup_source_create_pop3_email = {'text': _('Add new POP3 email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_POP3, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_POP3 and 'source' not in context} +setup_source_create_imap_email = {'text': _('Add new IMAP email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_IMAP, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_IMAP and 'source' not in context} +setup_source_delete = {'text': _('Delete'), 'view': 'sources:setup_source_delete', 'args': ['source.pk'], 'famfam': 'application_form_delete', 'permissions': [PERMISSION_SOURCES_SETUP_DELETE]} +setup_source_edit = {'text': _('Edit'), 'view': 'sources:setup_source_edit', 'args': ['source.pk'], 'famfam': 'application_form_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} -setup_source_transformation_list = {'text': _(u'Transformations'), 'view': 'sources:setup_source_transformation_list', 'args': ['source.pk'], 'famfam': 'shape_move_front', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} -setup_source_transformation_create = {'text': _(u'Add transformation'), 'view': 'sources:setup_source_transformation_create', 'args': ['source.pk'], 'famfam': 'shape_square_add', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} -setup_source_transformation_edit = {'text': _(u'Edit'), 'view': 'sources:setup_source_transformation_edit', 'args': 'transformation.pk', 'famfam': 'shape_square_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} -setup_source_transformation_delete = {'text': _(u'Delete'), 'view': 'sources:setup_source_transformation_delete', 'args': 'transformation.pk', 'famfam': 'shape_square_delete', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} +setup_source_transformation_list = {'text': _('Transformations'), 'view': 'sources:setup_source_transformation_list', 'args': ['source.pk'], 'famfam': 'shape_move_front', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} +setup_source_transformation_create = {'text': _('Add transformation'), 'view': 'sources:setup_source_transformation_create', 'args': ['source.pk'], 'famfam': 'shape_square_add', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} +setup_source_transformation_edit = {'text': _('Edit'), 'view': 'sources:setup_source_transformation_edit', 'args': 'transformation.pk', 'famfam': 'shape_square_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} +setup_source_transformation_delete = {'text': _('Delete'), 'view': 'sources:setup_source_transformation_delete', 'args': 'transformation.pk', 'famfam': 'shape_square_delete', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} -source_list = {'text': _(u'Document sources'), 'view': 'sources:setup_web_form_list', 'famfam': 'page_add', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]} +source_list = {'text': _('Document sources'), 'view': 'sources:setup_web_form_list', 'famfam': 'page_add', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW]} -upload_version = {'text': _(u'Upload new version'), 'view': 'sources:upload_version', 'args': 'object.pk', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION]} +upload_version = {'text': _('Upload new version'), 'view': 'sources:upload_version', 'args': 'object.pk', 'famfam': 'page_add', 'permissions': [PERMISSION_DOCUMENT_NEW_VERSION]} diff --git a/mayan/apps/sources/literals.py b/mayan/apps/sources/literals.py index eb69ed826d..be30f742fd 100644 --- a/mayan/apps/sources/literals.py +++ b/mayan/apps/sources/literals.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.translation import ugettext_lazy as _ SOURCE_UNCOMPRESS_CHOICE_Y = 'y' @@ -5,14 +7,14 @@ SOURCE_UNCOMPRESS_CHOICE_N = 'n' SOURCE_UNCOMPRESS_CHOICE_ASK = 'a' SOURCE_UNCOMPRESS_CHOICES = ( - (SOURCE_UNCOMPRESS_CHOICE_Y, _(u'Always')), - (SOURCE_UNCOMPRESS_CHOICE_N, _(u'Never')), + (SOURCE_UNCOMPRESS_CHOICE_Y, _('Always')), + (SOURCE_UNCOMPRESS_CHOICE_N, _('Never')), ) SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES = ( - (SOURCE_UNCOMPRESS_CHOICE_Y, _(u'Always')), - (SOURCE_UNCOMPRESS_CHOICE_N, _(u'Never')), - (SOURCE_UNCOMPRESS_CHOICE_ASK, _(u'Ask user')) + (SOURCE_UNCOMPRESS_CHOICE_Y, _('Always')), + (SOURCE_UNCOMPRESS_CHOICE_N, _('Never')), + (SOURCE_UNCOMPRESS_CHOICE_ASK, _('Ask user')) ) SOURCE_CHOICE_WEB_FORM = 'webform' @@ -22,11 +24,11 @@ SOURCE_CHOICE_EMAIL_POP3 = 'pop3' SOURCE_CHOICE_EMAIL_IMAP = 'imap' SOURCE_CHOICES = ( - (SOURCE_CHOICE_WEB_FORM, _(u'Web form')), - (SOURCE_CHOICE_STAGING, _(u'Staging folder')), - (SOURCE_CHOICE_WATCH, _(u'Watch folder')), - (SOURCE_CHOICE_EMAIL_POP3, _(u'POP3 email')), - (SOURCE_CHOICE_EMAIL_IMAP, _(u'IMAP email')), + (SOURCE_CHOICE_WEB_FORM, _('Web form')), + (SOURCE_CHOICE_STAGING, _('Staging folder')), + (SOURCE_CHOICE_WATCH, _('Watch folder')), + (SOURCE_CHOICE_EMAIL_POP3, _('POP3 email')), + (SOURCE_CHOICE_EMAIL_IMAP, _('IMAP email')), ) DEFAULT_INTERVAL = 60 diff --git a/mayan/apps/sources/managers.py b/mayan/apps/sources/managers.py index fc30d430b4..87f81b5033 100644 --- a/mayan/apps/sources/managers.py +++ b/mayan/apps/sources/managers.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from ast import literal_eval from django.contrib.contenttypes.models import ContentType diff --git a/mayan/apps/sources/models.py b/mayan/apps/sources/models.py index 93c1c57e5d..0280cb6303 100644 --- a/mayan/apps/sources/models.py +++ b/mayan/apps/sources/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from ast import literal_eval from email.Utils import collapse_rfc2231_value @@ -25,21 +25,21 @@ from documents.models import Document, DocumentType from metadata.api import save_metadata_list from .classes import Attachment, SourceUploadedFile, StagingFile -from .literals import (DEFAULT_INTERVAL, DEFAULT_POP3_TIMEOUT, - DEFAULT_IMAP_MAILBOX, SOURCE_CHOICES, - SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH, - SOURCE_CHOICE_WEB_FORM, - SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, - SOURCE_UNCOMPRESS_CHOICES, SOURCE_UNCOMPRESS_CHOICE_Y, - SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3) +from .literals import ( + DEFAULT_INTERVAL, DEFAULT_POP3_TIMEOUT, DEFAULT_IMAP_MAILBOX, + SOURCE_CHOICES, SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH, + SOURCE_CHOICE_WEB_FORM, SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, + SOURCE_UNCOMPRESS_CHOICES, SOURCE_UNCOMPRESS_CHOICE_Y, + SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3 +) from .managers import SourceTransformationManager logger = logging.getLogger(__name__) class Source(models.Model): - title = models.CharField(max_length=64, verbose_name=_(u'Title')) - enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled')) + title = models.CharField(max_length=64, verbose_name=_('Title')) + enabled = models.BooleanField(default=True, verbose_name=_('Enabled')) objects = InheritanceManager() @@ -48,10 +48,10 @@ class Source(models.Model): return unicode(dict(SOURCE_CHOICES).get(cls.source_type)) def __unicode__(self): - return u'%s' % self.title + return '%s' % self.title def fullname(self): - return u' '.join([self.class_fullname(), '"%s"' % self.title]) + return ' '.join([self.class_fullname(), '"%s"' % self.title]) def get_transformation_list(self): return SourceTransformation.transformations.get_for_object_as_list(self) @@ -82,27 +82,27 @@ class Source(models.Model): class Meta: ordering = ('title',) - verbose_name = _(u'Source') - verbose_name_plural = _(u'Sources') + verbose_name = _('Source') + verbose_name_plural = _('Sources') class InteractiveSource(Source): objects = InheritanceManager() class Meta: - verbose_name = _(u'Interactive source') - verbose_name_plural = _(u'Interactive sources') + verbose_name = _('Interactive source') + verbose_name_plural = _('Interactive sources') class StagingFolderSource(InteractiveSource): is_interactive = True source_type = SOURCE_CHOICE_STAGING - folder_path = models.CharField(max_length=255, verbose_name=_(u'Folder path'), help_text=_(u'Server side filesystem path.')) - preview_width = models.IntegerField(verbose_name=_(u'Preview width'), help_text=_(u'Width value to be passed to the converter backend.')) - preview_height = models.IntegerField(blank=True, null=True, verbose_name=_(u'Preview height'), help_text=_(u'Height value to be passed to the converter backend.')) - uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_(u'Uncompress'), help_text=_(u'Whether to expand or not compressed archives.')) - delete_after_upload = models.BooleanField(default=True, verbose_name=_(u'Delete after upload'), help_text=_(u'Delete the file after is has been successfully uploaded.')) + folder_path = models.CharField(max_length=255, verbose_name=_('Folder path'), help_text=_('Server side filesystem path.')) + preview_width = models.IntegerField(verbose_name=_('Preview width'), help_text=_('Width value to be passed to the converter backend.')) + preview_height = models.IntegerField(blank=True, null=True, verbose_name=_('Preview height'), help_text=_('Height value to be passed to the converter backend.')) + uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_('Uncompress'), help_text=_('Whether to expand or not compressed archives.')) + delete_after_upload = models.BooleanField(default=True, verbose_name=_('Delete after upload'), help_text=_('Delete the file after is has been successfully uploaded.')) def get_preview_size(self): dimensions = [] @@ -120,7 +120,7 @@ class StagingFolderSource(InteractiveSource): for entry in sorted([os.path.normcase(f) for f in os.listdir(self.folder_path) if os.path.isfile(os.path.join(self.folder_path, f))]): yield self.get_file(filename=entry) except OSError as exception: - raise Exception(_(u'Unable get list of staging files: %s') % exception) + raise Exception(_('Unable get list of staging files: %s') % exception) def get_upload_file_object(self, form_data): staging_file = self.get_file(encoded_filename=form_data['staging_file_id']) @@ -131,11 +131,11 @@ class StagingFolderSource(InteractiveSource): try: upload_file_object.extra_data.delete() except Exception as exception: - raise Exception(_(u'Error deleting staging file; %s') % exception) + raise Exception(_('Error deleting staging file; %s') % exception) class Meta: - verbose_name = _(u'Staging folder') - verbose_name_plural = _(u'Staging folders') + verbose_name = _('Staging folder') + verbose_name_plural = _('Staging folders') class WebFormSource(InteractiveSource): @@ -143,23 +143,23 @@ class WebFormSource(InteractiveSource): source_type = SOURCE_CHOICE_WEB_FORM # TODO: unify uncompress as an InteractiveSource field - uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_(u'Uncompress'), help_text=_(u'Whether to expand or not compressed archives.')) + uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_('Uncompress'), help_text=_('Whether to expand or not compressed archives.')) # Default path def get_upload_file_object(self, form_data): return SourceUploadedFile(source=self, file=form_data['file']) class Meta: - verbose_name = _(u'Web form') - verbose_name_plural = _(u'Web forms') + verbose_name = _('Web form') + verbose_name_plural = _('Web forms') class OutOfProcessSource(Source): is_interactive = False class Meta: - verbose_name = _(u'Out of process') - verbose_name_plural = _(u'Out of process') + verbose_name = _('Out of process') + verbose_name_plural = _('Out of process') class IntervalBaseModel(OutOfProcessSource): @@ -337,7 +337,7 @@ class IMAPEmail(EmailBaseModel): class WatchFolderSource(IntervalBaseModel): source_type = SOURCE_CHOICE_WATCH - folder_path = models.CharField(max_length=255, verbose_name=_(u'Folder path'), help_text=_(u'Server side filesystem path.')) + folder_path = models.CharField(max_length=255, verbose_name=_('Folder path'), help_text=_('Server side filesystem path.')) def check_source(self): for file_name in os.listdir(self.folder_path): @@ -349,12 +349,12 @@ class WatchFolderSource(IntervalBaseModel): os.unlink(full_path) class Meta: - verbose_name = _(u'Watch folder') - verbose_name_plural = _(u'Watch folders') + verbose_name = _('Watch folder') + verbose_name_plural = _('Watch folders') class ArgumentsValidator(object): - message = _(u'Enter a valid value.') + message = _('Enter a valid value.') code = 'invalid' def __init__(self, message=None, code=None): @@ -382,9 +382,9 @@ class SourceTransformation(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') - order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_(u'Order'), db_index=True) - transformation = models.CharField(choices=get_available_transformations_choices(), max_length=128, verbose_name=_(u'Transformation')) - arguments = models.TextField(blank=True, null=True, verbose_name=_(u'Arguments'), help_text=_(u'Use dictionaries to indentify arguments, example: %s') % u'{\'degrees\':90}', validators=[ArgumentsValidator()]) + order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_('Order'), db_index=True) + transformation = models.CharField(choices=get_available_transformations_choices(), max_length=128, verbose_name=_('Transformation')) + arguments = models.TextField(blank=True, null=True, verbose_name=_('Arguments'), help_text=_('Use dictionaries to indentify arguments, example: %s') % '{\'degrees\':90}', validators=[ArgumentsValidator()]) objects = models.Manager() transformations = SourceTransformationManager() @@ -394,5 +394,5 @@ class SourceTransformation(models.Model): class Meta: ordering = ('order',) - verbose_name = _(u'Document source transformation') - verbose_name_plural = _(u'Document source transformations') + verbose_name = _('Document source transformation') + verbose_name_plural = _('Document source transformations') diff --git a/mayan/apps/sources/permissions.py b/mayan/apps/sources/permissions.py index 13927619f1..78fa41ec59 100644 --- a/mayan/apps/sources/permissions.py +++ b/mayan/apps/sources/permissions.py @@ -1,11 +1,11 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import Permission, PermissionNamespace -sources_setup_namespace = PermissionNamespace('sources_setup', _(u'Sources setup')) -PERMISSION_SOURCES_SETUP_CREATE = Permission.objects.register(sources_setup_namespace, 'sources_setup_create', _(u'Create new document sources')) -PERMISSION_SOURCES_SETUP_DELETE = Permission.objects.register(sources_setup_namespace, 'sources_setup_delete', _(u'Delete document sources')) -PERMISSION_SOURCES_SETUP_EDIT = Permission.objects.register(sources_setup_namespace, 'sources_setup_edit', _(u'Edit document sources')) -PERMISSION_SOURCES_SETUP_VIEW = Permission.objects.register(sources_setup_namespace, 'sources_setup_view', _(u'View existing document sources')) +sources_setup_namespace = PermissionNamespace('sources_setup', _('Sources setup')) +PERMISSION_SOURCES_SETUP_CREATE = Permission.objects.register(sources_setup_namespace, 'sources_setup_create', _('Create new document sources')) +PERMISSION_SOURCES_SETUP_DELETE = Permission.objects.register(sources_setup_namespace, 'sources_setup_delete', _('Delete document sources')) +PERMISSION_SOURCES_SETUP_EDIT = Permission.objects.register(sources_setup_namespace, 'sources_setup_edit', _('Edit document sources')) +PERMISSION_SOURCES_SETUP_VIEW = Permission.objects.register(sources_setup_namespace, 'sources_setup_view', _('View existing document sources')) diff --git a/mayan/apps/sources/serializers.py b/mayan/apps/sources/serializers.py index f58dbe8523..d40a2ca350 100644 --- a/mayan/apps/sources/serializers.py +++ b/mayan/apps/sources/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import logging diff --git a/mayan/apps/sources/tasks.py b/mayan/apps/sources/tasks.py index 917c0f1574..87557df418 100644 --- a/mayan/apps/sources/tasks.py +++ b/mayan/apps/sources/tasks.py @@ -38,10 +38,10 @@ def task_source_upload_document(label, document_type_id, shared_uploaded_file_id # TODO: Report/record how was file uploaded # if result['is_compressed'] is None: - # messages.success(request, _(u'File uploaded successfully.')) + # messages.success(request, _('File uploaded successfully.')) # if result['is_compressed'] is True: - # messages.success(request, _(u'File uncompressed successfully and uploaded as individual files.')) + # messages.success(request, _('File uncompressed successfully and uploaded as individual files.')) # if result['is_compressed'] is False: - # messages.warning(request, _(u'File was not a compressed file, uploaded as it was.')) + # messages.warning(request, _('File was not a compressed file, uploaded as it was.')) diff --git a/mayan/apps/sources/tests.py b/mayan/apps/sources/tests.py index 75895b5b61..55ceddd62f 100644 --- a/mayan/apps/sources/tests.py +++ b/mayan/apps/sources/tests.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from json import loads from django.conf import settings diff --git a/mayan/apps/sources/urls.py b/mayan/apps/sources/urls.py index da99680c50..3a86e01007 100644 --- a/mayan/apps/sources/urls.py +++ b/mayan/apps/sources/urls.py @@ -1,9 +1,11 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import patterns, url -from .api_views import (APIStagingSourceFileView, APIStagingSourceFileImageView, - APIStagingSourceListView, APIStagingSourceView) +from .api_views import ( + APIStagingSourceFileView, APIStagingSourceFileImageView, + APIStagingSourceListView, APIStagingSourceView +) from .views import UploadInteractiveVersionView, UploadInteractiveView from .wizards import DocumentCreateWizard diff --git a/mayan/apps/sources/utils.py b/mayan/apps/sources/utils.py index 4b46fa9887..68ff27fe72 100644 --- a/mayan/apps/sources/utils.py +++ b/mayan/apps/sources/utils.py @@ -1,11 +1,15 @@ -from .forms import (POP3EmailSetupForm, IMAPEmailSetupForm, - StagingFolderSetupForm, StagingUploadForm, - WatchFolderSetupForm, WebFormSetupForm, WebFormUploadForm) -from .literals import (SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3, - SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH, - SOURCE_CHOICE_WEB_FORM) -from .models import (IMAPEmail, POP3Email, StagingFolderSource, - WatchFolderSource, WebFormSource) +from .forms import ( + POP3EmailSetupForm, IMAPEmailSetupForm, + StagingFolderSetupForm, StagingUploadForm, WatchFolderSetupForm, + WebFormSetupForm, WebFormUploadForm +) +from .literals import ( + SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3, SOURCE_CHOICE_STAGING, + SOURCE_CHOICE_WATCH, SOURCE_CHOICE_WEB_FORM +) +from .models import ( + IMAPEmail, POP3Email, StagingFolderSource, WatchFolderSource, WebFormSource +) def get_class(source_type): diff --git a/mayan/apps/sources/views.py b/mayan/apps/sources/views.py index 0fe79ac519..a852f78fd3 100644 --- a/mayan/apps/sources/views.py +++ b/mayan/apps/sources/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.conf import settings from django.contrib import messages @@ -15,22 +15,29 @@ from common.models import SharedUploadedFile from common.utils import encapsulate from common.views import MultiFormView from documents.models import DocumentType, Document -from documents.permissions import (PERMISSION_DOCUMENT_CREATE, - PERMISSION_DOCUMENT_NEW_VERSION) +from documents.permissions import ( + PERMISSION_DOCUMENT_CREATE, PERMISSION_DOCUMENT_NEW_VERSION +) from documents.tasks import task_upload_new_version from metadata.api import decode_metadata_from_url, metadata_repr_as_list from permissions.models import Permission -from .forms import (NewDocumentForm, NewVersionForm, SourceTransformationForm, - SourceTransformationForm_create) -from .literals import (SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WEB_FORM, - SOURCE_UNCOMPRESS_CHOICE_ASK, SOURCE_UNCOMPRESS_CHOICE_Y) -from .models import (InteractiveSource, Source, StagingFolderSource, - SourceTransformation, WebFormSource) -from .permissions import (PERMISSION_SOURCES_SETUP_CREATE, - PERMISSION_SOURCES_SETUP_DELETE, - PERMISSION_SOURCES_SETUP_EDIT, - PERMISSION_SOURCES_SETUP_VIEW) +from .forms import ( + NewDocumentForm, NewVersionForm, SourceTransformationForm, + SourceTransformationForm_create +) +from .literals import ( + SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WEB_FORM, SOURCE_UNCOMPRESS_CHOICE_ASK, + SOURCE_UNCOMPRESS_CHOICE_Y +) +from .models import ( + InteractiveSource, Source, StagingFolderSource, SourceTransformation, + WebFormSource +) +from .permissions import ( + PERMISSION_SOURCES_SETUP_CREATE, PERMISSION_SOURCES_SETUP_DELETE, + PERMISSION_SOURCES_SETUP_EDIT, PERMISSION_SOURCES_SETUP_VIEW +) from .tasks import task_source_upload_document from .utils import get_class, get_form_class, get_upload_form_class @@ -56,10 +63,10 @@ def conditional_highlight_factory(obj): def get_tab_link_for_source(source, document=None): if document: - view = u'sources:upload_version' + view = 'sources:upload_version' args = [document.pk, source.pk] else: - view = u'sources:upload_interactive' + view = 'sources:upload_interactive' args = [source.pk] return { @@ -102,7 +109,7 @@ class UploadBaseView(MultiFormView): self.source = InteractiveSource.objects.filter(enabled=True).select_subclasses().first() if InteractiveSource.objects.filter(enabled=True).count() == 0: - messages.error(request, _(u'No interactive document sources have been defined or none have been enabled, create one before proceeding.')) + messages.error(request, _('No interactive document sources have been defined or none have been enabled, create one before proceeding.')) return HttpResponseRedirect(reverse('sources:setup_source_list')) return super(UploadBaseView, self).dispatch(request, *args, **kwargs) @@ -130,7 +137,7 @@ class UploadBaseView(MultiFormView): { 'name': 'main/generic_list_subtemplate.html', 'context': { - 'title': _(u'Files in staging path'), + 'title': _('Files in staging path'), 'object_list': staging_filelist, 'hide_link': True, } @@ -214,7 +221,7 @@ class UploadInteractiveView(UploadBaseView): source_id=self.source.pk, user_id=user_id, ), queue='uploads') - messages.success(self.request, _(u'New document queued for uploaded and will be available shortly.')) + messages.success(self.request, _('New document queued for uploaded and will be available shortly.')) return HttpResponseRedirect(self.request.get_full_path()) def create_source_form_form(self, **kwargs): @@ -239,7 +246,7 @@ class UploadInteractiveView(UploadBaseView): def get_context_data(self, **kwargs): context = super(UploadInteractiveView, self).get_context_data(**kwargs) - context['title'] = _(u'Upload a local document from source: %s') % self.source.title + context['title'] = _('Upload a local document from source: %s') % self.source.title context.update( { @@ -247,15 +254,15 @@ class UploadInteractiveView(UploadBaseView): { 'name': 'main/generic_subtemplate.html', 'context': { - 'title': _(u'Current document type'), - 'paragraphs': [self.document_type if self.document_type else _(u'None')], + 'title': _('Current document type'), + 'paragraphs': [self.document_type if self.document_type else _('None')], 'side_bar': True, } }, { 'name': 'main/generic_subtemplate.html', 'context': { - 'title': _(u'Current metadata'), + 'title': _('Current metadata'), 'paragraphs': metadata_repr_as_list(decode_metadata_from_url(self.request.GET)), 'side_bar': True, } @@ -303,7 +310,7 @@ class UploadInteractiveVersionView(UploadBaseView): comment=forms['document_form'].cleaned_data.get('comment') ), queue='uploads') - messages.success(self.request, _(u'New document version queued for uploaded and will be available shortly.')) + messages.success(self.request, _('New document version queued for uploaded and will be available shortly.')) return HttpResponseRedirect(reverse('documents:document_version_list', args=[self.document.pk])) def create_source_form_form(self, **kwargs): @@ -329,7 +336,7 @@ class UploadInteractiveVersionView(UploadBaseView): def get_context_data(self, **kwargs): context = super(UploadInteractiveVersionView, self).get_context_data(**kwargs) context['object'] = self.document - context['title'] = _(u'Upload a new version from source: %s') % self.source.title + context['title'] = _('Upload a new version from source: %s') % self.source.title return context @@ -345,9 +352,9 @@ def staging_file_delete(request, staging_folder_pk, encoded_filename): if request.method == 'POST': try: staging_file.delete() - messages.success(request, _(u'Staging file delete successfully.')) + messages.success(request, _('Staging file delete successfully.')) except Exception as exception: - messages.error(request, _(u'Staging file delete error; %s.') % exception) + messages.error(request, _('Staging file delete error; %s.') % exception) return HttpResponseRedirect(next) results = get_active_tab_links() @@ -400,15 +407,15 @@ def setup_source_edit(request, source_id): if form.is_valid(): try: form.save() - messages.success(request, _(u'Source edited successfully')) + messages.success(request, _('Source edited successfully')) return HttpResponseRedirect(next) except Exception as exception: - messages.error(request, _(u'Error editing source; %s') % exception) + messages.error(request, _('Error editing source; %s') % exception) else: form = form_class(instance=source) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit source: %s') % source, + 'title': _('Edit source: %s') % source, 'form': form, 'source': source, 'navigation_object_name': 'source', @@ -427,15 +434,15 @@ def setup_source_delete(request, source_id): if request.method == 'POST': try: source.delete() - messages.success(request, _(u'Source "%s" deleted successfully.') % source) + messages.success(request, _('Source "%s" deleted successfully.') % source) except Exception as exception: - messages.error(request, _(u'Error deleting source "%(source)s": %(error)s') % { + messages.error(request, _('Error deleting source "%(source)s": %(error)s') % { 'source': source, 'error': exception }) return HttpResponseRedirect(redirect_view) context = { - 'title': _(u'Are you sure you wish to delete the source: %s?') % source, + 'title': _('Are you sure you wish to delete the source: %s?') % source, 'source': source, 'navigation_object_name': 'source', 'delete_view': True, @@ -458,15 +465,15 @@ def setup_source_create(request, source_type): if form.is_valid(): try: form.save() - messages.success(request, _(u'Source created successfully')) + messages.success(request, _('Source created successfully')) return HttpResponseRedirect(reverse('sources:setup_source_list')) except Exception as exception: - messages.error(request, _(u'Error creating source; %s') % exception) + messages.error(request, _('Error creating source; %s') % exception) else: form = form_class() return render_to_response('main/generic_form.html', { - 'title': _(u'Create new source of type: %s') % cls.class_fullname(), + 'title': _('Create new source of type: %s') % cls.class_fullname(), 'form': form, 'source_type': source_type, 'navigation_object_name': 'source', @@ -480,14 +487,14 @@ def setup_source_transformation_list(request, source_id): context = { 'object_list': SourceTransformation.transformations.get_for_object(source), - 'title': _(u'Transformations for: %s') % source.fullname(), + 'title': _('Transformations for: %s') % source.fullname(), 'source': source, 'navigation_object_name': 'source', 'list_object_variable_name': 'transformation', 'extra_columns': [ - {'name': _(u'Order'), 'attribute': 'order'}, - {'name': _(u'Transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())}, - {'name': _(u'Arguments'), 'attribute': 'arguments'} + {'name': _('Order'), 'attribute': 'order'}, + {'name': _('Transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())}, + {'name': _('Arguments'), 'attribute': 'arguments'} ], 'hide_link': True, 'hide_object': True, @@ -509,21 +516,21 @@ def setup_source_transformation_edit(request, transformation_id): if form.is_valid(): try: form.save() - messages.success(request, _(u'Source transformation edited successfully')) + messages.success(request, _('Source transformation edited successfully')) return HttpResponseRedirect(next) except Exception as exception: - messages.error(request, _(u'Error editing source transformation; %s') % exception) + messages.error(request, _('Error editing source transformation; %s') % exception) else: form = SourceTransformationForm(instance=source_transformation) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit transformation: %s') % source_transformation, + 'title': _('Edit transformation: %s') % source_transformation, 'form': form, 'source': source_transformation.content_object, 'transformation': source_transformation, 'navigation_object_list': [ - {'object': 'source', 'name': _(u'Source')}, - {'object': 'transformation', 'name': _(u'Transformation')} + {'object': 'source', 'name': _('Source')}, + {'object': 'transformation', 'name': _('Transformation')} ], 'next': next, }, context_instance=RequestContext(request)) @@ -539,9 +546,9 @@ def setup_source_transformation_delete(request, transformation_id): if request.method == 'POST': try: source_transformation.delete() - messages.success(request, _(u'Source transformation deleted successfully.')) + messages.success(request, _('Source transformation deleted successfully.')) except Exception as exception: - messages.error(request, _(u'Error deleting source transformation; %(error)s') % { + messages.error(request, _('Error deleting source transformation; %(error)s') % { 'error': exception} ) return HttpResponseRedirect(redirect_view) @@ -551,10 +558,10 @@ def setup_source_transformation_delete(request, transformation_id): 'transformation': source_transformation, 'source': source_transformation.content_object, 'navigation_object_list': [ - {'object': 'source', 'name': _(u'Source')}, - {'object': 'transformation', 'name': _(u'Transformation')} + {'object': 'source', 'name': _('Source')}, + {'object': 'transformation', 'name': _('Transformation')} ], - 'title': _(u'Are you sure you wish to delete source transformation "%(transformation)s"') % { + 'title': _('Are you sure you wish to delete source transformation "%(transformation)s"') % { 'transformation': source_transformation.get_transformation_display(), }, 'previous': previous, @@ -575,10 +582,10 @@ def setup_source_transformation_create(request, source_id): source_tranformation = form.save(commit=False) source_tranformation.content_object = source source_tranformation.save() - messages.success(request, _(u'Source transformation created successfully')) + messages.success(request, _('Source transformation created successfully')) return HttpResponseRedirect(redirect_view) except Exception as exception: - messages.error(request, _(u'Error creating source transformation; %s') % exception) + messages.error(request, _('Error creating source transformation; %s') % exception) else: form = SourceTransformationForm_create() @@ -586,5 +593,5 @@ def setup_source_transformation_create(request, source_id): 'form': form, 'source': source, 'navigation_object_name': 'source', - 'title': _(u'Create new transformation for source: %s') % source, + 'title': _('Create new transformation for source: %s') % source, }, context_instance=RequestContext(request)) diff --git a/mayan/apps/sources/widgets.py b/mayan/apps/sources/widgets.py index 454de3867d..96361c7586 100644 --- a/mayan/apps/sources/widgets.py +++ b/mayan/apps/sources/widgets.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf import settings from django.core.urlresolvers import reverse from django.utils.html import strip_tags @@ -17,7 +19,7 @@ def staging_file_thumbnail(staging_file, **kwargs): def staging_file_html_widget(staging_file, click_view=None, page=DEFAULT_PAGE_NUMBER, zoom=DEFAULT_ZOOM_LEVEL, rotation=DEFAULT_ROTATION, gallery_name=None, fancybox_class='fancybox-staging', image_class='lazy-load', title=None, size=THUMBNAIL_SIZE, nolazyload=False): result = [] - alt_text = _(u'Staging file page image') + alt_text = _('Staging file page image') query_dict = { 'page': page, @@ -27,37 +29,37 @@ def staging_file_html_widget(staging_file, click_view=None, page=DEFAULT_PAGE_NU } if gallery_name: - gallery_template = u'rel="%s"' % gallery_name + gallery_template = 'rel="%s"' % gallery_name else: - gallery_template = u'' + gallery_template = '' query_string = urlencode(query_dict) - preview_view = u'%s?%s' % (reverse('stagingfolderfile-image-view', args=[staging_file.staging_folder.pk, staging_file.encoded_filename]), query_string) + preview_view = '%s?%s' % (reverse('stagingfolderfile-image-view', args=[staging_file.staging_folder.pk, staging_file.encoded_filename]), query_string) plain_template = [] - plain_template.append(u'%s' % (preview_view, alt_text)) + plain_template.append('%s' % (preview_view, alt_text)) - result.append(u'
' % (staging_file.filename, page if page else DEFAULT_PAGE_NUMBER)) + result.append('') + result.append('') + result.append('
') - return mark_safe(u''.join(result)) + return mark_safe(''.join(result)) diff --git a/mayan/apps/sources/wizards.py b/mayan/apps/sources/wizards.py index e2d39772c5..033a71c3e6 100644 --- a/mayan/apps/sources/wizards.py +++ b/mayan/apps/sources/wizards.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import messages from django.contrib.formtools.wizard.views import SessionWizardView @@ -31,7 +31,7 @@ class DocumentCreateWizard(ViewPermissionCheckMixin, SessionWizardView): def dispatch(self, request, *args, **kwargs): if InteractiveSource.objects.filter(enabled=True).count() == 0: - messages.error(request, _(u'No interactive document sources have been defined or none have been enabled, create one before proceeding.')) + messages.error(request, _('No interactive document sources have been defined or none have been enabled, create one before proceeding.')) return HttpResponseRedirect(reverse('sources:setup_source_list')) return super(DocumentCreateWizard, self).dispatch(request, *args, **kwargs) @@ -41,8 +41,8 @@ class DocumentCreateWizard(ViewPermissionCheckMixin, SessionWizardView): self.condition_dict = {'1': DocumentCreateWizard._has_metadata_types} self.step_titles = [ - _(u'Step 1 of 2: Select document type'), - _(u'Step 2 of 2: Enter document metadata'), + _('Step 1 of 2: Select document type'), + _('Step 2 of 2: Enter document metadata'), ] def get_form_initial(self, step): @@ -62,7 +62,7 @@ class DocumentCreateWizard(ViewPermissionCheckMixin, SessionWizardView): context = super(DocumentCreateWizard, self).get_context_data(form=form, **kwargs) context.update({ 'step_title': self.step_titles[self.steps.step0], - 'submit_label': _(u'Next step'), + 'submit_label': _('Next step'), 'submit_icon_famfam': 'arrow_right', }) return context diff --git a/mayan/apps/statistics/__init__.py b/mayan/apps/statistics/__init__.py index 785e9eeaa8..3c5c4b086f 100644 --- a/mayan/apps/statistics/__init__.py +++ b/mayan/apps/statistics/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from navigation.api import register_links diff --git a/mayan/apps/statistics/links.py b/mayan/apps/statistics/links.py index e7bbc5203d..d54702026e 100644 --- a/mayan/apps/statistics/links.py +++ b/mayan/apps/statistics/links.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ @@ -7,7 +7,7 @@ def is_superuser(context): return context['request'].user.is_staff or context['request'].user.is_superuser -link_execute = {'text': _(u'Execute'), 'view': 'statistics:execute', 'args': 'object.id', 'famfam': 'lightning', 'condition': is_superuser} -link_namespace_details = {'text': _(u'Details'), 'view': 'statistics:namespace_details', 'args': 'namespace.id', 'famfam': 'chart_curve_go', 'condition': is_superuser} -link_namespace_list = {'text': _(u'Namespace list'), 'view': 'statistics:namespace_list', 'famfam': 'chart_curve', 'condition': is_superuser} -link_statistics = {'text': _(u'Statistics'), 'view': 'statistics:namespace_list', 'famfam': 'table', 'icon': 'blackboard_sum.png', 'condition': is_superuser} +link_execute = {'text': _('Execute'), 'view': 'statistics:execute', 'args': 'object.id', 'famfam': 'lightning', 'condition': is_superuser} +link_namespace_details = {'text': _('Details'), 'view': 'statistics:namespace_details', 'args': 'namespace.id', 'famfam': 'chart_curve_go', 'condition': is_superuser} +link_namespace_list = {'text': _('Namespace list'), 'view': 'statistics:namespace_list', 'famfam': 'chart_curve', 'condition': is_superuser} +link_statistics = {'text': _('Statistics'), 'view': 'statistics:namespace_list', 'famfam': 'table', 'icon': 'blackboard_sum.png', 'condition': is_superuser} diff --git a/mayan/apps/statistics/urls.py b/mayan/apps/statistics/urls.py index 2b9d62a3f4..daabcba2d4 100644 --- a/mayan/apps/statistics/urls.py +++ b/mayan/apps/statistics/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url urlpatterns = patterns('statistics.views', diff --git a/mayan/apps/statistics/views.py b/mayan/apps/statistics/views.py index 014d30af36..9e50d95935 100644 --- a/mayan/apps/statistics/views.py +++ b/mayan/apps/statistics/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import render_to_response @@ -15,7 +15,7 @@ def namespace_list(request): return render_to_response('main/generic_list.html', { 'object_list': StatisticNamespace.get_all(), 'hide_link': True, - 'title': _(u'Statistics namespaces'), + 'title': _('Statistics namespaces'), 'list_object_variable_name': 'namespace', }, context_instance=RequestContext(request)) @@ -31,7 +31,7 @@ def namespace_details(request, namespace_id): 'namespace': namespace, 'object_list': namespace.statistics, 'hide_link': True, - 'title': _(u'Namespace details for: %s') % namespace, + 'title': _('Namespace details for: %s') % namespace, }, context_instance=RequestContext(request)) @@ -45,10 +45,10 @@ def execute(request, statistic_id): 'object': statictic, 'namespace': statictic.namespace, 'navigation_object_list': [ - {'object': 'namespace', 'name': _(u'Namespace')}, - {'object': 'object', 'name': _(u'Statistic')}, + {'object': 'namespace', 'name': _('Namespace')}, + {'object': 'object', 'name': _('Statistic')}, ], 'object_list': statictic.get_results(), 'hide_link': True, - 'title': _(u'Results for: %s') % statictic, + 'title': _('Results for: %s') % statictic, }, context_instance=RequestContext(request)) diff --git a/mayan/apps/storage/backends/compressedstorage.py b/mayan/apps/storage/backends/compressedstorage.py index 52755f428f..59aaad34e6 100644 --- a/mayan/apps/storage/backends/compressedstorage.py +++ b/mayan/apps/storage/backends/compressedstorage.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os import zipfile diff --git a/mayan/apps/storage/backends/filebasedstorage.py b/mayan/apps/storage/backends/filebasedstorage.py index cfa8218efe..7c91396899 100644 --- a/mayan/apps/storage/backends/filebasedstorage.py +++ b/mayan/apps/storage/backends/filebasedstorage.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import os diff --git a/mayan/apps/storage/settings.py b/mayan/apps/storage/settings.py index 40c1ae4779..769a07130f 100644 --- a/mayan/apps/storage/settings.py +++ b/mayan/apps/storage/settings.py @@ -1,4 +1,5 @@ -"""Configuration options for the storage app""" +from __future__ import unicode_literals + import os from django.conf import settings @@ -6,9 +7,9 @@ from django.conf import settings from smart_settings.api import register_settings register_settings( - namespace=u'storage', - module=u'storage.settings', + namespace='storage', + module='storage.settings', settings=[ - {'name': u'FILESTORAGE_LOCATION', 'global_name': u'STORAGE_FILESTORAGE_LOCATION', 'default': os.path.join(settings.MEDIA_ROOT, u'document_storage'), 'exists': True}, + {'name': 'FILESTORAGE_LOCATION', 'global_name': 'STORAGE_FILESTORAGE_LOCATION', 'default': os.path.join(settings.MEDIA_ROOT, 'document_storage'), 'exists': True}, ] ) diff --git a/mayan/apps/tags/__init__.py b/mayan/apps/tags/__init__.py index a0e94ef64b..bb616ca669 100644 --- a/mayan/apps/tags/__init__.py +++ b/mayan/apps/tags/__init__.py @@ -1,24 +1,27 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from acls.api import class_permissions from common.utils import encapsulate from documents.models import Document -from navigation.api import (register_links, register_model_list_columns, - register_top_menu) +from navigation.api import ( + register_links, register_model_list_columns, register_top_menu +) from navigation.links import link_spacer from rest_api.classes import APIEndPoint -from .links import (multiple_documents_selection_tag_remove, - single_document_multiple_tag_remove, tag_acl_list, - tag_attach, tag_create, tag_delete, tag_document_list, - tag_edit, tag_list, tag_multiple_attach, - tag_multiple_delete, tag_tagged_item_list) +from .links import ( + multiple_documents_selection_tag_remove, + single_document_multiple_tag_remove, tag_acl_list, tag_attach, tag_create, + tag_delete, tag_document_list, tag_edit, tag_list, tag_multiple_attach, + tag_multiple_delete, tag_tagged_item_list +) from .models import Tag -from .permissions import (PERMISSION_TAG_ATTACH, PERMISSION_TAG_DELETE, - PERMISSION_TAG_EDIT, PERMISSION_TAG_REMOVE, - PERMISSION_TAG_VIEW) +from .permissions import ( + PERMISSION_TAG_ATTACH, PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT, + PERMISSION_TAG_REMOVE, PERMISSION_TAG_VIEW +) from .widgets import get_tags_inline_widget_simple, single_tag_widget class_permissions(Document, [ @@ -32,23 +35,23 @@ APIEndPoint('tags') register_model_list_columns(Tag, [ { - 'name': _(u'Preview'), + 'name': _('Preview'), 'attribute': encapsulate(lambda x: single_tag_widget(x)) }, { - 'name': _(u'Tagged items'), + 'name': _('Tagged items'), 'attribute': encapsulate(lambda x: x.documents.count()) } ]) register_model_list_columns(Document, [ { - 'name': _(u'Tags'), 'attribute': + 'name': _('Tags'), 'attribute': encapsulate(lambda x: get_tags_inline_widget_simple(x)) }, ]) -register_top_menu('tags', link={'text': _(u'Tags'), 'view': 'tags:tag_list', 'famfam': 'tag_blue'}) +register_top_menu('tags', link={'text': _('Tags'), 'view': 'tags:tag_list', 'famfam': 'tag_blue'}) register_links(Tag, [tag_tagged_item_list, tag_edit, tag_acl_list, tag_delete]) register_links([Tag], [tag_multiple_delete], menu_name='multi_item_links') diff --git a/mayan/apps/tags/admin.py b/mayan/apps/tags/admin.py index 480f4e416d..1fdb041e7f 100644 --- a/mayan/apps/tags/admin.py +++ b/mayan/apps/tags/admin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.contrib import admin from .models import Tag diff --git a/mayan/apps/tags/api_views.py b/mayan/apps/tags/api_views.py index 397e64ddc3..5df7289d27 100644 --- a/mayan/apps/tags/api_views.py +++ b/mayan/apps/tags/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 diff --git a/mayan/apps/tags/forms.py b/mayan/apps/tags/forms.py index 9c05e12259..4555acf614 100644 --- a/mayan/apps/tags/forms.py +++ b/mayan/apps/tags/forms.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging @@ -39,4 +39,4 @@ class TagListForm(forms.Form): self.fields['tag'] = forms.ModelChoiceField( queryset=queryset, - label=_(u'Tags')) + label=_('Tags')) diff --git a/mayan/apps/tags/links.py b/mayan/apps/tags/links.py index 34257886c2..b9a266ac6c 100644 --- a/mayan/apps/tags/links.py +++ b/mayan/apps/tags/links.py @@ -1,25 +1,26 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from acls.permissions import ACLS_VIEW_ACL -from .permissions import (PERMISSION_TAG_ATTACH, PERMISSION_TAG_CREATE, - PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT, - PERMISSION_TAG_REMOVE) +from .permissions import ( + PERMISSION_TAG_ATTACH, PERMISSION_TAG_CREATE, PERMISSION_TAG_DELETE, + PERMISSION_TAG_EDIT, PERMISSION_TAG_REMOVE +) -tag_list = {'text': _(u'Tags'), 'view': 'tags:tag_list', 'famfam': 'tag_blue'} -tag_create = {'text': _(u'Create new tag'), 'view': 'tags:tag_create', 'famfam': 'tag_blue_add', 'permissions': [PERMISSION_TAG_CREATE]} +tag_list = {'text': _('Tags'), 'view': 'tags:tag_list', 'famfam': 'tag_blue'} +tag_create = {'text': _('Create new tag'), 'view': 'tags:tag_create', 'famfam': 'tag_blue_add', 'permissions': [PERMISSION_TAG_CREATE]} -tag_attach = {'text': _(u'Attach tag'), 'view': 'tags:tag_attach', 'args': 'object.pk', 'famfam': 'tag_blue_add', 'permissions': [PERMISSION_TAG_ATTACH]} -tag_multiple_attach = {'text': _(u'Attach tag'), 'view': 'tags:tag_multiple_attach', 'famfam': 'tag_blue_add'} +tag_attach = {'text': _('Attach tag'), 'view': 'tags:tag_attach', 'args': 'object.pk', 'famfam': 'tag_blue_add', 'permissions': [PERMISSION_TAG_ATTACH]} +tag_multiple_attach = {'text': _('Attach tag'), 'view': 'tags:tag_multiple_attach', 'famfam': 'tag_blue_add'} -multiple_documents_selection_tag_remove = {'text': _(u'Remove tag'), 'view': 'tags:multiple_documents_selection_tag_remove', 'famfam': 'tag_blue_delete'} -single_document_multiple_tag_remove = {'text': _(u'Remove tags'), 'view': 'tags:single_document_multiple_tag_remove', 'args': 'document.id', 'famfam': 'tag_blue_delete', 'permissions': [PERMISSION_TAG_REMOVE]} +multiple_documents_selection_tag_remove = {'text': _('Remove tag'), 'view': 'tags:multiple_documents_selection_tag_remove', 'famfam': 'tag_blue_delete'} +single_document_multiple_tag_remove = {'text': _('Remove tags'), 'view': 'tags:single_document_multiple_tag_remove', 'args': 'document.id', 'famfam': 'tag_blue_delete', 'permissions': [PERMISSION_TAG_REMOVE]} -tag_document_list = {'text': _(u'Tags'), 'view': 'tags:document_tags', 'args': 'object.pk', 'famfam': 'tag_blue', 'permissions': [PERMISSION_TAG_REMOVE, PERMISSION_TAG_ATTACH]} -tag_delete = {'text': _(u'Delete'), 'view': 'tags:tag_delete', 'args': 'object.id', 'famfam': 'tag_blue_delete', 'permissions': [PERMISSION_TAG_DELETE]} -tag_edit = {'text': _(u'Edit'), 'view': 'tags:tag_edit', 'args': 'object.id', 'famfam': 'tag_blue_edit', 'permissions': [PERMISSION_TAG_EDIT]} -tag_tagged_item_list = {'text': _(u'Documents'), 'view': 'tags:tag_tagged_item_list', 'args': 'object.id', 'famfam': 'page'} -tag_multiple_delete = {'text': _(u'Delete'), 'view': 'tags:tag_multiple_delete', 'famfam': 'tag_blue_delete', 'permissions': [PERMISSION_TAG_DELETE]} -tag_acl_list = {'text': _(u'ACLs'), 'view': 'tags:tag_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} +tag_document_list = {'text': _('Tags'), 'view': 'tags:document_tags', 'args': 'object.pk', 'famfam': 'tag_blue', 'permissions': [PERMISSION_TAG_REMOVE, PERMISSION_TAG_ATTACH]} +tag_delete = {'text': _('Delete'), 'view': 'tags:tag_delete', 'args': 'object.id', 'famfam': 'tag_blue_delete', 'permissions': [PERMISSION_TAG_DELETE]} +tag_edit = {'text': _('Edit'), 'view': 'tags:tag_edit', 'args': 'object.id', 'famfam': 'tag_blue_edit', 'permissions': [PERMISSION_TAG_EDIT]} +tag_tagged_item_list = {'text': _('Documents'), 'view': 'tags:tag_tagged_item_list', 'args': 'object.id', 'famfam': 'page'} +tag_multiple_delete = {'text': _('Delete'), 'view': 'tags:tag_multiple_delete', 'famfam': 'tag_blue_delete', 'permissions': [PERMISSION_TAG_DELETE]} +tag_acl_list = {'text': _('ACLs'), 'view': 'tags:tag_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} diff --git a/mayan/apps/tags/literals.py b/mayan/apps/tags/literals.py index 9ae0cfe8f3..d7b0996cc3 100644 --- a/mayan/apps/tags/literals.py +++ b/mayan/apps/tags/literals.py @@ -1,40 +1,40 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ -COLOR_RED = u'red' -COLOR_BLUE = u'blu' -COLOR_MAGENTA = u'mag' -COLOR_CYAN = u'cya' -COLOR_YELLOW = u'yel' -COLOR_GREENYELLOW = u'gry' -COLOR_CORAL = u'crl' -COLOR_KHAKI = u'kki' -COLOR_LIGHTGREY = u'lig' -COLOR_ORANGE = u'org' +COLOR_RED = 'red' +COLOR_BLUE = 'blu' +COLOR_MAGENTA = 'mag' +COLOR_CYAN = 'cya' +COLOR_YELLOW = 'yel' +COLOR_GREENYELLOW = 'gry' +COLOR_CORAL = 'crl' +COLOR_KHAKI = 'kki' +COLOR_LIGHTGREY = 'lig' +COLOR_ORANGE = 'org' COLOR_CHOICES = ( - (COLOR_BLUE, _(u'Blue')), - (COLOR_CYAN, _(u'Cyan')), - (COLOR_CORAL, _(u'Coral')), - (COLOR_GREENYELLOW, _(u'Green-Yellow')), - (COLOR_KHAKI, _(u'Khaki')), - (COLOR_LIGHTGREY, _(u'LightGrey')), - (COLOR_MAGENTA, _(u'Magenta')), - (COLOR_RED, _(u'Red')), - (COLOR_ORANGE, _(u'Orange')), - (COLOR_YELLOW, _(u'Yellow')) + (COLOR_BLUE, _('Blue')), + (COLOR_CYAN, _('Cyan')), + (COLOR_CORAL, _('Coral')), + (COLOR_GREENYELLOW, _('Green-Yellow')), + (COLOR_KHAKI, _('Khaki')), + (COLOR_LIGHTGREY, _('LightGrey')), + (COLOR_MAGENTA, _('Magenta')), + (COLOR_RED, _('Red')), + (COLOR_ORANGE, _('Orange')), + (COLOR_YELLOW, _('Yellow')) ) COLOR_CODES = ( - (COLOR_RED, u'red'), - (COLOR_BLUE, u'blue'), - (COLOR_MAGENTA, u'magenta'), - (COLOR_CYAN, u'cyan'), - (COLOR_YELLOW, u'yellow'), - (COLOR_GREENYELLOW, u'greenyellow '), - (COLOR_CORAL, u'coral'), - (COLOR_KHAKI, u'khaki'), - (COLOR_ORANGE, u'orange'), - (COLOR_LIGHTGREY, u'lightgrey'), + (COLOR_RED, 'red'), + (COLOR_BLUE, 'blue'), + (COLOR_MAGENTA, 'magenta'), + (COLOR_CYAN, 'cyan'), + (COLOR_YELLOW, 'yellow'), + (COLOR_GREENYELLOW, 'greenyellow '), + (COLOR_CORAL, 'coral'), + (COLOR_KHAKI, 'khaki'), + (COLOR_ORANGE, 'orange'), + (COLOR_LIGHTGREY, 'lightgrey'), ) diff --git a/mayan/apps/tags/models.py b/mayan/apps/tags/models.py index 3652bdda2b..5049fed5be 100644 --- a/mayan/apps/tags/models.py +++ b/mayan/apps/tags/models.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -9,13 +9,13 @@ from .literals import COLOR_CHOICES, COLOR_CODES class Tag(models.Model): - label = models.CharField(max_length=128, verbose_name=_(u'Label'), unique=True, db_index=True) - color = models.CharField(max_length=3, choices=COLOR_CHOICES, verbose_name=_(u'Color')) + 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')) documents = models.ManyToManyField(Document, related_name='tags', verbose_name=_('Documents')) class Meta: - verbose_name = _(u'Tag') - verbose_name_plural = _(u'Tags') + verbose_name = _('Tag') + verbose_name_plural = _('Tags') def __unicode__(self): return self.label diff --git a/mayan/apps/tags/permissions.py b/mayan/apps/tags/permissions.py index cb4c7f9ae7..49b800b450 100644 --- a/mayan/apps/tags/permissions.py +++ b/mayan/apps/tags/permissions.py @@ -1,14 +1,14 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -tags_namespace = PermissionNamespace('tags', _(u'Tags')) +tags_namespace = PermissionNamespace('tags', _('Tags')) -PERMISSION_TAG_CREATE = Permission.objects.register(tags_namespace, 'tag_create', _(u'Create new tags')) -PERMISSION_TAG_DELETE = Permission.objects.register(tags_namespace, 'tag_delete', _(u'Delete tags')) -PERMISSION_TAG_EDIT = Permission.objects.register(tags_namespace, 'tag_edit', _(u'Edit tags')) -PERMISSION_TAG_VIEW = Permission.objects.register(tags_namespace, 'tag_view', _(u'View tags')) -PERMISSION_TAG_ATTACH = Permission.objects.register(tags_namespace, 'tag_attach', _(u'Attach tags to documents')) -PERMISSION_TAG_REMOVE = Permission.objects.register(tags_namespace, 'tag_remove', _(u'Remove tags from documents')) +PERMISSION_TAG_CREATE = Permission.objects.register(tags_namespace, 'tag_create', _('Create new tags')) +PERMISSION_TAG_DELETE = Permission.objects.register(tags_namespace, 'tag_delete', _('Delete tags')) +PERMISSION_TAG_EDIT = Permission.objects.register(tags_namespace, 'tag_edit', _('Edit tags')) +PERMISSION_TAG_VIEW = Permission.objects.register(tags_namespace, 'tag_view', _('View tags')) +PERMISSION_TAG_ATTACH = Permission.objects.register(tags_namespace, 'tag_attach', _('Attach tags to documents')) +PERMISSION_TAG_REMOVE = Permission.objects.register(tags_namespace, 'tag_remove', _('Remove tags from documents')) diff --git a/mayan/apps/tags/serializers.py b/mayan/apps/tags/serializers.py index b0130b9287..1f992c962c 100644 --- a/mayan/apps/tags/serializers.py +++ b/mayan/apps/tags/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from rest_framework import serializers diff --git a/mayan/apps/tags/tests.py b/mayan/apps/tags/tests.py index 15e7cad474..90e93ca451 100644 --- a/mayan/apps/tags/tests.py +++ b/mayan/apps/tags/tests.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import os from django.conf import settings diff --git a/mayan/apps/tags/urls.py b/mayan/apps/tags/urls.py index dc42380f07..753bb5a240 100644 --- a/mayan/apps/tags/urls.py +++ b/mayan/apps/tags/urls.py @@ -1,9 +1,11 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.conf.urls import patterns, url -from .api_views import (APIDocumentTagView, APIDocumentTagListView, - APITagDocumentListView, APITagListView, APITagView) +from .api_views import ( + APIDocumentTagView, APIDocumentTagListView, APITagDocumentListView, + APITagListView, APITagView +) from .views import TagTaggedItemListView urlpatterns = patterns('tags.views', diff --git a/mayan/apps/tags/views.py b/mayan/apps/tags/views.py index ee43a4567d..c66282eee0 100644 --- a/mayan/apps/tags/views.py +++ b/mayan/apps/tags/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging @@ -21,9 +21,10 @@ from permissions.models import Permission from .forms import TagForm, TagListForm from .models import Tag -from .permissions import (PERMISSION_TAG_ATTACH, PERMISSION_TAG_CREATE, - PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT, - PERMISSION_TAG_REMOVE, PERMISSION_TAG_VIEW) +from .permissions import ( + PERMISSION_TAG_ATTACH, PERMISSION_TAG_CREATE, PERMISSION_TAG_DELETE, + PERMISSION_TAG_EDIT, PERMISSION_TAG_REMOVE, PERMISSION_TAG_VIEW +) logger = logging.getLogger(__name__) @@ -39,13 +40,13 @@ def tag_create(request): tag = form.save() apply_default_acls(tag, request.user) - messages.success(request, _(u'Tag created succesfully.')) + messages.success(request, _('Tag created succesfully.')) return HttpResponseRedirect(redirect_url) else: form = TagForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Create tag'), + 'title': _('Create tag'), 'form': form, }, context_instance=RequestContext(request)) @@ -57,7 +58,7 @@ def tag_attach(request, document_id=None, document_id_list=None): elif document_id_list: documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one document.')) + messages.error(request, _('Must provide at least one document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) try: @@ -75,12 +76,12 @@ def tag_attach(request, document_id=None, document_id_list=None): tag = form.cleaned_data['tag'] for document in documents: if tag in document.tags.all(): - messages.warning(request, _(u'Document "%(document)s" is already tagged as "%(tag)s"') % { + messages.warning(request, _('Document "%(document)s" is already tagged as "%(tag)s"') % { 'document': document, 'tag': tag} ) else: tag.documents.add(document) - messages.success(request, _(u'Tag "%(tag)s" attached successfully to document "%(document)s".') % { + messages.success(request, _('Tag "%(tag)s" attached successfully to document "%(document)s".') % { 'document': document, 'tag': tag} ) return HttpResponseRedirect(next) @@ -92,8 +93,8 @@ def tag_attach(request, document_id=None, document_id_list=None): 'previous': previous, 'next': next, 'title': ungettext( - u'Attach tag to document', - u'Attach tag to documents', + 'Attach tag to document', + 'Attach tag to documents', len(documents) ) } @@ -113,7 +114,7 @@ def tag_multiple_attach(request): def tag_list(request, queryset=None, extra_context=None): context = { - 'title': _(u'Tags'), + 'title': _('Tags'), 'hide_link': True, 'hide_object': True, } @@ -142,7 +143,7 @@ def tag_delete(request, tag_id=None, tag_id_list=None): elif tag_id_list: tags = [get_object_or_404(Tag, pk=tag_id) for tag_id in tag_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one tag.')) + messages.error(request, _('Must provide at least one tag.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) try: @@ -157,9 +158,9 @@ def tag_delete(request, tag_id=None, tag_id_list=None): for tag in tags: try: tag.delete() - messages.success(request, _(u'Tag "%s" deleted successfully.') % tag) + messages.success(request, _('Tag "%s" deleted successfully.') % tag) except Exception as exception: - messages.error(request, _(u'Error deleting tag "%(tag)s": %(error)s') % { + messages.error(request, _('Error deleting tag "%(tag)s": %(error)s') % { 'tag': tag, 'error': exception }) @@ -172,10 +173,10 @@ def tag_delete(request, tag_id=None, tag_id_list=None): } if len(tags) == 1: context['object'] = tags[0] - context['title'] = _(u'Are you sure you wish to delete the tag: %s?') % ', '.join([unicode(d) for d in tags]) + context['title'] = _('Are you sure you wish to delete the tag: %s?') % ', '.join([unicode(d) for d in tags]) context['message'] = _('Will be removed from all documents.') elif len(tags) > 1: - context['title'] = _(u'Are you sure you wish to delete the tags: %s?') % ', '.join([unicode(d) for d in tags]) + context['title'] = _('Are you sure you wish to delete the tags: %s?') % ', '.join([unicode(d) for d in tags]) context['message'] = _('Will be removed from all documents.') return render_to_response('main/generic_confirm.html', context, @@ -200,13 +201,13 @@ def tag_edit(request, tag_id): form = TagForm(data=request.POST, instance=tag) if form.is_valid(): form.save() - messages.success(request, _(u'Tag updated succesfully.')) + messages.success(request, _('Tag updated succesfully.')) return HttpResponseRedirect(reverse('tags:tag_list')) else: form = TagForm(instance=tag) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit tag: %s') % tag, + 'title': _('Edit tag: %s') % tag, 'form': form, 'object': tag, }, context_instance=RequestContext(request)) @@ -221,7 +222,7 @@ class TagTaggedItemListView(DocumentListView): def get_extra_context(self): return { - 'title': _(u'Documents with the tag "%s"') % self.get_tag(), + 'title': _('Documents with the tag "%s"') % self.get_tag(), 'hide_links': True, 'object': self.get_tag(), } @@ -238,7 +239,7 @@ def document_tags(request, document_id): context = { 'object': document, 'document': document, - 'title': _(u'Document tags'), + 'title': _('Document tags'), } return tag_list(request, queryset=document.tags.all(), extra_context=context) @@ -250,7 +251,7 @@ def tag_remove(request, document_id=None, document_id_list=None, tag_id=None, ta elif document_id_list: documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one tagged document.')) + messages.error(request, _('Must provide at least one tagged document.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) try: @@ -288,38 +289,38 @@ def tag_remove(request, document_id=None, document_id_list=None, tag_id=None, ta context['form'] = form if len(documents) == 1: context['object'] = documents[0] - context['title'] = _(u'Remove tag from document: %s.') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Remove tag from document: %s.') % ', '.join([unicode(d) for d in documents]) elif len(documents) > 1: - context['title'] = _(u'Remove tag from documents: %s.') % ', '.join([unicode(d) for d in documents]) + context['title'] = _('Remove tag from documents: %s.') % ', '.join([unicode(d) for d in documents]) if tags: if len(tags) == 1: if len(documents) == 1: context['object'] = documents[0] - context['title'] = _(u'Are you sure you wish to remove the tag "%(tag)s" from the document: %(document)s?') % { + context['title'] = _('Are you sure you wish to remove the tag "%(tag)s" from the document: %(document)s?') % { 'tag': ', '.join([unicode(d) for d in tags]), 'document': ', '.join([unicode(d) for d in documents])} else: - context['title'] = _(u'Are you sure you wish to remove the tag "%(tag)s" from the documents: %(documents)s?') % { + context['title'] = _('Are you sure you wish to remove the tag "%(tag)s" from the documents: %(documents)s?') % { 'tag': ', '.join([unicode(d) for d in tags]), 'documents': ', '.join([unicode(d) for d in documents])} elif len(tags) > 1: if len(documents) == 1: context['object'] = documents[0] - context['title'] = _(u'Are you sure you wish to remove the tags: %(tags)s from the document: %(document)s?') % { + context['title'] = _('Are you sure you wish to remove the tags: %(tags)s from the document: %(document)s?') % { 'tags': ', '.join([unicode(d) for d in tags]), 'document': ', '.join([unicode(d) for d in documents])} else: - context['title'] = _(u'Are you sure you wish to remove the tags %(tags)s from the documents: %(documents)s?') % { + context['title'] = _('Are you sure you wish to remove the tags %(tags)s from the documents: %(documents)s?') % { 'tags': ', '.join([unicode(d) for d in tags]), 'documents': ', '.join([unicode(d) for d in documents])} if request.method == 'POST': for document in documents: for tag in tags: if tag not in document.tags.all(): - messages.warning(request, _(u'Document "%(document)s" wasn\'t tagged as "%(tag)s"') % { + messages.warning(request, _('Document "%(document)s" wasn\'t tagged as "%(tag)s"') % { 'document': document, 'tag': tag} ) else: tag.documents.remove(document) - messages.success(request, _(u'Tag "%(tag)s" removed successfully from document "%(document)s".') % { + messages.success(request, _('Tag "%(tag)s" removed successfully from document "%(document)s".') % { 'document': document, 'tag': tag} ) diff --git a/mayan/apps/tags/widgets.py b/mayan/apps/tags/widgets.py index d1c8d8c24f..f4d84ce61a 100644 --- a/mayan/apps/tags/widgets.py +++ b/mayan/apps/tags/widgets.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.utils.html import escape from django.utils.safestring import mark_safe @@ -10,14 +12,14 @@ def get_tags_inline_widget(document): tags_template = [] tag_count = document.tags.count() if tag_count: - tags_template.append(u'
') + tags_template.append('
') for tag in document.tags.all(): - tags_template.append(u'
  • %s
' % (tag.get_color_code(), escape(tag.label))) + tags_template.append('
  • %s
' % (tag.get_color_code(), escape(tag.label))) - tags_template.append(u'
') - tags_template.append(u'
') - return mark_safe(u''.join(tags_template)) + tags_template.append('
') + tags_template.append('
') + return mark_safe(''.join(tags_template)) def get_tags_inline_widget_simple(document): @@ -34,7 +36,7 @@ def get_tags_inline_widget_simple(document): tags_template.append('') - return mark_safe(u''.join(tags_template)) + return mark_safe(''.join(tags_template)) def single_tag_widget(tag): @@ -42,8 +44,8 @@ def single_tag_widget(tag): tags_template.append('
    ') tags_template.append(get_single_tag_template(tag)) tags_template.append('
') - return mark_safe(u''.join(tags_template)) + return mark_safe(''.join(tags_template)) def get_single_tag_template(tag): - return '
  • %s
  • ' % (tag.get_color_code(), escape(tag.label).replace(u' ', u' ')) + return '
  • %s
  • ' % (tag.get_color_code(), escape(tag.label).replace(' ', ' ')) diff --git a/mayan/apps/user_management/__init__.py b/mayan/apps/user_management/__init__.py index 217a038ebf..9edeceeff7 100644 --- a/mayan/apps/user_management/__init__.py +++ b/mayan/apps/user_management/__init__.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.auth.models import User, Group @@ -8,18 +8,19 @@ from navigation.links import link_spacer from project_setup.api import register_setup from rest_api.classes import APIEndPoint -from .links import (group_add, group_delete, group_edit, group_list, - group_members, group_multiple_delete, group_setup, - user_add, user_delete, user_edit, user_groups, user_list, - user_multiple_delete, user_multiple_set_password, - user_set_password, user_setup) +from .links import ( + group_add, group_delete, group_edit, group_list, group_members, + group_multiple_delete, group_setup, user_add, user_delete, user_edit, + user_groups, user_list, user_multiple_delete, user_multiple_set_password, + user_set_password, user_setup +) register_links(User, [user_edit, user_set_password, user_groups, user_delete]) -register_links([User, 'user_management:user_multiple_set_password', 'user_management:user_multiple_delete', 'user_management:user_list', 'user_management:user_add'], [user_list, user_add], menu_name=u'secondary_menu') +register_links([User, 'user_management:user_multiple_set_password', 'user_management:user_multiple_delete', 'user_management:user_list', 'user_management:user_add'], [user_list, user_add], menu_name='secondary_menu') register_links(['user_management:user_list'], [user_multiple_set_password, user_multiple_delete], menu_name='multi_item_links') register_links(Group, [group_edit, group_members, group_delete]) -register_links(['user_management:group_multiple_delete', 'user_management:group_delete', 'user_management:group_edit', 'user_management:group_list', 'user_management:group_add', 'user_management:group_members'], [group_list, group_add], menu_name=u'secondary_menu') +register_links(['user_management:group_multiple_delete', 'user_management:group_delete', 'user_management:group_edit', 'user_management:group_list', 'user_management:group_add', 'user_management:group_members'], [group_list, group_add], menu_name='secondary_menu') register_links(['user_management:group_list'], [group_multiple_delete], menu_name='multi_item_links') register_setup(user_setup) diff --git a/mayan/apps/user_management/api_views.py b/mayan/apps/user_management/api_views.py index 780551e684..685ea86387 100644 --- a/mayan/apps/user_management/api_views.py +++ b/mayan/apps/user_management/api_views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.auth.models import Group, User @@ -7,10 +7,11 @@ from rest_framework import generics from rest_api.filters import MayanObjectPermissionsFilter from rest_api.permissions import MayanPermission -from .permissions import (PERMISSION_GROUP_CREATE, PERMISSION_GROUP_DELETE, - PERMISSION_GROUP_EDIT, PERMISSION_GROUP_VIEW, - PERMISSION_USER_CREATE, PERMISSION_USER_DELETE, - PERMISSION_USER_EDIT, PERMISSION_USER_VIEW) +from .permissions import ( + PERMISSION_GROUP_CREATE, PERMISSION_GROUP_DELETE, PERMISSION_GROUP_EDIT, + PERMISSION_GROUP_VIEW, PERMISSION_USER_CREATE, PERMISSION_USER_DELETE, + PERMISSION_USER_EDIT, PERMISSION_USER_VIEW +) from .serializers import GroupSerializer, UserSerializer diff --git a/mayan/apps/user_management/forms.py b/mayan/apps/user_management/forms.py index a5bb1cd60b..5acc25db87 100644 --- a/mayan/apps/user_management/forms.py +++ b/mayan/apps/user_management/forms.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django import forms from django.contrib.auth.models import User, Group from django.utils.translation import ugettext_lazy as _ @@ -10,8 +12,8 @@ class UserForm(forms.ModelForm): class PasswordForm(forms.Form): - new_password_1 = forms.CharField(label=_(u'New password'), widget=forms.PasswordInput()) - new_password_2 = forms.CharField(label=_(u'Confirm password'), widget=forms.PasswordInput()) + new_password_1 = forms.CharField(label=_('New password'), widget=forms.PasswordInput()) + new_password_2 = forms.CharField(label=_('Confirm password'), widget=forms.PasswordInput()) class GroupForm(forms.ModelForm): diff --git a/mayan/apps/user_management/links.py b/mayan/apps/user_management/links.py index 5316d00fe3..bbd1d8f241 100644 --- a/mayan/apps/user_management/links.py +++ b/mayan/apps/user_management/links.py @@ -1,26 +1,27 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ -from .permissions import (PERMISSION_GROUP_CREATE, PERMISSION_GROUP_DELETE, - PERMISSION_GROUP_EDIT, PERMISSION_GROUP_VIEW, - PERMISSION_USER_CREATE, PERMISSION_USER_DELETE, - PERMISSION_USER_EDIT, PERMISSION_USER_VIEW) +from .permissions import ( + PERMISSION_GROUP_CREATE, PERMISSION_GROUP_DELETE, PERMISSION_GROUP_EDIT, + PERMISSION_GROUP_VIEW, PERMISSION_USER_CREATE, PERMISSION_USER_DELETE, + PERMISSION_USER_EDIT, PERMISSION_USER_VIEW +) -user_list = {'text': _(u'Users'), 'view': 'user_management:user_list', 'famfam': 'user', 'permissions': [PERMISSION_USER_VIEW]} -user_setup = {'text': _(u'Users'), 'view': 'user_management:user_list', 'famfam': 'user', 'icon': 'user.png', 'permissions': [PERMISSION_USER_VIEW]} -user_edit = {'text': _(u'Edit'), 'view': 'user_management:user_edit', 'args': 'object.id', 'famfam': 'user_edit', 'permissions': [PERMISSION_USER_EDIT]} -user_add = {'text': _(u'Create new user'), 'view': 'user_management:user_add', 'famfam': 'user_add', 'permissions': [PERMISSION_USER_CREATE]} -user_delete = {u'text': _('Delete'), 'view': 'user_management:user_delete', 'args': 'object.id', 'famfam': 'user_delete', 'permissions': [PERMISSION_USER_DELETE]} -user_multiple_delete = {u'text': _('Delete'), 'view': 'user_management:user_multiple_delete', 'famfam': 'user_delete', 'permissions': [PERMISSION_USER_DELETE]} -user_set_password = {u'text': _('Reset password'), 'view': 'user_management:user_set_password', 'args': 'object.id', 'famfam': 'lock_edit', 'permissions': [PERMISSION_USER_EDIT]} -user_multiple_set_password = {u'text': _('Reset password'), 'view': 'user_management:user_multiple_set_password', 'famfam': 'lock_edit', 'permissions': [PERMISSION_USER_EDIT]} -user_groups = {'text': _(u'Groups'), 'view': 'user_management:user_groups', 'args': 'object.id', 'famfam': 'group_link', 'permissions': [PERMISSION_USER_EDIT]} +user_list = {'text': _('Users'), 'view': 'user_management:user_list', 'famfam': 'user', 'permissions': [PERMISSION_USER_VIEW]} +user_setup = {'text': _('Users'), 'view': 'user_management:user_list', 'famfam': 'user', 'icon': 'user.png', 'permissions': [PERMISSION_USER_VIEW]} +user_edit = {'text': _('Edit'), 'view': 'user_management:user_edit', 'args': 'object.id', 'famfam': 'user_edit', 'permissions': [PERMISSION_USER_EDIT]} +user_add = {'text': _('Create new user'), 'view': 'user_management:user_add', 'famfam': 'user_add', 'permissions': [PERMISSION_USER_CREATE]} +user_delete = {'text': _('Delete'), 'view': 'user_management:user_delete', 'args': 'object.id', 'famfam': 'user_delete', 'permissions': [PERMISSION_USER_DELETE]} +user_multiple_delete = {'text': _('Delete'), 'view': 'user_management:user_multiple_delete', 'famfam': 'user_delete', 'permissions': [PERMISSION_USER_DELETE]} +user_set_password = {'text': _('Reset password'), 'view': 'user_management:user_set_password', 'args': 'object.id', 'famfam': 'lock_edit', 'permissions': [PERMISSION_USER_EDIT]} +user_multiple_set_password = {'text': _('Reset password'), 'view': 'user_management:user_multiple_set_password', 'famfam': 'lock_edit', 'permissions': [PERMISSION_USER_EDIT]} +user_groups = {'text': _('Groups'), 'view': 'user_management:user_groups', 'args': 'object.id', 'famfam': 'group_link', 'permissions': [PERMISSION_USER_EDIT]} -group_list = {'text': _(u'Groups'), 'view': 'user_management:group_list', 'famfam': 'group', 'permissions': [PERMISSION_GROUP_VIEW]} -group_setup = {'text': _(u'Groups'), 'view': 'user_management:group_list', 'famfam': 'group', 'icon': 'group.png', 'permissions': [PERMISSION_GROUP_VIEW]} -group_edit = {'text': _(u'Edit'), 'view': 'user_management:group_edit', 'args': 'object.id', 'famfam': 'group_edit', 'permissions': [PERMISSION_GROUP_EDIT]} -group_add = {'text': _(u'Create new group'), 'view': 'user_management:group_add', 'famfam': 'group_add', 'permissions': [PERMISSION_GROUP_CREATE]} -group_delete = {u'text': _('Delete'), 'view': 'user_management:group_delete', 'args': 'object.id', 'famfam': 'group_delete', 'permissions': [PERMISSION_GROUP_DELETE]} -group_multiple_delete = {u'text': _('Delete'), 'view': 'user_management:group_multiple_delete', 'famfam': 'group_delete', 'permissions': [PERMISSION_GROUP_DELETE]} -group_members = {'text': _(u'Members'), 'view': 'user_management:group_members', 'args': 'object.id', 'famfam': 'group_link', 'permissions': [PERMISSION_GROUP_EDIT]} +group_list = {'text': _('Groups'), 'view': 'user_management:group_list', 'famfam': 'group', 'permissions': [PERMISSION_GROUP_VIEW]} +group_setup = {'text': _('Groups'), 'view': 'user_management:group_list', 'famfam': 'group', 'icon': 'group.png', 'permissions': [PERMISSION_GROUP_VIEW]} +group_edit = {'text': _('Edit'), 'view': 'user_management:group_edit', 'args': 'object.id', 'famfam': 'group_edit', 'permissions': [PERMISSION_GROUP_EDIT]} +group_add = {'text': _('Create new group'), 'view': 'user_management:group_add', 'famfam': 'group_add', 'permissions': [PERMISSION_GROUP_CREATE]} +group_delete = {'text': _('Delete'), 'view': 'user_management:group_delete', 'args': 'object.id', 'famfam': 'group_delete', 'permissions': [PERMISSION_GROUP_DELETE]} +group_multiple_delete = {'text': _('Delete'), 'view': 'user_management:group_multiple_delete', 'famfam': 'group_delete', 'permissions': [PERMISSION_GROUP_DELETE]} +group_members = {'text': _('Members'), 'view': 'user_management:group_members', 'args': 'object.id', 'famfam': 'group_link', 'permissions': [PERMISSION_GROUP_EDIT]} diff --git a/mayan/apps/user_management/permissions.py b/mayan/apps/user_management/permissions.py index e644b1cb5e..af7245e58e 100644 --- a/mayan/apps/user_management/permissions.py +++ b/mayan/apps/user_management/permissions.py @@ -1,17 +1,17 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions.models import PermissionNamespace, Permission -user_management_namespace = PermissionNamespace('user_management', _(u'User management')) +user_management_namespace = PermissionNamespace('user_management', _('User management')) -PERMISSION_USER_CREATE = Permission.objects.register(user_management_namespace, 'user_create', _(u'Create new users')) -PERMISSION_USER_EDIT = Permission.objects.register(user_management_namespace, 'user_edit', _(u'Edit existing users')) -PERMISSION_USER_VIEW = Permission.objects.register(user_management_namespace, 'user_view', _(u'View existing users')) -PERMISSION_USER_DELETE = Permission.objects.register(user_management_namespace, 'user_delete', _(u'Delete existing users')) +PERMISSION_USER_CREATE = Permission.objects.register(user_management_namespace, 'user_create', _('Create new users')) +PERMISSION_USER_EDIT = Permission.objects.register(user_management_namespace, 'user_edit', _('Edit existing users')) +PERMISSION_USER_VIEW = Permission.objects.register(user_management_namespace, 'user_view', _('View existing users')) +PERMISSION_USER_DELETE = Permission.objects.register(user_management_namespace, 'user_delete', _('Delete existing users')) -PERMISSION_GROUP_CREATE = Permission.objects.register(user_management_namespace, 'group_create', _(u'Create new groups')) -PERMISSION_GROUP_EDIT = Permission.objects.register(user_management_namespace, 'group_edit', _(u'Edit existing groups')) -PERMISSION_GROUP_VIEW = Permission.objects.register(user_management_namespace, 'group_view', _(u'View existing groups')) -PERMISSION_GROUP_DELETE = Permission.objects.register(user_management_namespace, 'group_delete', _(u'Delete existing groups')) +PERMISSION_GROUP_CREATE = Permission.objects.register(user_management_namespace, 'group_create', _('Create new groups')) +PERMISSION_GROUP_EDIT = Permission.objects.register(user_management_namespace, 'group_edit', _('Edit existing groups')) +PERMISSION_GROUP_VIEW = Permission.objects.register(user_management_namespace, 'group_view', _('View existing groups')) +PERMISSION_GROUP_DELETE = Permission.objects.register(user_management_namespace, 'group_delete', _('Delete existing groups')) diff --git a/mayan/apps/user_management/serializers.py b/mayan/apps/user_management/serializers.py index 6bd9ef5501..ba3b7565b7 100644 --- a/mayan/apps/user_management/serializers.py +++ b/mayan/apps/user_management/serializers.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.auth.models import Group, User diff --git a/mayan/apps/user_management/urls.py b/mayan/apps/user_management/urls.py index 73f0d1bb12..946e9fe6dd 100644 --- a/mayan/apps/user_management/urls.py +++ b/mayan/apps/user_management/urls.py @@ -1,7 +1,11 @@ +from __future__ import unicode_literals + from django.conf.urls import patterns, url -from .api_views import (APICurrentUserView, APIGroupListView, APIGroupView, - APIUserListView, APIUserView) +from .api_views import ( + APICurrentUserView, APIGroupListView, APIGroupView, APIUserListView, + APIUserView +) urlpatterns = patterns('user_management.views', url(r'^user/list/$', 'user_list', (), 'user_list'), diff --git a/mayan/apps/user_management/views.py b/mayan/apps/user_management/views.py index ad91ea6c3f..ce5e106546 100644 --- a/mayan/apps/user_management/views.py +++ b/mayan/apps/user_management/views.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from django.conf import settings from django.contrib import messages @@ -16,10 +16,11 @@ from common.widgets import two_state_template from permissions.models import Permission from .forms import GroupForm, PasswordForm, UserForm -from .permissions import (PERMISSION_GROUP_CREATE, PERMISSION_GROUP_DELETE, - PERMISSION_GROUP_EDIT, PERMISSION_GROUP_VIEW, - PERMISSION_USER_CREATE, PERMISSION_USER_DELETE, - PERMISSION_USER_EDIT, PERMISSION_USER_VIEW) +from .permissions import ( + PERMISSION_GROUP_CREATE, PERMISSION_GROUP_DELETE, PERMISSION_GROUP_EDIT, + PERMISSION_GROUP_VIEW, PERMISSION_USER_CREATE, PERMISSION_USER_DELETE, + PERMISSION_USER_EDIT, PERMISSION_USER_VIEW +) def user_list(request): @@ -27,23 +28,23 @@ def user_list(request): context = { 'object_list': get_user_model().objects.exclude(is_superuser=True).exclude(is_staff=True).order_by('username'), - 'title': _(u'Users'), + 'title': _('Users'), 'hide_link': True, 'extra_columns': [ { - 'name': _(u'Full name'), + 'name': _('Full name'), 'attribute': 'get_full_name' }, { - 'name': _(u'Email'), + 'name': _('Email'), 'attribute': 'email' }, { - 'name': _(u'Active'), + 'name': _('Active'), 'attribute': encapsulate(lambda x: two_state_template(x.is_active)), }, { - 'name': _(u'Has usable password?'), + 'name': _('Has usable password?'), 'attribute': encapsulate(lambda x: two_state_template(x.has_usable_password())), }, ], @@ -58,20 +59,20 @@ def user_edit(request, user_id): user = get_object_or_404(User, pk=user_id) if user.is_superuser or user.is_staff: - messages.error(request, _(u'Super user and staff user editing is not allowed, use the admin interface for these cases.')) + messages.error(request, _('Super user and staff user editing is not allowed, use the admin interface for these cases.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) if request.method == 'POST': form = UserForm(instance=user, data=request.POST) if form.is_valid(): form.save() - messages.success(request, _(u'User "%s" updated successfully.') % user) + messages.success(request, _('User "%s" updated successfully.') % user) return HttpResponseRedirect(reverse('user_management:user_list')) else: form = UserForm(instance=user) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit user: %s') % user, + 'title': _('Edit user: %s') % user, 'form': form, 'object': user, }, context_instance=RequestContext(request)) @@ -86,13 +87,13 @@ def user_add(request): user = form.save(commit=False) user.set_unusable_password() user.save() - messages.success(request, _(u'User "%s" created successfully.') % user) + messages.success(request, _('User "%s" created successfully.') % user) return HttpResponseRedirect(reverse('user_management:user_set_password', args=[user.pk])) else: form = UserForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Create new user'), + 'title': _('Create new user'), 'form': form, }, context_instance=RequestContext(request)) @@ -107,7 +108,7 @@ def user_delete(request, user_id=None, user_id_list=None): elif user_id_list: users = [get_object_or_404(User, pk=user_id) for user_id in user_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one user.')) + messages.error(request, _('Must provide at least one user.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL)))) @@ -117,12 +118,12 @@ def user_delete(request, user_id=None, user_id_list=None): for user in users: try: if user.is_superuser or user.is_staff: - messages.error(request, _(u'Super user and staff user deleting is not allowed, use the admin interface for these cases.')) + messages.error(request, _('Super user and staff user deleting is not allowed, use the admin interface for these cases.')) else: user.delete() - messages.success(request, _(u'User "%s" deleted successfully.') % user) + messages.success(request, _('User "%s" deleted successfully.') % user) except Exception as exception: - messages.error(request, _(u'Error deleting user "%(user)s": %(error)s') % { + messages.error(request, _('Error deleting user "%(user)s": %(error)s') % { 'user': user, 'error': exception }) @@ -135,9 +136,9 @@ def user_delete(request, user_id=None, user_id_list=None): } if len(users) == 1: context['object'] = users[0] - context['title'] = _(u'Are you sure you wish to delete the user: %s?') % ', '.join([unicode(d) for d in users]) + context['title'] = _('Are you sure you wish to delete the user: %s?') % ', '.join([unicode(d) for d in users]) elif len(users) > 1: - context['title'] = _(u'Are you sure you wish to delete the users: %s?') % ', '.join([unicode(d) for d in users]) + context['title'] = _('Are you sure you wish to delete the users: %s?') % ', '.join([unicode(d) for d in users]) return render_to_response('main/generic_confirm.html', context, context_instance=RequestContext(request)) @@ -159,7 +160,7 @@ def user_set_password(request, user_id=None, user_id_list=None): elif user_id_list: users = [get_object_or_404(User, pk=user_id) for user_id in user_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one user.')) + messages.error(request, _('Must provide at least one user.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) next = request.POST.get('next', request.GET.get('next', post_action_redirect if post_action_redirect else request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL)))) @@ -170,18 +171,18 @@ def user_set_password(request, user_id=None, user_id_list=None): password_1 = form.cleaned_data['new_password_1'] password_2 = form.cleaned_data['new_password_2'] if password_1 != password_2: - messages.error(request, _(u'Passwords do not match, try again.')) + messages.error(request, _('Passwords do not match, try again.')) else: for user in users: try: if user.is_superuser or user.is_staff: - messages.error(request, _(u'Super user and staff user password reseting is not allowed, use the admin interface for these cases.')) + messages.error(request, _('Super user and staff user password reseting is not allowed, use the admin interface for these cases.')) else: user.set_password(password_1) user.save() - messages.success(request, _(u'Successfull password reset for user: %s.') % user) + messages.success(request, _('Successfull password reset for user: %s.') % user) except Exception as exception: - messages.error(request, _(u'Error reseting password for user "%(user)s": %(error)s') % { + messages.error(request, _('Error reseting password for user "%(user)s": %(error)s') % { 'user': user, 'error': exception }) @@ -196,9 +197,9 @@ def user_set_password(request, user_id=None, user_id_list=None): if len(users) == 1: context['object'] = users[0] - context['title'] = _(u'Reseting password for user: %s') % ', '.join([unicode(d) for d in users]) + context['title'] = _('Reseting password for user: %s') % ', '.join([unicode(d) for d in users]) elif len(users) > 1: - context['title'] = _(u'Reseting password for users: %s') % ', '.join([unicode(d) for d in users]) + context['title'] = _('Reseting password for users: %s') % ', '.join([unicode(d) for d in users]) return render_to_response('main/generic_form.html', context, context_instance=RequestContext(request)) @@ -228,8 +229,8 @@ def user_groups(request, user_id): right_list=lambda: generate_choices_w_labels(get_user_groups(user), display_object_type=False), add_method=lambda x: x.user_set.add(user), remove_method=lambda x: x.user_set.remove(user), - left_list_title=_(u'Non groups of user: %s') % user, - right_list_title=_(u'Groups of user: %s') % user, + left_list_title=_('Non groups of user: %s') % user, + right_list_title=_('Groups of user: %s') % user, decode_content_type=True, extra_context={ 'object': user, @@ -243,11 +244,11 @@ def group_list(request): context = { 'object_list': Group.objects.all(), - 'title': _(u'Groups'), + 'title': _('Groups'), 'hide_link': True, 'extra_columns': [ { - 'name': _(u'Members'), + 'name': _('Members'), 'attribute': 'user_set.count' }, ], @@ -265,13 +266,13 @@ def group_edit(request, group_id): form = GroupForm(instance=group, data=request.POST) if form.is_valid(): form.save() - messages.success(request, _(u'Group "%s" updated successfully.') % group) + messages.success(request, _('Group "%s" updated successfully.') % group) return HttpResponseRedirect(reverse('user_management:group_list')) else: form = GroupForm(instance=group) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit group: %s') % group, + 'title': _('Edit group: %s') % group, 'form': form, 'object': group, }, context_instance=RequestContext(request)) @@ -284,13 +285,13 @@ def group_add(request): form = GroupForm(request.POST) if form.is_valid(): group = form.save() - messages.success(request, _(u'Group "%s" created successfully.') % group) + messages.success(request, _('Group "%s" created successfully.') % group) return HttpResponseRedirect(reverse('user_management:group_list')) else: form = GroupForm() return render_to_response('main/generic_form.html', { - 'title': _(u'Create new group'), + 'title': _('Create new group'), 'form': form, }, context_instance=RequestContext(request)) @@ -305,7 +306,7 @@ def group_delete(request, group_id=None, group_id_list=None): elif group_id_list: groups = [get_object_or_404(Group, pk=group_id) for group_id in group_id_list.split(',')] else: - messages.error(request, _(u'Must provide at least one group.')) + messages.error(request, _('Must provide at least one group.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL))) previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', reverse(settings.LOGIN_REDIRECT_URL)))) @@ -315,9 +316,9 @@ def group_delete(request, group_id=None, group_id_list=None): for group in groups: try: group.delete() - messages.success(request, _(u'Group "%s" deleted successfully.') % group) + messages.success(request, _('Group "%s" deleted successfully.') % group) except Exception as exception: - messages.error(request, _(u'Error deleting group "%(group)s": %(error)s') % { + messages.error(request, _('Error deleting group "%(group)s": %(error)s') % { 'group': group, 'error': exception }) @@ -330,9 +331,9 @@ def group_delete(request, group_id=None, group_id_list=None): } if len(groups) == 1: context['object'] = groups[0] - context['title'] = _(u'Are you sure you wish to delete the group: %s?') % ', '.join([unicode(d) for d in groups]) + context['title'] = _('Are you sure you wish to delete the group: %s?') % ', '.join([unicode(d) for d in groups]) elif len(groups) > 1: - context['title'] = _(u'Are you sure you wish to delete the groups: %s?') % ', '.join([unicode(d) for d in groups]) + context['title'] = _('Are you sure you wish to delete the groups: %s?') % ', '.join([unicode(d) for d in groups]) return render_to_response('main/generic_confirm.html', context, context_instance=RequestContext(request)) @@ -362,8 +363,8 @@ def group_members(request, group_id): right_list=lambda: generate_choices_w_labels(get_group_members(group), display_object_type=False), add_method=lambda x: group.user_set.add(x), remove_method=lambda x: group.user_set.remove(x), - left_list_title=_(u'Non members of group: %s') % group, - right_list_title=_(u'Members of group: %s') % group, + left_list_title=_('Non members of group: %s') % group, + right_list_title=_('Members of group: %s') % group, decode_content_type=True, extra_context={ 'object': group, diff --git a/mayan/celery.py b/mayan/celery.py index cef3d3e8e0..4c3995bc8b 100644 --- a/mayan/celery.py +++ b/mayan/celery.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os diff --git a/mayan/settings/__init__.py b/mayan/settings/__init__.py index a340fdd16e..b937aad3fd 100644 --- a/mayan/settings/__init__.py +++ b/mayan/settings/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - try: from .local import * # NOQA except ImportError: diff --git a/mayan/settings/base.py b/mayan/settings/base.py index 12d1b16bb4..7f2afdb9ee 100644 --- a/mayan/settings/base.py +++ b/mayan/settings/base.py @@ -7,6 +7,7 @@ https://docs.djangoproject.com/en/1.6/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.6/ref/settings/ """ +from __future__ import unicode_literals # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os @@ -272,5 +273,5 @@ TEST_RUNNER = 'djcelery.contrib.test_runner.CeleryTestSuiteRunner' CORS_ORIGIN_ALLOW_ALL = True # ------ Django REST Swagger ----- SWAGGER_SETTINGS = { - "api_version": '0', # Specify your API's version + 'api_version': '0', # Specify your API's version } diff --git a/mayan/settings/development.py b/mayan/settings/development.py index 85aa4d651e..708ff92212 100644 --- a/mayan/settings/development.py +++ b/mayan/settings/development.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from . import * # NOQA diff --git a/mayan/settings/development_ddt.py b/mayan/settings/development_ddt.py index d81caa13ca..48e600bfbd 100644 --- a/mayan/settings/development_ddt.py +++ b/mayan/settings/development_ddt.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from . import * # NOQA diff --git a/mayan/settings/production.py b/mayan/settings/production.py index 75d2b62528..fbb5cbf4cd 100644 --- a/mayan/settings/production.py +++ b/mayan/settings/production.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from . import * # NOQA diff --git a/mayan/settings/travis/db_mysql.py b/mayan/settings/travis/db_mysql.py index 2f73b681db..96fd3e3ef0 100644 --- a/mayan/settings/travis/db_mysql.py +++ b/mayan/settings/travis/db_mysql.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from .. import * diff --git a/mayan/settings/travis/db_postgres.py b/mayan/settings/travis/db_postgres.py index 7a1a70f53c..339953450b 100644 --- a/mayan/settings/travis/db_postgres.py +++ b/mayan/settings/travis/db_postgres.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals from .. import * diff --git a/mayan/urls.py b/mayan/urls.py index d7aa04ece8..f11cf59f99 100644 --- a/mayan/urls.py +++ b/mayan/urls.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.conf import settings from django.conf.urls import include, patterns, url from django.contrib import admin