From 84493b7a721e397f61b938d19c5b243393b1285a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 11 Nov 2014 14:58:37 -0400 Subject: [PATCH] PEP8 Cleanups --- ...to__chg_field_documentcheckout_checkout_datetime.py | 2 +- mayan/apps/common/settings.py | 1 - mayan/apps/common/views.py | 1 - mayan/apps/document_indexing/models.py | 1 - mayan/apps/document_indexing/tasks.py | 3 --- mayan/apps/document_indexing/views.py | 1 - mayan/apps/documents/__init__.py | 1 - mayan/apps/documents/managers.py | 4 ---- mayan/apps/documents/serializers.py | 1 - ...ntversion_serial__del_field_documentversion_rele.py | 5 +---- .../0024_auto__add_field_documenttype_ocr.py | 5 +---- .../0025_auto__add_field_document_language.py | 5 +---- .../0028_auto__del_field_documentversion_filename.py | 5 +---- mayan/apps/documents/tests.py | 10 +++++----- mayan/apps/documents/views.py | 5 ++++- mayan/apps/folders/api_views.py | 1 - mayan/apps/folders/south_migrations/0003_auto.py | 5 +---- .../south_migrations/0005_auto__del_folderdocument.py | 5 +---- mayan/apps/linking/managers.py | 5 +---- mayan/apps/linking/south_migrations/0001_initial.py | 4 +--- mayan/apps/linking/south_migrations/0002_auto.py | 4 +--- mayan/apps/linking/views.py | 8 ++++---- .../apps/lock_manager/south_migrations/0001_initial.py | 4 +--- mayan/apps/lock_manager/tests.py | 2 +- mayan/apps/metadata/classes.py | 4 +--- mayan/apps/ocr/api_views.py | 1 - mayan/apps/ocr/serializers.py | 2 -- ...eld_source_whitelist__del_field_source_blacklist.py | 4 +--- .../apps/sources/south_migrations/0007_set_doc_type.py | 2 -- ...ource__chg_field_intervalbasemodel_document_type.py | 2 -- .../0010_auto__add_watchfoldersource.py | 5 +---- ..._auto__del_field_intervalbasemodel_document_type.py | 6 ++---- ..._auto__add_field_intervalbasemodel_document_type.py | 2 -- mayan/apps/sources/wizards.py | 1 - 34 files changed, 30 insertions(+), 87 deletions(-) diff --git a/mayan/apps/checkouts/south_migrations/0003_auto__chg_field_documentcheckout_checkout_datetime.py b/mayan/apps/checkouts/south_migrations/0003_auto__chg_field_documentcheckout_checkout_datetime.py index b0f89c258f..8e85077c73 100644 --- a/mayan/apps/checkouts/south_migrations/0003_auto__chg_field_documentcheckout_checkout_datetime.py +++ b/mayan/apps/checkouts/south_migrations/0003_auto__chg_field_documentcheckout_checkout_datetime.py @@ -50,4 +50,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['checkouts'] \ No newline at end of file + complete_apps = ['checkouts'] diff --git a/mayan/apps/common/settings.py b/mayan/apps/common/settings.py index 263cf208ac..5a87659cf4 100644 --- a/mayan/apps/common/settings.py +++ b/mayan/apps/common/settings.py @@ -65,4 +65,3 @@ register_setting( default='storage.backends.filebasedstorage.FileBasedStorage', description=_(u'A storage backend that all workers can use to share files.'), ) - diff --git a/mayan/apps/common/views.py b/mayan/apps/common/views.py index eae4ad426f..6f18326520 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -454,7 +454,6 @@ class MultiFormView(FormView): def post(self, request, *args, **kwargs): form_classes = self.get_form_classes() - form_name = request.POST.get('action') forms = self.get_forms(form_classes) if all([form.is_valid() for form in forms.values()]): diff --git a/mayan/apps/document_indexing/models.py b/mayan/apps/document_indexing/models.py index 3cf2286200..dc7d2e6e90 100644 --- a/mayan/apps/document_indexing/models.py +++ b/mayan/apps/document_indexing/models.py @@ -9,7 +9,6 @@ from mptt.models import MPTTModel from documents.models import Document, DocumentType from .managers import IndexManager -from .settings import AVAILABLE_INDEXING_FUNCTIONS class Index(models.Model): diff --git a/mayan/apps/document_indexing/tasks.py b/mayan/apps/document_indexing/tasks.py index d555356adf..3cc7fa26ac 100644 --- a/mayan/apps/document_indexing/tasks.py +++ b/mayan/apps/document_indexing/tasks.py @@ -1,8 +1,5 @@ import logging -from django.contrib.auth.models import User -from django.core.files import File - from mayan.celery import app from documents.models import Document diff --git a/mayan/apps/document_indexing/views.py b/mayan/apps/document_indexing/views.py index c600d8f4e5..7cc319c621 100644 --- a/mayan/apps/document_indexing/views.py +++ b/mayan/apps/document_indexing/views.py @@ -1,6 +1,5 @@ from __future__ import absolute_import -from django.conf import settings from django.contrib import messages from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse diff --git a/mayan/apps/documents/__init__.py b/mayan/apps/documents/__init__.py index c4a1b9056e..17d4044b82 100644 --- a/mayan/apps/documents/__init__.py +++ b/mayan/apps/documents/__init__.py @@ -3,7 +3,6 @@ from __future__ import absolute_import import tempfile from django.utils.translation import ugettext_lazy as _ -from django.utils.translation import ugettext from acls.api import class_permissions from common.classes import ModelAttribute diff --git a/mayan/apps/documents/managers.py b/mayan/apps/documents/managers.py index 21558188bc..a90c26862f 100644 --- a/mayan/apps/documents/managers.py +++ b/mayan/apps/documents/managers.py @@ -62,7 +62,6 @@ class DocumentManager(models.Manager): @transaction.atomic def new_document(self, document_type, file_object, label, command_line=False, description=None, expand=False, language=None, user=None): versions_created = [] - is_compressed = None if expand: try: @@ -76,13 +75,10 @@ class DocumentManager(models.Manager): count += 1 except NotACompressedFile: - is_compressed = False logging.debug('Exception: NotACompressedFile') if command_line: raise versions_created.append(self.upload_single_document(document_type=document_type, file_object=file_object, description=description, label=label, language=language or LANGUAGE, user=user)) - else: - is_compressed = True else: versions_created.append(self.upload_single_document(document_type=document_type, file_object=file_object, description=description, label=label, language=language or LANGUAGE, user=user)) diff --git a/mayan/apps/documents/serializers.py b/mayan/apps/documents/serializers.py index 2972afbbb4..f95e466136 100644 --- a/mayan/apps/documents/serializers.py +++ b/mayan/apps/documents/serializers.py @@ -45,7 +45,6 @@ class DocumentTypeSerializer(serializers.ModelSerializer): class NewDocumentSerializer(serializers.Serializer): description = serializers.CharField(required=False) - document_type = DocumentTypeSerializer() document_type = serializers.ChoiceField(choices=[(document_type.pk, document_type) for document_type in DocumentType.objects.all()]) expand = serializers.BooleanField(default=False) file = serializers.FileField() diff --git a/mayan/apps/documents/south_migrations/0021_auto__del_field_documentversion_serial__del_field_documentversion_rele.py b/mayan/apps/documents/south_migrations/0021_auto__del_field_documentversion_serial__del_field_documentversion_rele.py index a4e7d6b943..c2a2b466ea 100644 --- a/mayan/apps/documents/south_migrations/0021_auto__del_field_documentversion_serial__del_field_documentversion_rele.py +++ b/mayan/apps/documents/south_migrations/0021_auto__del_field_documentversion_serial__del_field_documentversion_rele.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -20,7 +19,6 @@ class Migration(SchemaMigration): # Adding unique constraint on 'DocumentVersion', fields ['document', 'major', 'minor', 'micro'] db.create_unique(u'documents_documentversion', ['document_id', 'major', 'minor', 'micro']) - def backwards(self, orm): # Removing unique constraint on 'DocumentVersion', fields ['document', 'major', 'minor', 'micro'] db.delete_unique(u'documents_documentversion', ['document_id', 'major', 'minor', 'micro']) @@ -38,7 +36,6 @@ class Migration(SchemaMigration): # Adding unique constraint on 'DocumentVersion', fields ['document', 'major', 'minor', 'micro', 'release_level', 'serial'] db.create_unique(u'documents_documentversion', ['document_id', 'major', 'minor', 'micro', 'release_level', 'serial']) - models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -136,4 +133,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['documents'] \ No newline at end of file + complete_apps = ['documents'] diff --git a/mayan/apps/documents/south_migrations/0024_auto__add_field_documenttype_ocr.py b/mayan/apps/documents/south_migrations/0024_auto__add_field_documenttype_ocr.py index baffa55cd1..5c28237cb4 100644 --- a/mayan/apps/documents/south_migrations/0024_auto__add_field_documenttype_ocr.py +++ b/mayan/apps/documents/south_migrations/0024_auto__add_field_documenttype_ocr.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -13,12 +12,10 @@ class Migration(SchemaMigration): self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) - def backwards(self, orm): # Deleting field 'DocumentType.ocr' db.delete_column(u'documents_documenttype', 'ocr') - models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -117,4 +114,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['documents'] \ No newline at end of file + complete_apps = ['documents'] diff --git a/mayan/apps/documents/south_migrations/0025_auto__add_field_document_language.py b/mayan/apps/documents/south_migrations/0025_auto__add_field_document_language.py index a26246fe71..1ae4f6cfe8 100644 --- a/mayan/apps/documents/south_migrations/0025_auto__add_field_document_language.py +++ b/mayan/apps/documents/south_migrations/0025_auto__add_field_document_language.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -13,12 +12,10 @@ class Migration(SchemaMigration): self.gf('django.db.models.fields.CharField')(default=u'eng', max_length=8), keep_default=False) - def backwards(self, orm): # Deleting field 'Document.language' db.delete_column(u'documents_document', 'language') - models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -118,4 +115,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['documents'] \ No newline at end of file + complete_apps = ['documents'] diff --git a/mayan/apps/documents/south_migrations/0028_auto__del_field_documentversion_filename.py b/mayan/apps/documents/south_migrations/0028_auto__del_field_documentversion_filename.py index e321e0fb39..72b28e6fa2 100644 --- a/mayan/apps/documents/south_migrations/0028_auto__del_field_documentversion_filename.py +++ b/mayan/apps/documents/south_migrations/0028_auto__del_field_documentversion_filename.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -11,14 +10,12 @@ class Migration(SchemaMigration): # Deleting field 'DocumentVersion.filename' db.delete_column(u'documents_documentversion', 'filename') - def backwards(self, orm): # Adding field 'DocumentVersion.filename' db.add_column(u'documents_documentversion', 'filename', self.gf('django.db.models.fields.CharField')(default=u'', max_length=255, db_index=True), keep_default=False) - models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -118,4 +115,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['documents'] \ No newline at end of file + complete_apps = ['documents'] diff --git a/mayan/apps/documents/tests.py b/mayan/apps/documents/tests.py index f91b509473..1f4e24ab36 100644 --- a/mayan/apps/documents/tests.py +++ b/mayan/apps/documents/tests.py @@ -55,7 +55,7 @@ class DocumentTestCase(TestCase): 'version_update': VERSION_UPDATE_MAJOR, } - new_version = self.document.new_version(file_object=File(file_object), **new_version_data) + self.document.new_version(file_object=File(file_object), **new_version_data) self.failUnlessEqual(self.document.latest_version.get_formated_version(), '2.0.0') @@ -87,7 +87,7 @@ class DocumentSearchTestCase(TestCase): self.document.save() with open(TEST_DOCUMENT_PATH) as file_object: - new_version = self.document.new_version(file_object=File(file_object, name='mayan_11_1.pdf')) + self.document.new_version(file_object=File(file_object, name='mayan_11_1.pdf')) # Text extraction on the first page only parse_document_page(self.document.latest_version.pages.all()[0]) @@ -148,7 +148,7 @@ class DocumentUploadFunctionalTestCase(TestCase): self.assertTrue(self.admin_user.is_authenticated()) # Create new webform source - response = self.client.post(reverse('sources:setup_source_create', args=[SOURCE_CHOICE_WEB_FORM]), {'title': 'test', 'uncompress': 'n', 'enabled': True}) + self.client.post(reverse('sources:setup_source_create', args=[SOURCE_CHOICE_WEB_FORM]), {'title': 'test', 'uncompress': 'n', 'enabled': True}) self.assertEqual(WebFormSource.objects.count(), 1) # Upload the test document @@ -180,7 +180,7 @@ class DocumentUploadFunctionalTestCase(TestCase): self.assertTrue(self.admin_user.is_authenticated()) # Create new webform source - response = self.client.post(reverse('sources:setup_source_create', args=[SOURCE_CHOICE_WEB_FORM]), {'title': 'test', 'uncompress': 'n', 'enabled': True}) + self.client.post(reverse('sources:setup_source_create', args=[SOURCE_CHOICE_WEB_FORM]), {'title': 'test', 'uncompress': 'n', 'enabled': True}) self.assertEqual(WebFormSource.objects.count(), 1) # Upload the test document @@ -295,7 +295,7 @@ class DocumentsViewsFunctionalTestCase(TestCase): self.assertTrue(logged_in) self.assertTrue(self.admin_user.is_authenticated()) # Create new webform source - response = self.client.post(reverse('sources:setup_source_create', args=[SOURCE_CHOICE_WEB_FORM]), {'title': 'test', 'uncompress': 'n', 'enabled': True}) + self.client.post(reverse('sources:setup_source_create', args=[SOURCE_CHOICE_WEB_FORM]), {'title': 'test', 'uncompress': 'n', 'enabled': True}) self.assertEqual(WebFormSource.objects.count(), 1) # Upload the test document diff --git a/mayan/apps/documents/views.py b/mayan/apps/documents/views.py index 7449ea4f9a..28e7cf83c6 100644 --- a/mayan/apps/documents/views.py +++ b/mayan/apps/documents/views.py @@ -290,6 +290,8 @@ def document_document_type_edit(request, document_id=None, document_id_list=None context = { 'form': form, 'submit_label': _('Submit'), + 'previous': previous, + 'next': next, } if len(documents) == 1: @@ -463,7 +465,8 @@ def document_update_page_count(request, document_id=None, document_id_list=None) for document in documents: task_update_page_count.apply_async(kwargs={'version_id': document.latest_version.pk}, queue='tools') - messages.success(request, + messages.success( + request, ungettext( _(u'Document queued for page count reset.'), _(u'Documents queued for page count reset.'), diff --git a/mayan/apps/folders/api_views.py b/mayan/apps/folders/api_views.py index 58b5a02c6b..e1b03e3a1b 100644 --- a/mayan/apps/folders/api_views.py +++ b/mayan/apps/folders/api_views.py @@ -40,7 +40,6 @@ class APIFolderListView(generics.ListCreateAPIView): return super(APIFolderListView, self).post(*args, **kwargs) def create(self, request, *args, **kwargs): - data = request.DATA serializer = self.get_serializer(data=request.DATA, files=request.FILES) if serializer.is_valid(): diff --git a/mayan/apps/folders/south_migrations/0003_auto.py b/mayan/apps/folders/south_migrations/0003_auto.py index 843ff683e1..89eff37278 100644 --- a/mayan/apps/folders/south_migrations/0003_auto.py +++ b/mayan/apps/folders/south_migrations/0003_auto.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -17,12 +16,10 @@ class Migration(SchemaMigration): )) db.create_unique(m2m_table_name, ['folder_id', 'document_id']) - def backwards(self, orm): # Removing M2M table for field documents on 'Folder' db.delete_table(db.shorten_name(u'folders_folder_documents')) - models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -89,4 +86,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['folders'] \ No newline at end of file + complete_apps = ['folders'] diff --git a/mayan/apps/folders/south_migrations/0005_auto__del_folderdocument.py b/mayan/apps/folders/south_migrations/0005_auto__del_folderdocument.py index 28f51df875..38cfb44e84 100644 --- a/mayan/apps/folders/south_migrations/0005_auto__del_folderdocument.py +++ b/mayan/apps/folders/south_migrations/0005_auto__del_folderdocument.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -11,7 +10,6 @@ class Migration(SchemaMigration): # Deleting model 'FolderDocument' db.delete_table(u'folders_folderdocument') - def backwards(self, orm): # Adding model 'FolderDocument' db.create_table(u'folders_folderdocument', ( @@ -21,7 +19,6 @@ class Migration(SchemaMigration): )) db.send_create_signal(u'folders', ['FolderDocument']) - models = { u'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -82,4 +79,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['folders'] \ No newline at end of file + complete_apps = ['folders'] diff --git a/mayan/apps/linking/managers.py b/mayan/apps/linking/managers.py index 46d6abd21f..57836f7bd0 100644 --- a/mayan/apps/linking/managers.py +++ b/mayan/apps/linking/managers.py @@ -12,14 +12,11 @@ class SmartLinkManager(models.Manager): def get_for(self, document, smart_link_obj=None): errors = [] result = {} - metadata_dict = {} - for document_metadata in document.document_metadata.all(): - metadata_dict[document_metadata.metadata_type.name] = document_metadata.value smart_link_qs = self.model.objects.filter(enabled=True) if smart_link_obj: - smart_link_qs= smart_link_qs.filter(pk=smart_link_obj.pk) + smart_link_qs = smart_link_qs.filter(pk=smart_link_obj.pk) smart_link_qs = smart_link_qs.filter(document_types=document.document_type) diff --git a/mayan/apps/linking/south_migrations/0001_initial.py b/mayan/apps/linking/south_migrations/0001_initial.py index eb981ad3f1..d92d8dd97c 100644 --- a/mayan/apps/linking/south_migrations/0001_initial.py +++ b/mayan/apps/linking/south_migrations/0001_initial.py @@ -30,7 +30,6 @@ class Migration(SchemaMigration): )) db.send_create_signal(u'linking', ['SmartLinkCondition']) - def backwards(self, orm): # Deleting model 'SmartLink' db.delete_table(u'linking_smartlink') @@ -38,7 +37,6 @@ class Migration(SchemaMigration): # Deleting model 'SmartLinkCondition' db.delete_table(u'linking_smartlinkcondition') - models = { u'linking.smartlink': { 'Meta': {'object_name': 'SmartLink'}, @@ -60,4 +58,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['linking'] \ No newline at end of file + complete_apps = ['linking'] diff --git a/mayan/apps/linking/south_migrations/0002_auto.py b/mayan/apps/linking/south_migrations/0002_auto.py index 13d03540e1..d52e724ed0 100644 --- a/mayan/apps/linking/south_migrations/0002_auto.py +++ b/mayan/apps/linking/south_migrations/0002_auto.py @@ -17,12 +17,10 @@ class Migration(SchemaMigration): )) db.create_unique(m2m_table_name, ['smartlink_id', 'documenttype_id']) - def backwards(self, orm): # Removing M2M table for field document_types on 'SmartLink' db.delete_table(db.shorten_name(u'linking_smartlink_document_types')) - models = { u'documents.documenttype': { 'Meta': {'ordering': "['name']", 'object_name': 'DocumentType'}, @@ -51,4 +49,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['linking'] \ No newline at end of file + complete_apps = ['linking'] diff --git a/mayan/apps/linking/views.py b/mayan/apps/linking/views.py index a9141514e0..f9d4ad2f92 100644 --- a/mayan/apps/linking/views.py +++ b/mayan/apps/linking/views.py @@ -269,7 +269,7 @@ def smart_link_condition_create(request, smart_link_pk): AccessEntry.objects.check_accesses([PERMISSION_SMART_LINK_CREATE, PERMISSION_SMART_LINK_EDIT], request.user, smart_link) if request.method == 'POST': - form = SmartLinkConditionForm(data=request.POST, smart_link=smart_link) + form = SmartLinkConditionForm(data=request.POST) if form.is_valid(): new_smart_link_condition = form.save(commit=False) new_smart_link_condition.smart_link = smart_link @@ -277,7 +277,7 @@ def smart_link_condition_create(request, smart_link_pk): messages.success(request, _(u'Smart link condition: "%s" created successfully.') % new_smart_link_condition) return HttpResponseRedirect(reverse('linking:smart_link_condition_list', args=[smart_link.pk])) else: - form = SmartLinkConditionForm(smart_link=smart_link) + form = SmartLinkConditionForm() return render_to_response('main/generic_form.html', { 'form': form, @@ -298,13 +298,13 @@ def smart_link_condition_edit(request, smart_link_condition_pk): previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', reverse('main:home')))) if request.method == 'POST': - form = SmartLinkConditionForm(request.POST, smart_link=smart_link_condition.smart_link, instance=smart_link_condition) + form = SmartLinkConditionForm(request.POST, instance=smart_link_condition) if form.is_valid(): smart_link_condition = form.save() messages.success(request, _(u'Smart link condition: "%s" edited successfully.') % smart_link_condition) return HttpResponseRedirect(next) else: - form = SmartLinkConditionForm(smart_link=smart_link_condition.smart_link, instance=smart_link_condition) + form = SmartLinkConditionForm(instance=smart_link_condition) return render_to_response('main/generic_form.html', { 'form': form, diff --git a/mayan/apps/lock_manager/south_migrations/0001_initial.py b/mayan/apps/lock_manager/south_migrations/0001_initial.py index 087b90d702..736c3a76fe 100644 --- a/mayan/apps/lock_manager/south_migrations/0001_initial.py +++ b/mayan/apps/lock_manager/south_migrations/0001_initial.py @@ -17,12 +17,10 @@ class Migration(SchemaMigration): )) db.send_create_signal(u'lock_manager', ['Lock']) - def backwards(self, orm): # Deleting model 'Lock' db.delete_table(u'lock_manager_lock') - models = { u'lock_manager.lock': { 'Meta': {'object_name': 'Lock'}, @@ -33,4 +31,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['lock_manager'] \ No newline at end of file + complete_apps = ['lock_manager'] diff --git a/mayan/apps/lock_manager/tests.py b/mayan/apps/lock_manager/tests.py index 892daded54..96ec3491e4 100644 --- a/mayan/apps/lock_manager/tests.py +++ b/mayan/apps/lock_manager/tests.py @@ -30,7 +30,7 @@ class LockTestCase(TestCase): lock_2.release() def test_timeout_expired(self): - lock_1 = Lock.objects.acquire_lock(name='test_lock_1', timeout=1) + Lock.objects.acquire_lock(name='test_lock_1', timeout=1) # lock_1 not release and not expired, should raise LockError with self.assertRaises(LockError): diff --git a/mayan/apps/metadata/classes.py b/mayan/apps/metadata/classes.py index 910fc92e33..12de37df19 100644 --- a/mayan/apps/metadata/classes.py +++ b/mayan/apps/metadata/classes.py @@ -1,8 +1,6 @@ from django.utils.translation import ugettext_lazy as _ -from acls.classes import EncapsulatedObject - -from .models import DocumentMetadata, DocumentTypeMetadataType, MetadataType +from .models import DocumentTypeMetadataType, MetadataType class DocumentTypeMetadataTypeHelper(object): diff --git a/mayan/apps/ocr/api_views.py b/mayan/apps/ocr/api_views.py index 5f53536f99..220339e54f 100644 --- a/mayan/apps/ocr/api_views.py +++ b/mayan/apps/ocr/api_views.py @@ -10,7 +10,6 @@ from rest_framework.settings import api_settings from acls.models import AccessEntry from documents.models import Document from permissions.models import Permission -from rest_api.filters import MayanObjectPermissionsFilter from rest_api.permissions import MayanPermission from .permissions import PERMISSION_OCR_DOCUMENT diff --git a/mayan/apps/ocr/serializers.py b/mayan/apps/ocr/serializers.py index 1062adb850..c38fb42f7c 100644 --- a/mayan/apps/ocr/serializers.py +++ b/mayan/apps/ocr/serializers.py @@ -2,8 +2,6 @@ from __future__ import absolute_import from rest_framework import serializers -from .models import Document - class DocumentOCRSerializer(serializers.Serializer): document_id = serializers.IntegerField() diff --git a/mayan/apps/sources/south_migrations/0006_auto__del_field_source_whitelist__del_field_source_blacklist.py b/mayan/apps/sources/south_migrations/0006_auto__del_field_source_whitelist__del_field_source_blacklist.py index 969e4a35a0..2f9ba2d458 100644 --- a/mayan/apps/sources/south_migrations/0006_auto__del_field_source_whitelist__del_field_source_blacklist.py +++ b/mayan/apps/sources/south_migrations/0006_auto__del_field_source_whitelist__del_field_source_blacklist.py @@ -14,7 +14,6 @@ class Migration(SchemaMigration): # Deleting field 'Source.blacklist' db.delete_column(u'sources_source', 'blacklist') - def backwards(self, orm): # Adding field 'Source.whitelist' db.add_column(u'sources_source', 'whitelist', @@ -26,7 +25,6 @@ class Migration(SchemaMigration): self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False) - models = { u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, @@ -113,4 +111,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['sources'] \ No newline at end of file + complete_apps = ['sources'] diff --git a/mayan/apps/sources/south_migrations/0007_set_doc_type.py b/mayan/apps/sources/south_migrations/0007_set_doc_type.py index a75f6a4606..dfc681b1cb 100644 --- a/mayan/apps/sources/south_migrations/0007_set_doc_type.py +++ b/mayan/apps/sources/south_migrations/0007_set_doc_type.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db from south.v2 import DataMigration from django.db import models diff --git a/mayan/apps/sources/south_migrations/0009_auto__del_watchfoldersource__chg_field_intervalbasemodel_document_type.py b/mayan/apps/sources/south_migrations/0009_auto__del_watchfoldersource__chg_field_intervalbasemodel_document_type.py index a5b9a76ff5..becfb1aced 100644 --- a/mayan/apps/sources/south_migrations/0009_auto__del_watchfoldersource__chg_field_intervalbasemodel_document_type.py +++ b/mayan/apps/sources/south_migrations/0009_auto__del_watchfoldersource__chg_field_intervalbasemodel_document_type.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -37,7 +36,6 @@ class Migration(SchemaMigration): )) db.send_create_signal(u'sources', ['WatchFolderSource']) - # Changing field 'IntervalBaseModel.document_type' db.alter_column(u'sources_intervalbasemodel', 'document_type_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['documents.DocumentType'], null=True)) diff --git a/mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py b/mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py index ef38125094..ef672ac485 100644 --- a/mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py +++ b/mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -16,12 +15,10 @@ class Migration(SchemaMigration): )) db.send_create_signal(u'sources', ['WatchFolderSource']) - def backwards(self, orm): # Deleting model 'WatchFolderSource' db.delete_table(u'sources_watchfoldersource') - models = { u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, @@ -107,4 +104,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['sources'] \ No newline at end of file + complete_apps = ['sources'] diff --git a/mayan/apps/sources/south_migrations/0011_auto__del_field_intervalbasemodel_document_type.py b/mayan/apps/sources/south_migrations/0011_auto__del_field_intervalbasemodel_document_type.py index 0ad00f653b..12aec323f9 100644 --- a/mayan/apps/sources/south_migrations/0011_auto__del_field_intervalbasemodel_document_type.py +++ b/mayan/apps/sources/south_migrations/0011_auto__del_field_intervalbasemodel_document_type.py @@ -11,18 +11,16 @@ class Migration(SchemaMigration): # Deleting field 'IntervalBaseModel.document_type' db.delete_column(u'sources_intervalbasemodel', 'document_type_id') - def backwards(self, orm): # User chose to not deal with backwards NULL issues for 'IntervalBaseModel.document_type' raise RuntimeError("Cannot reverse this migration. 'IntervalBaseModel.document_type' and its values cannot be restored.") - + # The following code is provided here to aid in writing a correct migration # Adding field 'IntervalBaseModel.document_type' db.add_column(u'sources_intervalbasemodel', 'document_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['documents.DocumentType']), keep_default=False) - models = { u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, @@ -101,4 +99,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['sources'] \ No newline at end of file + complete_apps = ['sources'] diff --git a/mayan/apps/sources/south_migrations/0012_auto__add_field_intervalbasemodel_document_type.py b/mayan/apps/sources/south_migrations/0012_auto__add_field_intervalbasemodel_document_type.py index 7d95fd6e3a..87f8e73200 100644 --- a/mayan/apps/sources/south_migrations/0012_auto__add_field_intervalbasemodel_document_type.py +++ b/mayan/apps/sources/south_migrations/0012_auto__add_field_intervalbasemodel_document_type.py @@ -13,12 +13,10 @@ class Migration(SchemaMigration): self.gf('django.db.models.fields.related.ForeignKey')(to=orm['documents.DocumentType'], null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'IntervalBaseModel.document_type' db.delete_column(u'sources_intervalbasemodel', 'document_type_id') - models = { u'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, diff --git a/mayan/apps/sources/wizards.py b/mayan/apps/sources/wizards.py index 54e2d93189..9f168a1ddc 100644 --- a/mayan/apps/sources/wizards.py +++ b/mayan/apps/sources/wizards.py @@ -60,7 +60,6 @@ class DocumentCreateWizard(MayanPermissionCheckMixin, SessionWizardView): 'metadata_type': metadata_type, }) - return initial return self.initial_dict.get(step, {})