flake8 cleanups
This commit is contained in:
@@ -28,9 +28,9 @@ QUALITY_SETTINGS = {QUALITY_DEFAULT: DEFAULT_OPTIONS,
|
||||
|
||||
CONVERTER_OFFICE_FILE_EXTENSIONS = [
|
||||
u'ods', u'docx'
|
||||
]
|
||||
|
||||
|
||||
]
|
||||
|
||||
|
||||
def _lazy_load(fn):
|
||||
_cached = []
|
||||
|
||||
@@ -118,7 +118,7 @@ def convert(document, size, quality=QUALITY_DEFAULT, page=0, file_format=u'jpg',
|
||||
output_filepath = create_image_cache_filename(document.checksum, size=size, page=page, file_format=file_format, quality=quality, extra_options=extra_options, zoom=zoom, rotation=rotation)
|
||||
if os.path.exists(output_filepath):
|
||||
return output_filepath
|
||||
|
||||
|
||||
input_filepath = document_save_to_temp_dir(document, document.checksum)
|
||||
|
||||
if document.file_extension.lower() in CONVERTER_OFFICE_FILE_EXTENSIONS:
|
||||
@@ -127,7 +127,7 @@ def convert(document, size, quality=QUALITY_DEFAULT, page=0, file_format=u'jpg',
|
||||
unoconv_output = result
|
||||
input_filepath = result
|
||||
extra_options = u''
|
||||
|
||||
|
||||
input_arg = u'%s[%s]' % (input_filepath, page)
|
||||
extra_options += u' -resize %s' % size
|
||||
if zoom != 100:
|
||||
@@ -152,7 +152,7 @@ def convert(document, size, quality=QUALITY_DEFAULT, page=0, file_format=u'jpg',
|
||||
def get_page_count(input_filepath):
|
||||
try:
|
||||
return len(backend.execute_identify(unicode(input_filepath)).splitlines())
|
||||
except Exception, e:
|
||||
except:
|
||||
#TODO: send to other page number identifying program
|
||||
return 1
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from converter.exceptions import ConvertError, UnknownFormat, IdentifyError
|
||||
CONVERTER_ERROR_STRING_NO_DECODER = u'No decode delegate for this image format'
|
||||
CONVERTER_ERROR_STARTS_WITH = u'starts with'
|
||||
|
||||
|
||||
def execute_identify(input_filepath, arguments=u''):
|
||||
command = []
|
||||
command.append(unicode(GM_PATH))
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import tempfile
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from navigation.api import register_links, register_menu, \
|
||||
register_model_list_columns, register_multi_item_links
|
||||
from common.utils import pretty_size
|
||||
from common.conf import settings as common_settings
|
||||
from main.api import register_diagnostic
|
||||
from permissions.api import register_permissions
|
||||
|
||||
@@ -36,8 +32,8 @@ register_permissions('documents', [
|
||||
{'name': PERMISSION_DOCUMENT_TOOLS, 'label': _(u'Execute document modifying tools')},
|
||||
])
|
||||
|
||||
document_list = {'text': _(u'documents list'), 'view': 'document_list', 'famfam': 'page', 'permissions': {'namespace': 'documents', 'permissions': [PERMISSION_DOCUMENT_VIEW]}}
|
||||
document_list_recent = {'text': _(u'recent documents list'), 'view': 'document_list_recent', 'famfam': 'page', 'permissions': {'namespace': 'documents', 'permissions': [PERMISSION_DOCUMENT_VIEW]}}
|
||||
document_list = {'text': _(u'documents list'), 'view': 'document_list', 'famfam': 'page', 'permissions': {'namespace': 'documents', 'permissions': [PERMISSION_DOCUMENT_VIEW]}}
|
||||
document_list_recent = {'text': _(u'recent documents list'), 'view': 'document_list_recent', 'famfam': 'page', 'permissions': {'namespace': 'documents', 'permissions': [PERMISSION_DOCUMENT_VIEW]}}
|
||||
document_create = {'text': _('upload a new document'), 'view': 'document_create', 'famfam': 'page_add', 'permissions': {'namespace': 'documents', 'permissions': [PERMISSION_DOCUMENT_CREATE]}}
|
||||
document_create_multiple = {'text': _('upload multiple new documents'), 'view': 'document_create_multiple', 'famfam': 'page_add', 'permissions': {'namespace': 'documents', 'permissions': [PERMISSION_DOCUMENT_CREATE]}}
|
||||
document_create_sibling = {'text': _('upload new document using same metadata'), 'view': 'document_create_sibling', 'args': 'object.id', 'famfam': 'page_copy', 'permissions': {'namespace': 'documents', 'permissions': [PERMISSION_DOCUMENT_CREATE]}}
|
||||
|
||||
@@ -18,7 +18,7 @@ class MetadataIndexInline(admin.StackedInline):
|
||||
classes = ('collapse-open',)
|
||||
allow_add = True
|
||||
|
||||
|
||||
|
||||
class DocumentTypeMetadataTypeInline(admin.StackedInline):
|
||||
model = DocumentTypeMetadataType
|
||||
extra = 1
|
||||
@@ -35,7 +35,7 @@ class DocumentTypeFilenameInline(admin.StackedInline):
|
||||
|
||||
class DocumentTypeAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
DocumentTypeFilenameInline, DocumentTypeMetadataTypeInline,
|
||||
DocumentTypeFilenameInline, DocumentTypeMetadataTypeInline,
|
||||
MetadataIndexInline
|
||||
]
|
||||
|
||||
@@ -49,7 +49,7 @@ class DocumentMetadataInline(admin.StackedInline):
|
||||
|
||||
class DocumentPageTransformationAdmin(admin.ModelAdmin):
|
||||
model = DocumentPageTransformation
|
||||
|
||||
|
||||
|
||||
class DocumentPageInline(admin.StackedInline):
|
||||
model = DocumentPage
|
||||
@@ -71,25 +71,25 @@ class MetadataGroupItemInline(admin.StackedInline):
|
||||
extra = 1
|
||||
classes = ('collapse-open',)
|
||||
allow_add = True
|
||||
|
||||
|
||||
|
||||
|
||||
class MetadataGroupAdmin(admin.ModelAdmin):
|
||||
inlines = [MetadataGroupItemInline]
|
||||
filter_horizontal = ['document_type']
|
||||
|
||||
|
||||
|
||||
class RecentDocumentAdmin(admin.ModelAdmin):
|
||||
model = RecentDocument
|
||||
list_display = ('user', 'document', 'datetime_accessed')
|
||||
readonly_fields = ('user', 'document', 'datetime_accessed')
|
||||
list_filter = ('user',)
|
||||
date_hierarchy = 'datetime_accessed'
|
||||
|
||||
|
||||
|
||||
|
||||
admin.site.register(MetadataType, MetadataTypeAdmin)
|
||||
admin.site.register(DocumentType, DocumentTypeAdmin)
|
||||
admin.site.register(Document, DocumentAdmin)
|
||||
admin.site.register(MetadataGroup, MetadataGroupAdmin)
|
||||
admin.site.register(DocumentPageTransformation,
|
||||
admin.site.register(DocumentPageTransformation,
|
||||
DocumentPageTransformationAdmin)
|
||||
admin.site.register(RecentDocument, RecentDocumentAdmin)
|
||||
|
||||
@@ -100,8 +100,6 @@ class DocumentPageForm_edit(forms.ModelForm):
|
||||
class ImageWidget(forms.widgets.Widget):
|
||||
def render(self, name, value, attrs=None):
|
||||
output = []
|
||||
page_count = value.documentpage_set.count()
|
||||
|
||||
output.append(u'<div style="white-space:nowrap; overflow: auto;">')
|
||||
|
||||
for page in value.documentpage_set.all():
|
||||
|
||||
@@ -153,7 +153,7 @@ class Document(models.Model):
|
||||
|
||||
def exists(self):
|
||||
return self.file.storage.exists(self.file.path)
|
||||
|
||||
|
||||
def get_metadata_string(self):
|
||||
return u', '.join([u'%s - %s' % (metadata.metadata_type, metadata.value) for metadata in self.documentmetadata_set.select_related('metadata_type', 'document').defer('document__document_type', 'document__file', 'document__description', 'document__file_filename', 'document__uuid', 'document__date_added', 'document__date_updated', 'document__file_mimetype', 'document__file_mime_encoding')])
|
||||
|
||||
@@ -284,7 +284,7 @@ class MetadataGroupManager(models.Manager):
|
||||
metadata_dict = {}
|
||||
for document_metadata in document.documentmetadata_set.all():
|
||||
metadata_dict['metadata_%s' % document_metadata.metadata_type.name] = document_metadata.value
|
||||
|
||||
|
||||
if group_obj:
|
||||
groups_qs = MetadataGroup.objects.filter((Q(document_type=document.document_type) | Q(document_type=None)) & Q(enabled=True) & Q(pk=group_obj.pk))
|
||||
else:
|
||||
@@ -317,9 +317,9 @@ class MetadataGroupManager(models.Manager):
|
||||
|
||||
if group_obj:
|
||||
return metadata_groups[group_obj], errors
|
||||
|
||||
|
||||
return metadata_groups, errors
|
||||
|
||||
|
||||
|
||||
class MetadataGroup(models.Model):
|
||||
document_type = models.ManyToManyField(DocumentType, null=True, blank=True,
|
||||
@@ -415,9 +415,9 @@ class RecentDocument(models.Model):
|
||||
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'), db_index=True)
|
||||
|
||||
|
||||
objects = RecentDocumentManager()
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.document)
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ from documents.conf.settings import ZOOM_MIN_LEVEL
|
||||
from documents.conf.settings import ROTATION_STEP
|
||||
|
||||
from documents import PERMISSION_DOCUMENT_CREATE, \
|
||||
PERMISSION_DOCUMENT_CREATE, PERMISSION_DOCUMENT_PROPERTIES_EDIT, \
|
||||
PERMISSION_DOCUMENT_PROPERTIES_EDIT, \
|
||||
PERMISSION_DOCUMENT_METADATA_EDIT, PERMISSION_DOCUMENT_VIEW, \
|
||||
PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, \
|
||||
PERMISSION_DOCUMENT_TRANSFORM, \
|
||||
@@ -618,7 +618,7 @@ def staging_file_preview(request, staging_file_id):
|
||||
except UnkownConvertError, e:
|
||||
if request.user.is_staff or request.user.is_superuser:
|
||||
messages.error(request, e)
|
||||
|
||||
|
||||
output_file = os.path.join(settings.MEDIA_ROOT, u'images', PICTURE_ERROR_MEDIUM)
|
||||
except UnknownFormat:
|
||||
output_file = os.path.join(settings.MEDIA_ROOT, u'images', PICTURE_UNKNOWN_MEDIUM)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_links, register_menu, \
|
||||
register_model_list_columns, register_multi_item_links
|
||||
from permissions.api import register_permissions
|
||||
register_multi_item_links
|
||||
from navigation.api import register_sidebar_template
|
||||
|
||||
from folders.models import Folder
|
||||
|
||||
folder_list = {'text': _(u'folder list'), 'view': 'folder_list', 'famfam': 'folder'}
|
||||
folder_list = {'text': _(u'folder list'), 'view': 'folder_list', 'famfam': 'folder'}
|
||||
folder_create = {'text': _('create folder'), 'view': 'folder_create', 'famfam': 'folder_add'}
|
||||
folder_edit = {'text': _('edit'), 'view': 'folder_edit', 'args': 'object.id', 'famfam': 'folder_edit'}
|
||||
folder_delete = {'text': _('delete'), 'view': 'folder_delete', 'args': 'object.id', 'famfam': 'folder_delete'}
|
||||
|
||||
@@ -110,9 +110,9 @@ def check_settings(request):
|
||||
'hide_object': True,
|
||||
'extra_columns': [
|
||||
{'name': _(u'name'), 'attribute': 'name'},
|
||||
{'name': _(u'value'), 'attribute': lambda x: _return_type(x['value'])},
|
||||
{'name': _(u'description'), 'attribute': lambda x: x.get('description', {}).get(x['name'], '')},
|
||||
{'name': _(u'exists'), 'attribute': lambda x: exists_with_famfam(x['value']) if 'exists' in x else ''},
|
||||
{'name': _(u'value'), 'attribute': lambda x: _return_type(x['value'])},
|
||||
{'name': _(u'description'), 'attribute': lambda x: x.get('description', {}).get(x['name'], '')},
|
||||
{'name': _(u'exists'), 'attribute': lambda x: exists_with_famfam(x['value']) if 'exists' in x else ''},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from django.db.models.signals import post_save
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_links, register_menu
|
||||
from navigation.api import register_links
|
||||
|
||||
from permissions.conf.settings import DEFAULT_ROLES
|
||||
from permissions.models import Role
|
||||
|
||||
Reference in New Issue
Block a user