PEP8 Cleanups
This commit is contained in:
@@ -26,14 +26,6 @@ register_settings(
|
||||
namespace=u'documents',
|
||||
module=u'documents.conf.settings',
|
||||
settings=[
|
||||
# Upload
|
||||
#{'name': u'USE_STAGING_DIRECTORY', 'global_name': u'DOCUMENTS_USE_STAGING_DIRECTORY', 'default': False},
|
||||
#{'name': u'STAGING_DIRECTORY', 'global_name': u'DOCUMENTS_STAGING_DIRECTORY', 'default': u'/tmp/mayan/staging', 'exists': True},
|
||||
#{'name': u'PER_USER_STAGING_DIRECTORY', 'global_name': u'DOCUMENTS_PER_USER_STAGING_DIRECTORY', 'default': False},
|
||||
#{'name': u'USER_STAGING_DIRECTORY_ROOT', 'global_name': u'DOCUMENTS_USER_STAGING_DIRECTORY_ROOT', 'default': u'/tmp/mayan/staging/users', 'exists': True},
|
||||
#{'name': u'USER_STAGING_DIRECTORY_EXPRESSION', 'global_name': u'DOCUMENTS_USER_STAGING_DIRECTORY_EXPRESSION', 'default': u'user.username'},
|
||||
#{'name': u'DELETE_STAGING_FILE_AFTER_UPLOAD', 'global_name': u'DOCUMENTS_DELETE_STAGING_FILE_AFTER_UPLOAD', 'default': False},
|
||||
#{'name': u'STAGING_FILES_PREVIEW_SIZE', 'global_name': u'DOCUMENTS_STAGING_FILES_PREVIEW_SIZE', 'default': u'640x480'},
|
||||
# Saving
|
||||
{'name': u'CHECKSUM_FUNCTION', 'global_name': u'DOCUMENTS_CHECKSUM_FUNCTION', 'default': default_checksum},
|
||||
{'name': u'UUID_FUNCTION', 'global_name': u'DOCUMENTS_UUID_FUNCTION', 'default': default_uuid},
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
|
||||
from navigation.api import register_links, register_top_menu, \
|
||||
from navigation.api import register_links, \
|
||||
register_model_list_columns, register_multi_item_links, \
|
||||
register_sidebar_template
|
||||
|
||||
@@ -12,4 +10,3 @@ staging_file_preview = {'text': _(u'preview'), 'class': 'fancybox-noscaling', 'v
|
||||
staging_file_delete = {'text': _(u'delete'), 'view': 'staging_file_delete', 'args': ['source.source_type', 'source.pk', 'object.id'], 'famfam': 'delete'}
|
||||
|
||||
register_links(StagingFile, [staging_file_preview, staging_file_delete])
|
||||
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.conf import settings
|
||||
|
||||
from common.forms import DetailForm
|
||||
from common.literals import PAGE_SIZE_CHOICES, PAGE_ORIENTATION_CHOICES
|
||||
from common.conf.settings import DEFAULT_PAPER_SIZE
|
||||
from common.conf.settings import DEFAULT_PAGE_ORIENTATION
|
||||
|
||||
from documents.forms import DocumentForm
|
||||
|
||||
@@ -31,7 +23,7 @@ class StagingDocumentForm(DocumentForm):
|
||||
|
||||
if show_expand:
|
||||
self.fields['expand'] = forms.BooleanField(
|
||||
label=_(u'Expand compressed files'), required=False,
|
||||
label=_(u'Expand compressed files'), required=False,
|
||||
help_text=ugettext(u'Upload a compressed file\'s contained files as individual documents')
|
||||
)
|
||||
|
||||
@@ -50,9 +42,9 @@ class WebFormForm(DocumentForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
show_expand = kwargs.pop('show_expand', False)
|
||||
super(WebFormForm, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
if show_expand:
|
||||
self.fields['expand'] = forms.BooleanField(
|
||||
label=_(u'Expand compressed files'), required=False,
|
||||
label=_(u'Expand compressed files'), required=False,
|
||||
help_text=ugettext(u'Upload a compressed file\'s contained files as individual documents')
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ SOURCE_ICON_CHOICES = (
|
||||
|
||||
SOURCE_CHOICE_WEB_FORM = 'webform'
|
||||
SOURCE_CHOICE_STAGING = 'staging'
|
||||
|
||||
|
||||
SOURCE_CHOICES = (
|
||||
(SOURCE_CHOICE_WEB_FORM, _(u'Web form')),
|
||||
(SOURCE_CHOICE_STAGING, _(u'Server staging folder')),
|
||||
@@ -55,10 +55,10 @@ class BaseModel(models.Model):
|
||||
whitelist = models.TextField(blank=True, verbose_name=_(u'whitelist'))
|
||||
blacklist = models.TextField(blank=True, verbose_name=_(u'blacklist'))
|
||||
document_type = models.ForeignKey(DocumentType, blank=True, null=True, verbose_name=_(u'document type'))
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s (%s)' % (self.title, dict(SOURCE_CHOICES).get(self.source_type))
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s (%s)' % (self.title, dict(SOURCE_CHOICES).get(self.source_type))
|
||||
|
||||
class Meta:
|
||||
ordering = ('title',)
|
||||
abstract = True
|
||||
@@ -86,18 +86,18 @@ class StagingFolder(InteractiveBaseModel):
|
||||
preview_height = models.IntegerField(blank=True, null=True, verbose_name=_(u'preview height'))
|
||||
uncompress = models.CharField(max_length=1, choices=SOURCE_INTERACTIVE_UNCOMPRESS_CHOICES, verbose_name=_(u'uncompress'))
|
||||
delete_after_upload = models.BooleanField(default=True, verbose_name=_(u'delete after upload'))
|
||||
|
||||
|
||||
def get_preview_size(self):
|
||||
dimensions = []
|
||||
dimensions.append(unicode(self.preview_width))
|
||||
if self.preview_height:
|
||||
dimensions.append(unicode(self.preview_height))
|
||||
|
||||
|
||||
return u'x'.join(dimensions)
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'staging folder')
|
||||
verbose_name_plural = _(u'staging folder')
|
||||
verbose_name_plural = _(u'staging folder')
|
||||
|
||||
|
||||
#class StagingFolderMetadataValue(models.Model):
|
||||
@@ -111,7 +111,7 @@ class StagingFolder(InteractiveBaseModel):
|
||||
# class Meta:
|
||||
# verbose_name = _(u'source metadata')
|
||||
# verbose_name_plural = _(u'sources metadata')
|
||||
|
||||
|
||||
|
||||
class WebForm(InteractiveBaseModel):
|
||||
is_interactive = True
|
||||
@@ -123,4 +123,4 @@ class WebForm(InteractiveBaseModel):
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'web form')
|
||||
verbose_name_plural = _(u'web forms')
|
||||
verbose_name_plural = _(u'web forms')
|
||||
|
||||
@@ -25,12 +25,12 @@ HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest()
|
||||
#}
|
||||
|
||||
|
||||
def evaluate_user_staging_path(request, source):
|
||||
try:
|
||||
return STAGING_FILE_FUNCTIONS[source](request)
|
||||
except Exception, exc:
|
||||
messages.error(request, _(u'Error evaluating user staging directory expression; %s') % exc)
|
||||
return u''
|
||||
#def evaluate_user_staging_path(request, source):
|
||||
# try:
|
||||
# return STAGING_FILE_FUNCTIONS[source](request)
|
||||
# except Exception, exc:
|
||||
# messages.error(request, _(u'Error evaluating user staging directory expression; %s') % exc)
|
||||
# return u''
|
||||
|
||||
|
||||
def get_all_files(path):
|
||||
@@ -115,8 +115,8 @@ class StagingFile(object):
|
||||
raise Exception(ugettext(u'Unable to upload staging file: %s') % exc)
|
||||
|
||||
def delete(self, preview_size):
|
||||
#tranformation_string, errors = get_transformation_string(DEFAULT_TRANSFORMATIONS)
|
||||
cache_cleanup(self.filepath, size=preview_size)#, extra_options=tranformation_string)
|
||||
# tranformation_string, errors = get_transformation_string(DEFAULT_TRANSFORMATIONS)
|
||||
cache_cleanup(self.filepath, size=preview_size)# , extra_options=tranformation_string)
|
||||
try:
|
||||
os.unlink(self.filepath)
|
||||
except OSError, exc:
|
||||
@@ -127,8 +127,8 @@ class StagingFile(object):
|
||||
|
||||
def preview(self, preview_size):
|
||||
errors = []
|
||||
#tranformation_string, errors = get_transformation_string(DEFAULT_TRANSFORMATIONS)
|
||||
#output_file = convert(self.filepath, size=STAGING_FILES_PREVIEW_SIZE, extra_options=tranformation_string, cleanup_files=False)
|
||||
# tranformation_string, errors = get_transformation_string(DEFAULT_TRANSFORMATIONS)
|
||||
# output_file = convert(self.filepath, size=STAGING_FILES_PREVIEW_SIZE, extra_options=tranformation_string, cleanup_files=False)
|
||||
output_file = convert(self.filepath, size=preview_size, cleanup_files=False)
|
||||
return output_file, errors
|
||||
|
||||
|
||||
@@ -20,14 +20,13 @@ from document_indexing.api import update_indexes
|
||||
from history.api import create_history
|
||||
from metadata.api import save_metadata_list, \
|
||||
decode_metadata_from_url, metadata_repr_as_list
|
||||
from metadata.forms import MetadataFormSet, MetadataSelectionForm
|
||||
from permissions.api import check_permissions
|
||||
import sendfile
|
||||
|
||||
|
||||
from sources.models import WebForm, StagingFolder
|
||||
from sources.models import SOURCE_CHOICE_WEB_FORM, SOURCE_CHOICE_STAGING
|
||||
from sources.models import SOURCE_UNCOMPRESS_CHOICE_Y, \
|
||||
SOURCE_UNCOMPRESS_CHOICE_N, SOURCE_UNCOMPRESS_CHOICE_ASK
|
||||
SOURCE_UNCOMPRESS_CHOICE_ASK
|
||||
from sources.staging import create_staging_file_class
|
||||
from sources.forms import StagingDocumentForm, WebFormForm
|
||||
|
||||
@@ -38,7 +37,7 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
subtemplates_list = []
|
||||
|
||||
tab_links = []
|
||||
|
||||
|
||||
context = {}
|
||||
|
||||
web_forms = WebForm.objects.filter(enabled=True)
|
||||
@@ -62,7 +61,7 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
'keep_query': True,
|
||||
'conditional_highlight': lambda context: context['source'].source_type == staging_folder.source_type and context['source'].pk == staging_folder.pk,
|
||||
})
|
||||
|
||||
|
||||
if web_forms.count() == 0 and staging_folders.count() == 0:
|
||||
subtemplates_list.append(
|
||||
{
|
||||
@@ -83,7 +82,7 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
document_type = None
|
||||
|
||||
subtemplates_list = []
|
||||
|
||||
|
||||
if source_type is None and source_id is None:
|
||||
if web_forms.count():
|
||||
source_type = web_forms[0].source_type
|
||||
@@ -99,14 +98,14 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
if request.method == 'POST':
|
||||
form = WebFormForm(request.POST, request.FILES,
|
||||
document_type=document_type,
|
||||
show_expand=(web_form.uncompress==SOURCE_UNCOMPRESS_CHOICE_ASK)
|
||||
show_expand=(web_form.uncompress == SOURCE_UNCOMPRESS_CHOICE_ASK)
|
||||
)
|
||||
if form.is_valid():
|
||||
try:
|
||||
if web_form.uncompress==SOURCE_UNCOMPRESS_CHOICE_ASK:
|
||||
if web_form.uncompress == SOURCE_UNCOMPRESS_CHOICE_ASK:
|
||||
expand = form.cleaned_data['expand']
|
||||
else:
|
||||
if web_form.uncompress==SOURCE_UNCOMPRESS_CHOICE_Y:
|
||||
if web_form.uncompress == SOURCE_UNCOMPRESS_CHOICE_Y:
|
||||
expand = True
|
||||
else:
|
||||
expand = False
|
||||
@@ -143,10 +142,10 @@ def upload_interactive(request, source_type=None, source_id=None):
|
||||
if form.is_valid():
|
||||
try:
|
||||
staging_file = StagingFile.get(form.cleaned_data['staging_file_id'])
|
||||
if staging_folder.uncompress==SOURCE_UNCOMPRESS_CHOICE_ASK:
|
||||
if staging_folder.uncompress == SOURCE_UNCOMPRESS_CHOICE_ASK:
|
||||
expand = form.cleaned_data['expand']
|
||||
else:
|
||||
if staging_folder.uncompress==SOURCE_UNCOMPRESS_CHOICE_Y:
|
||||
if staging_folder.uncompress == SOURCE_UNCOMPRESS_CHOICE_Y:
|
||||
expand = True
|
||||
else:
|
||||
expand = False
|
||||
@@ -306,4 +305,4 @@ def staging_file_delete(request, source_type, source_id, staging_file_id):
|
||||
'next': next,
|
||||
'previous': previous,
|
||||
'form_icon': u'delete.png',
|
||||
}, context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
Reference in New Issue
Block a user