PEP8 cleanup, unused import removal
This commit is contained in:
@@ -35,8 +35,8 @@ class SplitHiddenDeltaWidget(forms.widgets.SplitDateTimeWidget):
|
||||
"""
|
||||
is_hidden = True
|
||||
|
||||
def __init__(self, attrs=None):
|
||||
super(SplitHiddenDeltaWidget, self).__init__(attrs, date_format, time_format)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SplitHiddenDeltaWidget, self).__init__(*args, **kwargs)
|
||||
for widget in self.widgets:
|
||||
widget.input_type = 'hidden'
|
||||
widget.is_hidden = True
|
||||
|
||||
@@ -11,8 +11,7 @@ from common.forms import DetailForm
|
||||
from common.widgets import TextAreaDiv
|
||||
|
||||
from .models import (Document, DocumentType, DocumentPage,
|
||||
DocumentPageTransformation, DocumentTypeFilename,
|
||||
DocumentVersion)
|
||||
DocumentPageTransformation, DocumentTypeFilename)
|
||||
from .literals import DEFAULT_ZIP_FILENAME
|
||||
from .widgets import DocumentPagesCarouselWidget, DocumentPageImageWidget
|
||||
|
||||
|
||||
@@ -12,4 +12,3 @@ VERSION_UPDATE_MICRO = u'micro'
|
||||
DEFAULT_ZIP_FILENAME = u'document_bundle.zip'
|
||||
|
||||
LANGUAGE_CHOICES = [(i.bibliographic, i.name) for i in list(pycountry.languages)]
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ def task_new_document(document_type_id, shared_uploaded_file_id, label, descript
|
||||
user = None
|
||||
|
||||
with File(file=shared_uploaded_file.file) as file_object:
|
||||
new_version = Document.objects.new_document(document_type=document_type, expand=expand, file_object=file_object, label=label, description=description, language=language, user=user)
|
||||
Document.objects.new_document(document_type=document_type, expand=expand, file_object=file_object, label=label, description=description, language=language, user=user)
|
||||
|
||||
shared_uploaded_file.delete()
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class DocumentUploadFunctionalTestCase(TestCase):
|
||||
self.failUnlessEqual(self.document.page_count, 47)
|
||||
|
||||
# Delete the document
|
||||
response = self.client.post(reverse('documents:document_delete', args=[self.document.pk]))
|
||||
self.client.post(reverse('documents:document_delete', args=[self.document.pk]))
|
||||
self.assertEqual(Document.objects.count(), 0)
|
||||
|
||||
def test_issue_25(self):
|
||||
@@ -198,7 +198,7 @@ class DocumentUploadFunctionalTestCase(TestCase):
|
||||
self.failUnlessEqual(document.description, '')
|
||||
|
||||
# Test for issue 25 during editing
|
||||
response = self.client.post(reverse('documents:document_edit', args=[document.pk]), {'description': TEST_DOCUMENT_DESCRIPTION})
|
||||
self.client.post(reverse('documents:document_edit', args=[document.pk]), {'description': TEST_DOCUMENT_DESCRIPTION})
|
||||
# Fetch document again and test description
|
||||
document = Document.objects.all().first()
|
||||
self.failUnlessEqual(document.description, TEST_DOCUMENT_DESCRIPTION)
|
||||
@@ -300,7 +300,7 @@ class DocumentsViewsFunctionalTestCase(TestCase):
|
||||
|
||||
# Upload the test document
|
||||
with open(TEST_SMALL_DOCUMENT_PATH) as file_descriptor:
|
||||
response = self.client.post(reverse('sources:upload_interactive'), {'file': file_descriptor, 'document_type_id': self.document_type.pk})
|
||||
self.client.post(reverse('sources:upload_interactive'), {'file': file_descriptor, 'document_type_id': self.document_type.pk})
|
||||
self.assertEqual(Document.objects.count(), 1)
|
||||
self.document = Document.objects.first()
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import urlparse
|
||||
|
||||
@@ -18,13 +17,11 @@ import sendfile
|
||||
|
||||
from acls.models import AccessEntry
|
||||
from common.compressed_files import CompressedFile
|
||||
from common.utils import (encapsulate, pretty_size, parse_range, return_diff,
|
||||
urlquote)
|
||||
from common.utils import encapsulate, pretty_size, parse_range, urlquote
|
||||
from common.views import SingleObjectListView
|
||||
from common.widgets import two_state_template
|
||||
from converter.literals import (DEFAULT_FILE_FORMAT_MIMETYPE, DEFAULT_PAGE_NUMBER,
|
||||
DEFAULT_ROTATION, DEFAULT_ZOOM_LEVEL)
|
||||
from converter.office_converter import OfficeConverter
|
||||
from filetransfers.api import serve_file
|
||||
from history.api import create_history
|
||||
from navigation.utils import resolve_to_name
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_links, register_top_menu
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import absolute_import
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import DocumentMetadata, MetadataType
|
||||
from .models import MetadataType
|
||||
|
||||
|
||||
class MetadataTypeAdmin(admin.ModelAdmin):
|
||||
|
||||
@@ -43,7 +43,7 @@ class DocumentTypeMetadataTypeManager(object):
|
||||
return MetadataType.objects.none()
|
||||
|
||||
def add(self, metadata_type, required=False):
|
||||
DocumentTypeMetadataType.objects.create(document_type=self.document_type, metadata_type= metadata_type, required=required)
|
||||
DocumentTypeMetadataType.objects.create(document_type=self.document_type, metadata_type=metadata_type, required=required)
|
||||
|
||||
def remove(self, metadata_type):
|
||||
DocumentTypeMetadataType.objects.get(document_type=self.document_type, metadata_type= metadata_type).delete()
|
||||
DocumentTypeMetadataType.objects.get(document_type=self.document_type, metadata_type=metadata_type).delete()
|
||||
|
||||
@@ -71,7 +71,7 @@ class AddMetadataForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
document_type = kwargs.pop('document_type')
|
||||
super(AddMetadataForm, self).__init__(*args, **kwargs)
|
||||
self.fields['metadata_type'].queryset=document_type.metadata_type.all()
|
||||
self.fields['metadata_type'].queryset = document_type.metadata_type.all()
|
||||
|
||||
metadata_type = forms.ModelChoiceField(queryset=MetadataType.objects.all(), label=_(u'Metadata type'))
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ from common.utils import encapsulate, generate_choices_w_labels
|
||||
from common.views import assign_remove
|
||||
|
||||
from .api import save_metadata_list
|
||||
from .classes import MetadataObjectWrapper
|
||||
from .forms import (AddMetadataForm, MetadataFormSet, MetadataRemoveFormSet,
|
||||
MetadataTypeForm)
|
||||
from .models import DocumentMetadata, MetadataType
|
||||
|
||||
@@ -2,7 +2,6 @@ from __future__ import absolute_import
|
||||
|
||||
import inspect
|
||||
import logging
|
||||
import re
|
||||
import urllib
|
||||
import urlparse
|
||||
|
||||
@@ -257,7 +256,7 @@ class Link(object):
|
||||
args = []
|
||||
kwargs = {}
|
||||
|
||||
if type(src_args) == type([]):
|
||||
if isinstance(src_args, list):
|
||||
for i in src_args:
|
||||
try:
|
||||
# Try to execute as a function
|
||||
@@ -268,7 +267,7 @@ class Link(object):
|
||||
args.append(val)
|
||||
else:
|
||||
args.append(val)
|
||||
elif type(src_args) == type({}):
|
||||
elif isinstance(src_args, dict):
|
||||
for key, value in src_args.items():
|
||||
try:
|
||||
# Try to execute as a function
|
||||
|
||||
@@ -112,7 +112,7 @@ def clean_pages():
|
||||
"""
|
||||
for page in DocumentPage.objects.all():
|
||||
if page.content:
|
||||
page.content = ocr_cleanup(document.language, page.content)
|
||||
page.content = ocr_cleanup(page.document.language, page.content)
|
||||
page.save()
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from . import setup_link
|
||||
|
||||
setup_items = []
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from . import tool_link
|
||||
|
||||
tool_items = []
|
||||
|
||||
|
||||
|
||||
@@ -31,5 +31,4 @@ def form_view(request):
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'title': _(u'Registration form'),
|
||||
'form': form,
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from project_tools.api import register_tool
|
||||
|
||||
from .classes import APIEndPoint
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import include, patterns, url
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
from common.utils import load_backend
|
||||
|
||||
@@ -25,7 +24,7 @@ class APIEndPoint(object):
|
||||
self.endpoints = []
|
||||
try:
|
||||
api_urls = load_backend('{}.urls.api_urls'.format(app_name or name))
|
||||
except Exception as exception:
|
||||
except Exception:
|
||||
# Ignore import time errors
|
||||
pass
|
||||
else:
|
||||
|
||||
@@ -53,8 +53,6 @@ class APIAppView(generics.GenericAPIView):
|
||||
serializer_class = APIAppSerializer
|
||||
|
||||
def get(self, request, app_name, format=None):
|
||||
result = []
|
||||
|
||||
api_app = APIEndPoint.get(app_name)
|
||||
|
||||
return Response({
|
||||
|
||||
@@ -13,7 +13,7 @@ from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files import File
|
||||
from django.db import models, transaction
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from model_utils.managers import InheritanceManager
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.core.files import File
|
||||
from mayan.celery import app
|
||||
|
||||
from common.models import SharedUploadedFile
|
||||
from documents.models import Document, DocumentType
|
||||
from documents.models import DocumentType
|
||||
|
||||
from .models import Source
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import tempfile
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import PermissionDenied
|
||||
@@ -10,7 +8,6 @@ from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.template import RequestContext
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls.models import AccessEntry
|
||||
@@ -20,7 +17,7 @@ from common.views import MultiFormView
|
||||
from documents.models import DocumentType, Document
|
||||
from documents.permissions import (PERMISSION_DOCUMENT_CREATE,
|
||||
PERMISSION_DOCUMENT_NEW_VERSION)
|
||||
from documents.tasks import task_new_document, task_upload_new_version
|
||||
from documents.tasks import task_upload_new_version
|
||||
from metadata.api import decode_metadata_from_url, metadata_repr_as_list
|
||||
from permissions.models import Permission
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.files.base import File
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.contrib.auth.models import User, Group
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_links
|
||||
from navigation.links import link_spacer
|
||||
|
||||
Reference in New Issue
Block a user