Move django_gpg literals to their own module

This commit is contained in:
Roberto Rosario
2014-09-13 00:34:01 -04:00
parent 2e1c6ea8c9
commit 3770695af8
3 changed files with 63 additions and 59 deletions

View File

@@ -15,66 +15,12 @@ import gnupg
from django.utils.translation import ugettext_lazy as _
from .exceptions import (GPGVerificationError, GPGSigningError,
GPGDecryptionError, KeyDeleteError, KeyGenerationError,
KeyFetchingError, KeyDoesNotExist, KeyImportError)
GPGDecryptionError, KeyDeleteError, KeyGenerationError,
KeyFetchingError, KeyDoesNotExist, KeyImportError)
from .literals import KEY_TYPES
logger = logging.getLogger(__name__)
KEY_TYPES = {
'pub': _(u'Public'),
'sec': _(u'Secret'),
}
KEY_CLASS_RSA = 'RSA'
KEY_CLASS_DSA = 'DSA'
KEY_CLASS_ELG = 'ELG-E'
KEY_PRIMARY_CLASSES = (
((KEY_CLASS_RSA), _(u'RSA')),
((KEY_CLASS_DSA), _(u'DSA')),
)
KEY_SECONDARY_CLASSES = (
((KEY_CLASS_RSA), _(u'RSA')),
((KEY_CLASS_ELG), _(u'Elgamal')),
)
KEYSERVER_DEFAULT_PORT = 11371
SIGNATURE_STATE_BAD = 'signature bad'
SIGNATURE_STATE_NONE = None
SIGNATURE_STATE_ERROR = 'signature error'
SIGNATURE_STATE_NO_PUBLIC_KEY = 'no public key'
SIGNATURE_STATE_GOOD = 'signature good'
SIGNATURE_STATE_VALID = 'signature valid'
SIGNATURE_STATES = {
SIGNATURE_STATE_BAD: {
'text': _(u'Bad signature.'),
'icon': 'cross.png'
},
SIGNATURE_STATE_NONE: {
'text': _(u'Document not signed or invalid signature.'),
'icon': 'cross.png'
},
SIGNATURE_STATE_ERROR: {
'text': _(u'Signature error.'),
'icon': 'cross.png'
},
SIGNATURE_STATE_NO_PUBLIC_KEY: {
'text': _(u'Document is signed but no public key is available for verification.'),
'icon': 'user_silhouette.png'
},
SIGNATURE_STATE_GOOD: {
'text': _(u'Document is signed, and signature is good.'),
'icon': 'document_signature.png'
},
SIGNATURE_STATE_VALID: {
'text': _(u'Document is signed with a valid signature.'),
'icon': 'document_signature.png'
},
}
class Key(object):
@staticmethod

View File

@@ -0,0 +1,58 @@
from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
KEY_TYPES = {
'pub': _('Public'),
'sec': _('Secret'),
}
KEY_CLASS_RSA = 'RSA'
KEY_CLASS_DSA = 'DSA'
KEY_CLASS_ELG = 'ELG-E'
KEY_PRIMARY_CLASSES = (
((KEY_CLASS_RSA), _('RSA')),
((KEY_CLASS_DSA), _('DSA')),
)
KEY_SECONDARY_CLASSES = (
((KEY_CLASS_RSA), _('RSA')),
((KEY_CLASS_ELG), _('Elgamal')),
)
KEYSERVER_DEFAULT_PORT = 11371
SIGNATURE_STATE_BAD = 'signature bad'
SIGNATURE_STATE_NONE = None
SIGNATURE_STATE_ERROR = 'signature error'
SIGNATURE_STATE_NO_PUBLIC_KEY = 'no public key'
SIGNATURE_STATE_GOOD = 'signature good'
SIGNATURE_STATE_VALID = 'signature valid'
SIGNATURE_STATES = {
SIGNATURE_STATE_BAD: {
'text': _('Bad signature.'),
'icon': 'cross.png'
},
SIGNATURE_STATE_NONE: {
'text': _('Document not signed or invalid signature.'),
'icon': 'cross.png'
},
SIGNATURE_STATE_ERROR: {
'text': _('Signature error.'),
'icon': 'cross.png'
},
SIGNATURE_STATE_NO_PUBLIC_KEY: {
'text': _('Document is signed but no public key is available for verification.'),
'icon': 'user_silhouette.png'
},
SIGNATURE_STATE_GOOD: {
'text': _('Document is signed, and signature is good.'),
'icon': 'document_signature.png'
},
SIGNATURE_STATE_VALID: {
'text': _('Document is signed with a valid signature.'),
'icon': 'document_signature.png'
},
}

View File

@@ -14,9 +14,9 @@ from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from acls.models import AccessEntry
from filetransfers.api import serve_file
from django_gpg.api import SIGNATURE_STATE_NONE, SIGNATURE_STATES
from django_gpg.literals import SIGNATURE_STATE_NONE, SIGNATURE_STATES
from documents.models import Document, RecentDocument
from filetransfers.api import serve_file
from permissions.models import Permission
from . import (PERMISSION_DOCUMENT_VERIFY, PERMISSION_SIGNATURE_UPLOAD,