From 460570ed051d058f451171ba2b6c87cb4487f5d8 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 7 Jun 2018 20:58:50 -0400 Subject: [PATCH] Don't provide a default for the scanner source adf_mode. Some scanners throw an error even when the selection if supported. Signed-off-by: Roberto Rosario --- HISTORY.rst | 3 +- docs/releases/3.0.rst | 2 + .../migrations/0018_auto_20180608_0057.py | 20 ++++++ mayan/apps/sources/models.py | 2 +- mayan/apps/sources/tests/test_models.py | 67 ------------------- 5 files changed, 25 insertions(+), 69 deletions(-) create mode 100644 mayan/apps/sources/migrations/0018_auto_20180608_0057.py diff --git a/HISTORY.rst b/HISTORY.rst index 30d96d0f3d..8512a1b6ce 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -173,7 +173,8 @@ - Fix error when trying to upload a document from and email account with 'from' and 'subject' metadata. - Fix typo on message.header get from 'Suject' to 'Subject'. - On multi part emails keep the original From and Subject properties for all subsequent parts if the sub parts don't specify them. Fixes issue #481. Thanks to Robert Schöftner @robert.schoeftner for the report and debug information. - +- Don't provide a default for the scanner source adf_mode. Some scanners throw an error even when the selection + if supported. 2.7.3 (2017-09-11) diff --git a/docs/releases/3.0.rst b/docs/releases/3.0.rst index aa531e1f86..326b3e066c 100644 --- a/docs/releases/3.0.rst +++ b/docs/releases/3.0.rst @@ -519,6 +519,8 @@ Other changes worth mentioning - Fix error when trying to upload a document from and email account with 'from' and 'subject' metadata. - Fix typo on message.header get from 'Suject' to 'Subject'. - On multi part emails keep the original From and Subject properties for all subsequent parts if the sub parts don't specify them. Fixes issue #481. Thanks to Robert Schöftner @robert.schoeftner for the report and debug information. +- Don't provide a default for the scanner source adf_mode. Some scanners throw an error even when the selection + if supported. Removals -------- diff --git a/mayan/apps/sources/migrations/0018_auto_20180608_0057.py b/mayan/apps/sources/migrations/0018_auto_20180608_0057.py new file mode 100644 index 0000000000..a0f50f920c --- /dev/null +++ b/mayan/apps/sources/migrations/0018_auto_20180608_0057.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.11 on 2018-06-08 00:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sources', '0017_auto_20180510_2151'), + ] + + operations = [ + migrations.AlterField( + model_name='sanescanner', + name='adf_mode', + field=models.CharField(blank=True, choices=[('simplex', 'Simplex'), ('duplex', 'Duplex')], help_text='Selects the document feeder mode (simplex/duplex). If this option is not supported by your scanner, leave it blank.', max_length=16, verbose_name='ADF mode'), + ), + ] diff --git a/mayan/apps/sources/models.py b/mayan/apps/sources/models.py index 8fe8f78078..5d37262576 100644 --- a/mayan/apps/sources/models.py +++ b/mayan/apps/sources/models.py @@ -207,7 +207,7 @@ class SaneScanner(InteractiveSource): ) adf_mode = models.CharField( blank=True, choices=SCANNER_ADF_MODE_CHOICES, - default=SCANNER_ADF_MODE_SIMPLEX, help_text=_( + help_text=_( 'Selects the document feeder mode (simplex/duplex). If this ' 'option is not supported by your scanner, leave it blank.' ), max_length=16, verbose_name=_('ADF mode') diff --git a/mayan/apps/sources/tests/test_models.py b/mayan/apps/sources/tests/test_models.py index 66ed8a8e27..05e8b11279 100644 --- a/mayan/apps/sources/tests/test_models.py +++ b/mayan/apps/sources/tests/test_models.py @@ -161,73 +161,6 @@ class EmailFilenameDecodingTestCase(BaseTestCase): ) -@override_settings(OCR_AUTO_OCR=False) -class IMAPSourceTestCase(BaseTestCase): - class MockIMAP4_SSL(object): - #def dele(self, which): - # return - - #def getwelcome(self): - # return - - #def list(self, which=None): - # return (None, ['1 test']) - - #def pass_(self, password): - # return - - #def quit(self): - # return - - #def retr(self, which=None): - # return ( - # 1, [TEST_EMAIL_BASE64_FILENAME] - # ) - - def fetch(self, message_set, message_parts): - return 'STATUS', '(1 BODY[{}])'.format(TEST_EMAIL_ATTACHMENT_AND_INLINE) - #status, data = mailbox.fetch(message_number, '(RFC822)') - #EmailBaseModel.process_message( - # source=self, message_text=data[0][1] - #) - #mailbox.store(message_number, '+FLAGS', '\\Deleted') - - def login(self, username, password): - return - - def search(self, charset, *criterion): - return (None, ['1']) - - def select(self, mailbox): - return - - def user(self, username): - return - - def setUp(self): - super(IMAPSourceTestCase, self).setUp() - self.document_type = DocumentType.objects.create( - label=TEST_DOCUMENT_TYPE_LABEL - ) - - def tearDown(self): - self.document_type.delete() - super(IMAPSourceTestCase, self).tearDown() - - @mock.patch('imaplib.IMAP4_SSL') - def test_download_document(self, mock_imaplib): - mock_imaplib.return_value = IMAPSourceTestCase.MockIMAP4_SSL() - self.source = IMAPEmail.objects.create( - document_type=self.document_type, label='', host='', password='', - username='' - ) - - self.source.check_source() - self.assertEqual( - Document.objects.first().label, 'Ampelm\xe4nnchen.txt' - ) - - @override_settings(OCR_AUTO_OCR=False) class POP3SourceTestCase(BaseTestCase): class MockMailbox(object):