PEP8 cleanups.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.urls import resolve, reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from documents.tests.test_views import GenericDocumentViewTestCase
|
from documents.tests.test_views import GenericDocumentViewTestCase
|
||||||
from user_management.tests.literals import (
|
from user_management.tests.literals import (
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
|
|
||||||
from kombu import Exchange, Queue
|
from kombu import Exchange, Queue
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from django_downloadview import (
|
|||||||
)
|
)
|
||||||
from pure_pagination.mixins import PaginationMixin
|
from pure_pagination.mixins import PaginationMixin
|
||||||
|
|
||||||
from .forms import ChoiceForm, DynamicForm
|
from .forms import ChoiceForm
|
||||||
from .mixins import (
|
from .mixins import (
|
||||||
DeleteExtraDataMixin, DynamicFormViewMixin, ExtraContextMixin,
|
DeleteExtraDataMixin, DynamicFormViewMixin, ExtraContextMixin,
|
||||||
FormExtraKwargsMixin, MultipleObjectMixin, ObjectActionMixin,
|
FormExtraKwargsMixin, MultipleObjectMixin, ObjectActionMixin,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.core import management
|
from django.core import management
|
||||||
from django.db.utils import OperationalError
|
|
||||||
|
|
||||||
from ...signals import post_initial_setup, pre_initial_setup
|
from ...signals import post_initial_setup, pre_initial_setup
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,3 @@ class Command(management.BaseCommand):
|
|||||||
raise CommandError(
|
raise CommandError(
|
||||||
'Error during post_upgrade signal; %s' % exception
|
'Error during post_upgrade signal; %s' % exception
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,3 @@ post_initial_setup = Signal(use_caching=True)
|
|||||||
post_upgrade = Signal(use_caching=True)
|
post_upgrade = Signal(use_caching=True)
|
||||||
pre_initial_setup = Signal(use_caching=True)
|
pre_initial_setup = Signal(use_caching=True)
|
||||||
pre_upgrade = Signal(use_caching=True)
|
pre_upgrade = Signal(use_caching=True)
|
||||||
|
|
||||||
|
|||||||
@@ -19,18 +19,21 @@ class Migration(migrations.Migration):
|
|||||||
(
|
(
|
||||||
'id', models.AutoField(
|
'id', models.AutoField(
|
||||||
auto_created=True, primary_key=True, serialize=False,
|
auto_created=True, primary_key=True, serialize=False,
|
||||||
verbose_name='ID')
|
verbose_name='ID'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'datetime_added', models.DateTimeField(
|
'datetime_added', models.DateTimeField(
|
||||||
auto_now_add=True, db_index=True,
|
auto_now_add=True, db_index=True,
|
||||||
verbose_name='Added')
|
verbose_name='Added'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'document', models.ForeignKey(
|
'document', models.ForeignKey(
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
related_name='duplicates', to='documents.Document',
|
related_name='duplicates', to='documents.Document',
|
||||||
verbose_name='Document')
|
verbose_name='Document'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'documents', models.ManyToManyField(
|
'documents', models.ManyToManyField(
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ from .literals import (
|
|||||||
TEST_TRANSFORMATION_NAME, TEST_VERSION_COMMENT
|
TEST_TRANSFORMATION_NAME, TEST_VERSION_COMMENT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(OCR_AUTO_OCR=False)
|
@override_settings(OCR_AUTO_OCR=False)
|
||||||
class GenericDocumentViewTestCase(GenericViewTestCase):
|
class GenericDocumentViewTestCase(GenericViewTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -606,7 +607,7 @@ class DocumentTypeViewsTestCase(GenericDocumentViewTestCase):
|
|||||||
# Grant the document type view permission so that the post create
|
# Grant the document type view permission so that the post create
|
||||||
# redirect works
|
# redirect works
|
||||||
self.grant_permission(permission=permission_document_type_view)
|
self.grant_permission(permission=permission_document_type_view)
|
||||||
response = self._request_document_type_create()
|
self._request_document_type_create()
|
||||||
|
|
||||||
self.assertEqual(DocumentType.objects.count(), 0)
|
self.assertEqual(DocumentType.objects.count(), 0)
|
||||||
|
|
||||||
@@ -669,7 +670,7 @@ class DocumentTypeViewsTestCase(GenericDocumentViewTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_document_type_edit_view_no_permission(self):
|
def test_document_type_edit_view_no_permission(self):
|
||||||
response = self._request_document_type_edit()
|
self._request_document_type_edit()
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
DocumentType.objects.get(pk=self.document_type.pk).label,
|
DocumentType.objects.get(pk=self.document_type.pk).label,
|
||||||
@@ -781,7 +782,7 @@ class DocumentTypeViewsTestCase(GenericDocumentViewTestCase):
|
|||||||
self.grant_access(
|
self.grant_access(
|
||||||
obj=self.document_type, permission=permission_document_type_view
|
obj=self.document_type, permission=permission_document_type_view
|
||||||
)
|
)
|
||||||
response = self._request_quick_label_delete()
|
self._request_quick_label_delete()
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.document_type.filenames.count(), 1
|
self.document_type.filenames.count(), 1
|
||||||
@@ -807,6 +808,7 @@ class DocumentTypeViewsTestCase(GenericDocumentViewTestCase):
|
|||||||
self.document_type.filenames.count(), 0
|
self.document_type.filenames.count(), 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DocumentVersionTestCase(GenericDocumentViewTestCase):
|
class DocumentVersionTestCase(GenericDocumentViewTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DocumentVersionTestCase, self).setUp()
|
super(DocumentVersionTestCase, self).setUp()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from common.generics import ConfirmView, SingleObjectListView
|
|||||||
from ..models import Document, DocumentVersion
|
from ..models import Document, DocumentVersion
|
||||||
from ..permissions import (
|
from ..permissions import (
|
||||||
permission_document_download, permission_document_version_revert,
|
permission_document_download, permission_document_version_revert,
|
||||||
permission_document_version_view, permission_document_view
|
permission_document_version_view
|
||||||
)
|
)
|
||||||
|
|
||||||
from .document_views import DocumentDownloadFormView, DocumentDownloadView
|
from .document_views import DocumentDownloadFormView, DocumentDownloadView
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from .classes import SearchField, SearchModel
|
|
||||||
|
|
||||||
|
|
||||||
class SearchFieldSerializer(serializers.Serializer):
|
class SearchFieldSerializer(serializers.Serializer):
|
||||||
field = serializers.CharField(read_only=True)
|
field = serializers.CharField(read_only=True)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.html import format_html_join
|
from django.utils.html import format_html_join
|
||||||
|
|
||||||
|
|
||||||
@@ -8,7 +9,9 @@ def get_metadata_string(document):
|
|||||||
"""
|
"""
|
||||||
return format_html_join(
|
return format_html_join(
|
||||||
'\n', '<div class="metadata-display"><b>{}: </b><span data-metadata-type="{}" data-pk="{}">{}</span></div>',
|
'\n', '<div class="metadata-display"><b>{}: </b><span data-metadata-type="{}" data-pk="{}">{}</span></div>',
|
||||||
((document_metadata.metadata_type,document_metadata.metadata_type_id,document_metadata.id,document_metadata.value)
|
(
|
||||||
for document_metadata in document.metadata.all()
|
(
|
||||||
|
document_metadata.metadata_type, document_metadata.metadata_type_id, document_metadata.id, document_metadata.value
|
||||||
|
) for document_metadata in document.metadata.all()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ class Command(management.BaseCommand):
|
|||||||
allow_other=options['allow_other'],
|
allow_other=options['allow_other'],
|
||||||
allow_root=options['allow_root']
|
allow_root=options['allow_root']
|
||||||
)
|
)
|
||||||
except RuntimeError as exception:
|
except RuntimeError:
|
||||||
if options['allow_other'] or options['allow_root']:
|
if options['allow_other'] or options['allow_root']:
|
||||||
raise CommandError(
|
raise CommandError(
|
||||||
'Make sure \'user_allow_other\' is set in /etc/fuse.conf'
|
'Make sure \'user_allow_other\' is set in /etc/fuse.conf'
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.test import override_settings
|
from django.test import override_settings
|
||||||
from django.utils.encoding import force_text
|
|
||||||
|
|
||||||
from documents.tests.test_views import GenericDocumentViewTestCase
|
from documents.tests.test_views import GenericDocumentViewTestCase
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ from __future__ import unicode_literals
|
|||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import conditional_escape
|
from django.utils.html import conditional_escape
|
||||||
|
|
||||||
|
from .models import DocumentPageContent
|
||||||
|
|
||||||
|
|
||||||
def get_document_ocr_content(document):
|
def get_document_ocr_content(document):
|
||||||
for page in document.pages.all():
|
for page in document.pages.all():
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ class WritableRoleSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
model = Role
|
model = Role
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
result = validated_data.copy()
|
|
||||||
|
|
||||||
self.groups_pk_list = validated_data.pop('groups_pk_list', '')
|
self.groups_pk_list = validated_data.pop('groups_pk_list', '')
|
||||||
self.permissions_pk_list = validated_data.pop(
|
self.permissions_pk_list = validated_data.pop(
|
||||||
'permissions_pk_list', ''
|
'permissions_pk_list', ''
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ class Source(models.Model):
|
|||||||
document.delete(to_trash=False)
|
document.delete(to_trash=False)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def handle_upload(self, file_object, description=None, document_type=None, expand=False, label=None, language=None, metadata_dict_list=None, metadata_dictionary=None, user=None):
|
def handle_upload(self, file_object, description=None, document_type=None, expand=False, label=None, language=None, metadata_dict_list=None, metadata_dictionary=None, user=None):
|
||||||
if not document_type:
|
if not document_type:
|
||||||
document_type = self.document_type
|
document_type = self.document_type
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from common.utils import fs_cleanup, mkdtemp
|
|||||||
from documents.models import Document, DocumentType
|
from documents.models import Document, DocumentType
|
||||||
from documents.permissions import permission_document_create
|
from documents.permissions import permission_document_create
|
||||||
from documents.tests import (
|
from documents.tests import (
|
||||||
TEST_DOCUMENT_DESCRIPTION, TEST_SMALL_DOCUMENT_PATH, TEST_DOCUMENT_TYPE_LABEL,
|
TEST_DOCUMENT_DESCRIPTION, TEST_DOCUMENT_TYPE_LABEL,
|
||||||
TEST_SMALL_DOCUMENT_CHECKSUM, TEST_SMALL_DOCUMENT_PATH
|
TEST_SMALL_DOCUMENT_CHECKSUM, TEST_SMALL_DOCUMENT_PATH
|
||||||
)
|
)
|
||||||
from documents.tests.test_views import GenericDocumentViewTestCase
|
from documents.tests.test_views import GenericDocumentViewTestCase
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.html import escape
|
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
|||||||
Reference in New Issue
Block a user