PEP8 cleanups
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.contenttypes import generic
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
|
||||||
|
|
||||||
from .models import AccessEntry
|
from .models import AccessEntry
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ from django.utils.translation import ugettext
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
from common.models import AnonymousUserSingleton
|
from common.models import AnonymousUserSingleton
|
||||||
|
from permissions.models import Permission
|
||||||
|
|
||||||
from .classes import EncapsulatedObject, AccessHolder, ClassAccessHolder
|
from .classes import EncapsulatedObject, AccessHolder, ClassAccessHolder
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -131,4 +131,3 @@ def get_available_transformations_choices():
|
|||||||
|
|
||||||
def get_format_list():
|
def get_format_list():
|
||||||
return [(format, FILE_FORMATS.get(format, u'')) for format in backend.get_format_list()]
|
return [(format, FILE_FORMATS.get(format, u'')) for format in backend.get_format_list()]
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
class ConvertError(Exception):
|
class ConvertError(Exception):
|
||||||
'''
|
"""
|
||||||
Base exception for all coverter app exceptions
|
Base exception for all coverter app exceptions
|
||||||
'''
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class UnknownFileFormat(ConvertError):
|
class UnknownFileFormat(ConvertError):
|
||||||
'''
|
"""
|
||||||
Raised when the converter backend can't understand a file
|
Raised when the converter backend can't understand a file
|
||||||
'''
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IdentifyError(ConvertError):
|
class IdentifyError(ConvertError):
|
||||||
'''
|
"""
|
||||||
Raised by the graphcismagick and imagemagics identify program
|
Raised by the graphcismagick and imagemagics identify program
|
||||||
'''
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class UnkownConvertError(ConvertError):
|
class UnkownConvertError(ConvertError):
|
||||||
'''
|
"""
|
||||||
Raised when an error is found but there is no disernible way to
|
Raised when an error is found but there is no disernible way to
|
||||||
identify the kind of error
|
identify the kind of error
|
||||||
'''
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class DocumentVersionSignature(models.Model):
|
class DocumentVersionSignature(models.Model):
|
||||||
'''
|
"""
|
||||||
Model that describes a document version signature properties
|
Model that describes a document version signature properties
|
||||||
'''
|
"""
|
||||||
document_version = models.ForeignKey(DocumentVersion, verbose_name=_(u'document version'), editable=False)
|
document_version = models.ForeignKey(DocumentVersion, verbose_name=_(u'document version'), editable=False)
|
||||||
signature_file = models.FileField(blank=True, null=True, upload_to=get_filename_from_uuid, storage=STORAGE_BACKEND(), verbose_name=_(u'signature file'), editable=False)
|
signature_file = models.FileField(blank=True, null=True, upload_to=get_filename_from_uuid, 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)
|
has_embedded_signature = models.BooleanField(default=False, verbose_name=_(u'has embedded signature'), editable=False)
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,6 @@ def folder_add_document(request, document_id):
|
|||||||
else:
|
else:
|
||||||
form = FolderListForm(user=request.user)
|
form = FolderListForm(user=request.user)
|
||||||
|
|
||||||
|
|
||||||
return render_to_response('generic_form.html', {
|
return render_to_response('generic_form.html', {
|
||||||
'title': _(u'add document "%s" to a folder') % document,
|
'title': _(u'add document "%s" to a folder') % document,
|
||||||
'form': form,
|
'form': form,
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'''Metadata handling commonalities'''
|
"""Metadata handling commonalities"""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from urllib import unquote_plus
|
from urllib import unquote_plus
|
||||||
@@ -9,9 +9,9 @@ from .models import DocumentMetadata, MetadataType
|
|||||||
|
|
||||||
|
|
||||||
def decode_metadata_from_url(url_dict):
|
def decode_metadata_from_url(url_dict):
|
||||||
'''
|
"""
|
||||||
Parse a URL query string to a list of metadata
|
Parse a URL query string to a list of metadata
|
||||||
'''
|
"""
|
||||||
metadata_dict = {
|
metadata_dict = {
|
||||||
'id': {},
|
'id': {},
|
||||||
'value': {}
|
'value': {}
|
||||||
@@ -35,19 +35,19 @@ def decode_metadata_from_url(url_dict):
|
|||||||
|
|
||||||
|
|
||||||
def save_metadata_list(metadata_list, document, create=False):
|
def save_metadata_list(metadata_list, document, create=False):
|
||||||
'''
|
"""
|
||||||
Take a list of metadata dictionaries and associate them to a
|
Take a list of metadata dictionaries and associate them to a
|
||||||
document
|
document
|
||||||
'''
|
"""
|
||||||
for item in metadata_list:
|
for item in metadata_list:
|
||||||
save_metadata(item, document, create)
|
save_metadata(item, document, create)
|
||||||
|
|
||||||
|
|
||||||
def save_metadata(metadata_dict, document, create=False):
|
def save_metadata(metadata_dict, document, create=False):
|
||||||
'''
|
"""
|
||||||
Take a dictionary of metadata type & value and associate it to a
|
Take a dictionary of metadata type & value and associate it to a
|
||||||
document
|
document
|
||||||
'''
|
"""
|
||||||
if create:
|
if create:
|
||||||
# Use matched metadata now to create document metadata
|
# Use matched metadata now to create document metadata
|
||||||
document_metadata, created = DocumentMetadata.objects.get_or_create(
|
document_metadata, created = DocumentMetadata.objects.get_or_create(
|
||||||
@@ -81,16 +81,16 @@ def save_metadata(metadata_dict, document, create=False):
|
|||||||
|
|
||||||
|
|
||||||
def metadata_repr(metadata_list):
|
def metadata_repr(metadata_list):
|
||||||
'''
|
"""
|
||||||
Return a printable representation of a metadata list
|
Return a printable representation of a metadata list
|
||||||
'''
|
"""
|
||||||
return u', '.join(metadata_repr_as_list(metadata_list))
|
return u', '.join(metadata_repr_as_list(metadata_list))
|
||||||
|
|
||||||
|
|
||||||
def metadata_repr_as_list(metadata_list):
|
def metadata_repr_as_list(metadata_list):
|
||||||
'''
|
"""
|
||||||
Turn a list of metadata into a list of printable representations
|
Turn a list of metadata into a list of printable representations
|
||||||
'''
|
"""
|
||||||
output = []
|
output = []
|
||||||
for metadata_dict in metadata_list:
|
for metadata_dict in metadata_list:
|
||||||
try:
|
try:
|
||||||
@@ -103,7 +103,7 @@ def metadata_repr_as_list(metadata_list):
|
|||||||
|
|
||||||
|
|
||||||
def get_metadata_string(document):
|
def get_metadata_string(document):
|
||||||
'''
|
"""
|
||||||
Return a formated representation of a document's metadata values
|
Return a formated representation of a document's metadata values
|
||||||
'''
|
"""
|
||||||
return u', '.join([u'%s - %s' % (metadata.metadata_type, metadata.value) for metadata in DocumentMetadata.objects.filter(document=document).select_related('metadata_type')])
|
return u', '.join([u'%s - %s' % (metadata.metadata_type, metadata.value) for metadata in DocumentMetadata.objects.filter(document=document).select_related('metadata_type')])
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ available_functions_string = (_(u' Available functions: %s') % u','.join([u'%s()
|
|||||||
|
|
||||||
|
|
||||||
class MetadataType(models.Model):
|
class MetadataType(models.Model):
|
||||||
'''
|
"""
|
||||||
Define a type of metadata
|
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=_(u'name'), help_text=_(u'Do not use python reserved words, or spaces.'))
|
||||||
title = models.CharField(max_length=48, verbose_name=_(u'title'), blank=True, null=True)
|
title = models.CharField(max_length=48, verbose_name=_(u'title'), blank=True, null=True)
|
||||||
default = models.CharField(max_length=128, blank=True, null=True,
|
default = models.CharField(max_length=128, blank=True, null=True,
|
||||||
@@ -35,9 +35,9 @@ class MetadataType(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class MetadataSet(models.Model):
|
class MetadataSet(models.Model):
|
||||||
'''
|
"""
|
||||||
Define a group of metadata types
|
Define a group of metadata types
|
||||||
'''
|
"""
|
||||||
title = models.CharField(max_length=48, verbose_name=_(u'title'))
|
title = models.CharField(max_length=48, verbose_name=_(u'title'))
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
@@ -50,10 +50,10 @@ class MetadataSet(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class MetadataSetItem(models.Model):
|
class MetadataSetItem(models.Model):
|
||||||
'''
|
"""
|
||||||
Define the set of metadata that relates to a set or group of
|
Define the set of metadata that relates to a set or group of
|
||||||
metadata fields
|
metadata fields
|
||||||
'''
|
"""
|
||||||
metadata_set = models.ForeignKey(MetadataSet, verbose_name=_(u'metadata set'))
|
metadata_set = models.ForeignKey(MetadataSet, verbose_name=_(u'metadata set'))
|
||||||
metadata_type = models.ForeignKey(MetadataType, verbose_name=_(u'metadata type'))
|
metadata_type = models.ForeignKey(MetadataType, verbose_name=_(u'metadata type'))
|
||||||
#required = models.BooleanField(default=True, verbose_name=_(u'required'))
|
#required = models.BooleanField(default=True, verbose_name=_(u'required'))
|
||||||
@@ -67,10 +67,10 @@ class MetadataSetItem(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class DocumentMetadata(models.Model):
|
class DocumentMetadata(models.Model):
|
||||||
'''
|
"""
|
||||||
Link a document to a specific instance of a metadata type with it's
|
Link a document to a specific instance of a metadata type with it's
|
||||||
current value
|
current value
|
||||||
'''
|
"""
|
||||||
document = models.ForeignKey(Document, verbose_name=_(u'document'))
|
document = models.ForeignKey(Document, verbose_name=_(u'document'))
|
||||||
metadata_type = models.ForeignKey(MetadataType, verbose_name=_(u'type'))
|
metadata_type = models.ForeignKey(MetadataType, verbose_name=_(u'type'))
|
||||||
value = models.CharField(max_length=256, blank=True, verbose_name=_(u'value'), db_index=True)
|
value = models.CharField(max_length=256, blank=True, verbose_name=_(u'value'), db_index=True)
|
||||||
@@ -84,10 +84,10 @@ class DocumentMetadata(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class DocumentTypeDefaults(models.Model):
|
class DocumentTypeDefaults(models.Model):
|
||||||
'''
|
"""
|
||||||
Default preselected metadata types and metadata set per document
|
Default preselected metadata types and metadata set per document
|
||||||
type
|
type
|
||||||
'''
|
"""
|
||||||
document_type = models.ForeignKey(DocumentType, verbose_name=_(u'document type'))
|
document_type = models.ForeignKey(DocumentType, verbose_name=_(u'document type'))
|
||||||
default_metadata_sets = models.ManyToManyField(MetadataSet, blank=True, verbose_name=_(u'default metadata sets'))
|
default_metadata_sets = models.ManyToManyField(MetadataSet, blank=True, verbose_name=_(u'default metadata sets'))
|
||||||
default_metadata = models.ManyToManyField(MetadataType, blank=True, verbose_name=_(u'default metadata'))
|
default_metadata = models.ManyToManyField(MetadataType, blank=True, verbose_name=_(u'default metadata'))
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from .models import DocumentQueue, QueueTransformation
|
|||||||
from .tasks import task_process_document_queues
|
from .tasks import task_process_document_queues
|
||||||
from .permissions import (PERMISSION_OCR_DOCUMENT,
|
from .permissions import (PERMISSION_OCR_DOCUMENT,
|
||||||
PERMISSION_OCR_DOCUMENT_DELETE, PERMISSION_OCR_QUEUE_ENABLE_DISABLE,
|
PERMISSION_OCR_DOCUMENT_DELETE, PERMISSION_OCR_QUEUE_ENABLE_DISABLE,
|
||||||
PERMISSION_OCR_CLEAN_ALL_PAGES, PERMISSION_OCR_QUEUE_EDIT)
|
PERMISSION_OCR_CLEAN_ALL_PAGES)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
|
|
||||||
from project_setup.api import register_setup
|
from project_setup.api import register_setup
|
||||||
|
|
||||||
|
|
||||||
def is_superuser(context):
|
def is_superuser(context):
|
||||||
return context['request'].user.is_staff or context['request'].user.is_superuser
|
return context['request'].user.is_staff or context['request'].user.is_superuser
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
|
|||||||
>>> 1 + 1 == 2
|
>>> 1 + 1 == 2
|
||||||
True
|
True
|
||||||
"""}
|
"""}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class TagForm(forms.Form):
|
class TagForm(forms.Form):
|
||||||
'''
|
"""
|
||||||
Form to edit an existing tag's properties
|
Form to edit an existing tag's properties
|
||||||
'''
|
"""
|
||||||
name = forms.CharField(label=_(u'Name'))
|
name = forms.CharField(label=_(u'Name'))
|
||||||
color = forms.ChoiceField(choices=COLOR_CHOICES, label=_(u'Color'))
|
color = forms.ChoiceField(choices=COLOR_CHOICES, label=_(u'Color'))
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ from django.utils.safestring import mark_safe
|
|||||||
|
|
||||||
|
|
||||||
def get_tags_inline_widget(document):
|
def get_tags_inline_widget(document):
|
||||||
'''
|
"""
|
||||||
A tag widget that includes the total tag count for a given document
|
A tag widget that includes the total tag count for a given document
|
||||||
'''
|
"""
|
||||||
tags_template = []
|
tags_template = []
|
||||||
tag_count = document.tags.count()
|
tag_count = document.tags.count()
|
||||||
if tag_count:
|
if tag_count:
|
||||||
@@ -20,10 +20,10 @@ def get_tags_inline_widget(document):
|
|||||||
|
|
||||||
|
|
||||||
def get_tags_inline_widget_simple(document):
|
def get_tags_inline_widget_simple(document):
|
||||||
'''
|
"""
|
||||||
A tag widget that only displayes the rectangular colored boxes for a
|
A tag widget that only displayes the rectangular colored boxes for a
|
||||||
given document
|
given document
|
||||||
'''
|
"""
|
||||||
tags_template = []
|
tags_template = []
|
||||||
|
|
||||||
tag_count = document.tags.count()
|
tag_count = document.tags.count()
|
||||||
|
|||||||
Reference in New Issue
Block a user