Add from __future__ import unicode_literals, issue #37

This commit is contained in:
Roberto Rosario
2015-01-19 04:06:40 -04:00
parent efbac7300c
commit d59ea3ede2
334 changed files with 2452 additions and 2268 deletions

View File

@@ -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])),
},
]
},