diff --git a/mayan/apps/sources/__init__.py b/mayan/apps/sources/__init__.py index cf42aadcb4..cc6be3a96c 100644 --- a/mayan/apps/sources/__init__.py +++ b/mayan/apps/sources/__init__.py @@ -12,6 +12,7 @@ from .classes import StagingFile from .links import (document_create_multiple, document_create_siblings, setup_sources, setup_source_create_imap_email, setup_source_create_pop3_email, + setup_source_create_watch_folder, setup_source_create_webform, setup_source_create_staging_folder, setup_source_delete, setup_source_edit, @@ -26,7 +27,7 @@ from .widgets import staging_file_thumbnail register_links([StagingFile], [staging_file_delete]) -register_links([Source, 'sources:setup_source_list', 'sources:setup_source_create'], [setup_sources, setup_source_create_webform, setup_source_create_staging_folder, setup_source_create_pop3_email, setup_source_create_imap_email], menu_name='secondary_menu') +register_links([Source, 'sources:setup_source_list', 'sources:setup_source_create'], [setup_sources, setup_source_create_webform, setup_source_create_staging_folder, setup_source_create_pop3_email, setup_source_create_imap_email, setup_source_create_watch_folder], menu_name='secondary_menu') register_links([Source], [setup_source_edit, setup_source_transformation_list, setup_source_delete]) register_links(SourceTransformation, [setup_source_transformation_edit, setup_source_transformation_delete]) diff --git a/mayan/apps/sources/links.py b/mayan/apps/sources/links.py index 70bff98aad..b8005018a2 100644 --- a/mayan/apps/sources/links.py +++ b/mayan/apps/sources/links.py @@ -20,10 +20,10 @@ staging_file_delete = {'text': _(u'Delete'), 'view': 'sources:staging_file_delet setup_sources = {'text': _(u'Sources'), 'view': 'sources:setup_source_list', 'famfam': 'application_form', 'icon': 'application_form.png', 'permissions': [PERMISSION_SOURCES_SETUP_VIEW], 'children_view_regex': [r'setup_web_form', r'setup_staging_folder', r'setup_source_']} setup_source_create_webform = {'text': _(u'Add new webform source'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WEB_FORM, 'famfam': 'application_form_add', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WEB_FORM and 'source' not in context} -setup_source_create_staging_folder = {'text': _(u'Add new staging folders'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_STAGING, 'famfam': 'folder_camera', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_STAGING and 'source' not in context} -setup_source_create_watch_folder_list = {'text': _(u'Add new watch folders'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WATCH, 'famfam': 'folder_magnify', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WATCH and 'source' not in context} -setup_source_create_pop3_email = {'text': _(u'Add new POP3 emails'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_POP3, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_POP3 and 'source' not in context} -setup_source_create_imap_email = {'text': _(u'Add new IMAP emails'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_IMAP, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_IMAP and 'source' not in context} +setup_source_create_staging_folder = {'text': _(u'Add new staging folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_STAGING, 'famfam': 'folder_camera', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_STAGING and 'source' not in context} +setup_source_create_watch_folder = {'text': _(u'Add new watch folder'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_WATCH, 'famfam': 'folder_magnify', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_WATCH and 'source' not in context} +setup_source_create_pop3_email = {'text': _(u'Add new POP3 email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_POP3, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_POP3 and 'source' not in context} +setup_source_create_imap_email = {'text': _(u'Add new IMAP email'), 'view': 'sources:setup_source_create', 'args': '"%s"' % SOURCE_CHOICE_EMAIL_IMAP, 'famfam': 'email', 'permissions': [PERMISSION_SOURCES_SETUP_CREATE], 'conditional_highlight': lambda context: context.get('source_type') == SOURCE_CHOICE_EMAIL_IMAP and 'source' not in context} setup_source_delete = {'text': _(u'Delete'), 'view': 'sources:setup_source_delete', 'args': ['source.pk'], 'famfam': 'application_form_delete', 'permissions': [PERMISSION_SOURCES_SETUP_DELETE]} setup_source_edit = {'text': _(u'Edit'), 'view': 'sources:setup_source_edit', 'args': ['source.pk'], 'famfam': 'application_form_edit', 'permissions': [PERMISSION_SOURCES_SETUP_EDIT]} diff --git a/mayan/apps/sources/literals.py b/mayan/apps/sources/literals.py index 69acc4af6b..eb69ed826d 100644 --- a/mayan/apps/sources/literals.py +++ b/mayan/apps/sources/literals.py @@ -23,8 +23,8 @@ SOURCE_CHOICE_EMAIL_IMAP = 'imap' SOURCE_CHOICES = ( (SOURCE_CHOICE_WEB_FORM, _(u'Web form')), - (SOURCE_CHOICE_STAGING, _(u'Server staging folder')), - (SOURCE_CHOICE_WATCH, _(u'Server watch folder')), + (SOURCE_CHOICE_STAGING, _(u'Staging folder')), + (SOURCE_CHOICE_WATCH, _(u'Watch folder')), (SOURCE_CHOICE_EMAIL_POP3, _(u'POP3 email')), (SOURCE_CHOICE_EMAIL_IMAP, _(u'IMAP email')), ) diff --git a/mayan/apps/sources/models.py b/mayan/apps/sources/models.py index 7dfa63aacd..46eaf86b67 100644 --- a/mayan/apps/sources/models.py +++ b/mayan/apps/sources/models.py @@ -12,6 +12,7 @@ import poplib 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.utils.translation import ugettext_lazy as _ @@ -181,8 +182,9 @@ class OutOfProcessSource(Source): class IntervalBaseModel(OutOfProcessSource): - interval = models.PositiveIntegerField(default=DEFAULT_INTERVAL, verbose_name=_('Interval'), help_text=_('Interval in seconds between document downloads from this source.')) - document_type = models.ForeignKey(DocumentType, verbose_name=_('Document type'), help_text=_('Assign a document type to documents uploaded from this source.')) + interval = models.PositiveIntegerField(default=DEFAULT_INTERVAL, verbose_name=_('Interval'), help_text=_('Interval in seconds between checks for new documents.')) + # TEMP: Until migration problem is fixed + #document_type = models.ForeignKey(DocumentType, null=True, verbose_name=_('Document type'), help_text=_('Assign a document type to documents uploaded from this source.')) uncompress = models.CharField(max_length=1, choices=SOURCE_UNCOMPRESS_CHOICES, verbose_name=_('Uncompress'), help_text=_('Whether to expand or not, compressed archives.')) def _get_periodic_task_name(self, pk=None): @@ -212,7 +214,7 @@ class IntervalBaseModel(OutOfProcessSource): name=self._get_periodic_task_name(), interval=interval_instance, task='sources.tasks.task_check_interval_source', - queue='mailing', + queue='uploads', kwargs=json.dumps({'source_id': self.pk}) ) @@ -268,7 +270,7 @@ class POP3Email(EmailBaseModel): timeout = models.PositiveIntegerField(default=DEFAULT_POP3_TIMEOUT, verbose_name=_('Timeout')) - def fetch_mail(self): + def check_source(self): try: logger.debug('Starting POP3 email fetch') logger.debug('host: %s' % self.host) @@ -314,7 +316,7 @@ class IMAPEmail(EmailBaseModel): mailbox = models.CharField(max_length=64, default=DEFAULT_IMAP_MAILBOX, verbose_name=_('Mailbox'), help_text=_('Mail from which to check for messages with attached documents.')) # http://www.doughellmann.com/PyMOTW/imaplib/ - def fetch_mail(self): + def check_source(self): try: logger.debug('Starting IMAP email fetch') logger.debug('host: %s' % self.host) @@ -351,13 +353,26 @@ class IMAPEmail(EmailBaseModel): verbose_name_plural = _('IMAP email') -class WatchFolderSource(OutOfProcessSource): +class WatchFolderSource(IntervalBaseModel): source_type = SOURCE_CHOICE_WATCH folder_path = models.CharField(max_length=255, verbose_name=_(u'Folder path'), help_text=_(u'Server side filesystem path.')) - uncompress = models.CharField(max_length=1, choices=SOURCE_UNCOMPRESS_CHOICES, verbose_name=_(u'Uncompress'), help_text=_(u'Whether to expand or not compressed archives.')) + # TODO: remove delete_after_upload delete_after_upload = models.BooleanField(default=True, verbose_name=_(u'Delete after upload'), help_text=_(u'Delete the file after is has been successfully uploaded.')) - interval = models.PositiveIntegerField(verbose_name=_(u'Interval'), help_text=_(u'Inverval in seconds where the watch folder path is checked for new documents.')) + + def check_source(self): + # TEMP: until default document language problem is fixed + from documents.settings import LANGUAGE + + for file_name in os.listdir(self.folder_path): + full_path = os.path.join(self.folder_path, file_name) + if os.path.isfile(full_path): + + with File(file=open(full_path, mode='rb')) as file_object: + # TEMP: Until migration document type problem is fixed + document_type = DocumentType.objects.all()[0] + self.upload_document(file_object, label=file_name, document_type=document_type, expand=(self.uncompress == SOURCE_UNCOMPRESS_CHOICE_Y), language=LANGUAGE) + os.unlink(full_path) class Meta: verbose_name = _(u'Watch folder') 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 new file mode 100644 index 0000000000..a5b9a76ff5 --- /dev/null +++ b/mayan/apps/sources/south_migrations/0009_auto__del_watchfoldersource__chg_field_intervalbasemodel_document_type.py @@ -0,0 +1,123 @@ +# -*- 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 + + +def fake_get_or_create(model, *args, **kwargs): + try: + obj = model.objects.get(**kwargs) + except model.DoesNotExist: + obj = model(**kwargs) + obj.save() + return obj + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Deleting model 'WatchFolderSource' + db.delete_table(u'sources_watchfoldersource') + + if not db.dry_run: + orphan_doc_type = fake_get_or_create(orm['documents.DocumentType'], name='_orphan_document_') + + # Changing field 'IntervalBaseModel.document_type' + db.alter_column(u'sources_intervalbasemodel', 'document_type_id', self.gf('django.db.models.fields.related.ForeignKey')(default=orphan_doc_type.pk, to=orm['documents.DocumentType'])) + + def backwards(self, orm): + # Adding model 'WatchFolderSource' + db.create_table(u'sources_watchfoldersource', ( + ('folder_path', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('uncompress', self.gf('django.db.models.fields.CharField')(max_length=1)), + ('delete_after_upload', self.gf('django.db.models.fields.BooleanField')(default=True)), + ('interval', self.gf('django.db.models.fields.PositiveIntegerField')()), + (u'outofprocesssource_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['sources.OutOfProcessSource'], unique=True, primary_key=True)), + )) + 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)) + + models = { + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'documents.documenttype': { + 'Meta': {'ordering': "['name']", 'object_name': 'DocumentType'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}), + 'ocr': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) + }, + u'sources.emailbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'EmailBaseModel', '_ormbases': [u'sources.IntervalBaseModel']}, + 'host': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + u'intervalbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.IntervalBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '96'}), + 'port': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'ssl': ('django.db.models.fields.BooleanField', [], {}), + 'username': ('django.db.models.fields.CharField', [], {'max_length': '96'}) + }, + u'sources.imapemail': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IMAPEmail', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'mailbox': ('django.db.models.fields.CharField', [], {'default': "'INBOX'", 'max_length': '64'}) + }, + u'sources.interactivesource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'InteractiveSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.intervalbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IntervalBaseModel', '_ormbases': [u'sources.OutOfProcessSource']}, + 'document_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['documents.DocumentType']"}), + 'interval': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}), + u'outofprocesssource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.OutOfProcessSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.outofprocesssource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'OutOfProcessSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.pop3email': { + 'Meta': {'ordering': "('title',)", 'object_name': 'POP3Email', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'timeout': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}) + }, + u'sources.source': { + 'Meta': {'ordering': "('title',)", 'object_name': 'Source'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '64'}) + }, + u'sources.sourcetransformation': { + 'Meta': {'ordering': "('order',)", 'object_name': 'SourceTransformation'}, + 'arguments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), + 'transformation': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + u'sources.stagingfoldersource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'StagingFolderSource', '_ormbases': [u'sources.InteractiveSource']}, + 'delete_after_upload': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'folder_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'preview_height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'preview_width': ('django.db.models.fields.IntegerField', [], {}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.webformsource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'WebFormSource', '_ormbases': [u'sources.InteractiveSource']}, + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + } + } + + complete_apps = ['sources'] diff --git a/mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py b/mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py new file mode 100644 index 0000000000..ef38125094 --- /dev/null +++ b/mayan/apps/sources/south_migrations/0010_auto__add_watchfoldersource.py @@ -0,0 +1,110 @@ +# -*- 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 + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'WatchFolderSource' + db.create_table(u'sources_watchfoldersource', ( + (u'intervalbasemodel_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['sources.IntervalBaseModel'], unique=True, primary_key=True)), + ('folder_path', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('delete_after_upload', self.gf('django.db.models.fields.BooleanField')(default=True)), + )) + 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'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'documents.documenttype': { + 'Meta': {'ordering': "['name']", 'object_name': 'DocumentType'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}), + 'ocr': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) + }, + u'sources.emailbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'EmailBaseModel', '_ormbases': [u'sources.IntervalBaseModel']}, + 'host': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + u'intervalbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.IntervalBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '96'}), + 'port': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'ssl': ('django.db.models.fields.BooleanField', [], {}), + 'username': ('django.db.models.fields.CharField', [], {'max_length': '96'}) + }, + u'sources.imapemail': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IMAPEmail', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'mailbox': ('django.db.models.fields.CharField', [], {'default': "'INBOX'", 'max_length': '64'}) + }, + u'sources.interactivesource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'InteractiveSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.intervalbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IntervalBaseModel', '_ormbases': [u'sources.OutOfProcessSource']}, + 'document_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['documents.DocumentType']"}), + 'interval': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}), + u'outofprocesssource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.OutOfProcessSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.outofprocesssource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'OutOfProcessSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.pop3email': { + 'Meta': {'ordering': "('title',)", 'object_name': 'POP3Email', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'timeout': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}) + }, + u'sources.source': { + 'Meta': {'ordering': "('title',)", 'object_name': 'Source'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '64'}) + }, + u'sources.sourcetransformation': { + 'Meta': {'ordering': "('order',)", 'object_name': 'SourceTransformation'}, + 'arguments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), + 'transformation': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + u'sources.stagingfoldersource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'StagingFolderSource', '_ormbases': [u'sources.InteractiveSource']}, + 'delete_after_upload': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'folder_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'preview_height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'preview_width': ('django.db.models.fields.IntegerField', [], {}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.watchfoldersource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'WatchFolderSource', '_ormbases': [u'sources.IntervalBaseModel']}, + 'delete_after_upload': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'folder_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'intervalbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.IntervalBaseModel']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.webformsource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'WebFormSource', '_ormbases': [u'sources.InteractiveSource']}, + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + } + } + + complete_apps = ['sources'] \ No newline at end of file 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 new file mode 100644 index 0000000000..0ad00f653b --- /dev/null +++ b/mayan/apps/sources/south_migrations/0011_auto__del_field_intervalbasemodel_document_type.py @@ -0,0 +1,104 @@ +# -*- 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 + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # 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'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'sources.emailbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'EmailBaseModel', '_ormbases': [u'sources.IntervalBaseModel']}, + 'host': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + u'intervalbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.IntervalBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '96'}), + 'port': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'ssl': ('django.db.models.fields.BooleanField', [], {}), + 'username': ('django.db.models.fields.CharField', [], {'max_length': '96'}) + }, + u'sources.imapemail': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IMAPEmail', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'mailbox': ('django.db.models.fields.CharField', [], {'default': "'INBOX'", 'max_length': '64'}) + }, + u'sources.interactivesource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'InteractiveSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.intervalbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IntervalBaseModel', '_ormbases': [u'sources.OutOfProcessSource']}, + 'interval': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}), + u'outofprocesssource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.OutOfProcessSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.outofprocesssource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'OutOfProcessSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.pop3email': { + 'Meta': {'ordering': "('title',)", 'object_name': 'POP3Email', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'timeout': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}) + }, + u'sources.source': { + 'Meta': {'ordering': "('title',)", 'object_name': 'Source'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '64'}) + }, + u'sources.sourcetransformation': { + 'Meta': {'ordering': "('order',)", 'object_name': 'SourceTransformation'}, + 'arguments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), + 'transformation': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + u'sources.stagingfoldersource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'StagingFolderSource', '_ormbases': [u'sources.InteractiveSource']}, + 'delete_after_upload': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'folder_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'preview_height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'preview_width': ('django.db.models.fields.IntegerField', [], {}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.watchfoldersource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'WatchFolderSource', '_ormbases': [u'sources.IntervalBaseModel']}, + 'delete_after_upload': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'folder_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'intervalbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.IntervalBaseModel']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.webformsource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'WebFormSource', '_ormbases': [u'sources.InteractiveSource']}, + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + } + } + + complete_apps = ['sources'] \ No newline at end of file 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 new file mode 100644 index 0000000000..7d95fd6e3a --- /dev/null +++ b/mayan/apps/sources/south_migrations/0012_auto__add_field_intervalbasemodel_document_type.py @@ -0,0 +1,107 @@ +# -*- 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 + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # 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'], 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'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'documents.documenttype': { + 'Meta': {'ordering': "['name']", 'object_name': 'DocumentType'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}), + 'ocr': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) + }, + u'sources.emailbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'EmailBaseModel', '_ormbases': [u'sources.IntervalBaseModel']}, + 'host': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + u'intervalbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.IntervalBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '96'}), + 'port': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'ssl': ('django.db.models.fields.BooleanField', [], {}), + 'username': ('django.db.models.fields.CharField', [], {'max_length': '96'}) + }, + u'sources.imapemail': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IMAPEmail', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'mailbox': ('django.db.models.fields.CharField', [], {'default': "'INBOX'", 'max_length': '64'}) + }, + u'sources.interactivesource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'InteractiveSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.intervalbasemodel': { + 'Meta': {'ordering': "('title',)", 'object_name': 'IntervalBaseModel', '_ormbases': [u'sources.OutOfProcessSource']}, + 'document_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['documents.DocumentType']", 'null': 'True'}), + 'interval': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}), + u'outofprocesssource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.OutOfProcessSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.outofprocesssource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'OutOfProcessSource', '_ormbases': [u'sources.Source']}, + u'source_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.Source']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.pop3email': { + 'Meta': {'ordering': "('title',)", 'object_name': 'POP3Email', '_ormbases': [u'sources.EmailBaseModel']}, + u'emailbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.EmailBaseModel']", 'unique': 'True', 'primary_key': 'True'}), + 'timeout': ('django.db.models.fields.PositiveIntegerField', [], {'default': '60'}) + }, + u'sources.source': { + 'Meta': {'ordering': "('title',)", 'object_name': 'Source'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '64'}) + }, + u'sources.sourcetransformation': { + 'Meta': {'ordering': "('order',)", 'object_name': 'SourceTransformation'}, + 'arguments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), + 'transformation': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + u'sources.stagingfoldersource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'StagingFolderSource', '_ormbases': [u'sources.InteractiveSource']}, + 'delete_after_upload': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'folder_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'preview_height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'preview_width': ('django.db.models.fields.IntegerField', [], {}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + }, + u'sources.watchfoldersource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'WatchFolderSource', '_ormbases': [u'sources.IntervalBaseModel']}, + 'delete_after_upload': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'folder_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'intervalbasemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.IntervalBaseModel']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'sources.webformsource': { + 'Meta': {'ordering': "('title',)", 'object_name': 'WebFormSource', '_ormbases': [u'sources.InteractiveSource']}, + u'interactivesource_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['sources.InteractiveSource']", 'unique': 'True', 'primary_key': 'True'}), + 'uncompress': ('django.db.models.fields.CharField', [], {'max_length': '1'}) + } + } + + complete_apps = ['sources'] diff --git a/mayan/apps/sources/tasks.py b/mayan/apps/sources/tasks.py index 9a7cb4b249..0e41afdfc0 100644 --- a/mayan/apps/sources/tasks.py +++ b/mayan/apps/sources/tasks.py @@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) def task_check_interval_source(source_id): source = Source.objects.get_subclass(pk=source_id) if source.enabled: - source.fetch_mail() + source.check_source() @app.task(ignore_result=True) diff --git a/mayan/apps/sources/views.py b/mayan/apps/sources/views.py index 9406853428..fe67643a29 100644 --- a/mayan/apps/sources/views.py +++ b/mayan/apps/sources/views.py @@ -427,7 +427,7 @@ def setup_source_edit(request, source_id): form = form_class(instance=source) return render_to_response('main/generic_form.html', { - 'title': _(u'Edit source: %s') % source.fullname(), + 'title': _(u'Edit source: %s') % source, 'form': form, 'source': source, 'navigation_object_name': 'source', @@ -455,7 +455,7 @@ def setup_source_delete(request, source_id): return HttpResponseRedirect(reverse(redirect_view)) context = { - 'title': _(u'Are you sure you wish to delete the source: %s?') % source.fullname(), + 'title': _(u'Are you sure you wish to delete the source: %s?') % source, 'source': source, 'object_name': _(u'Source'), 'navigation_object_name': 'source',