diff --git a/mayan/apps/sources/admin.py b/mayan/apps/sources/admin.py index ea80bb817c..b8f2b38370 100644 --- a/mayan/apps/sources/admin.py +++ b/mayan/apps/sources/admin.py @@ -11,7 +11,8 @@ from .models import ( class IMAPEmailAdmin(admin.ModelAdmin): list_display = ( 'label', 'enabled', 'uncompress', 'host', 'ssl', 'port', 'interval', - 'document_type', 'metadata_attachment_name' + 'document_type', 'metadata_attachment_name', 'from_metadata_type', + 'subject_metadata_type', 'store_body' ) @@ -19,7 +20,8 @@ class IMAPEmailAdmin(admin.ModelAdmin): class POP3EmailAdmin(admin.ModelAdmin): list_display = ( 'label', 'enabled', 'uncompress', 'host', 'ssl', 'port', 'interval', - 'document_type', 'metadata_attachment_name' + 'document_type', 'metadata_attachment_name', 'from_metadata_type', + 'subject_metadata_type', 'store_body' ) diff --git a/mayan/apps/sources/forms.py b/mayan/apps/sources/forms.py index 05306d5b73..db2a29b9b9 100644 --- a/mayan/apps/sources/forms.py +++ b/mayan/apps/sources/forms.py @@ -89,7 +89,7 @@ class EmailSetupBaseForm(forms.ModelForm): 'label', 'enabled', 'interval', 'document_type', 'uncompress', 'host', 'ssl', 'port', 'username', 'password', 'metadata_attachment_name', 'subject_metadata_type', - 'from_metadata_type' + 'from_metadata_type', 'store_body' ) widgets = { 'password': forms.widgets.PasswordInput(render_value=True) diff --git a/mayan/apps/sources/migrations/0010_auto_20151001_0055.py b/mayan/apps/sources/migrations/0010_auto_20151001_0055.py new file mode 100644 index 0000000000..33262efccb --- /dev/null +++ b/mayan/apps/sources/migrations/0010_auto_20151001_0055.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('sources', '0009_auto_20150930_2341'), + ] + + operations = [ + migrations.AddField( + model_name='emailbasemodel', + name='store_body', + field=models.BooleanField(default=True, help_text='Store the body of the email as a text document.', verbose_name='Store email body'), + preserve_default=True, + ), + migrations.AlterField( + model_name='imapemail', + name='mailbox', + field=models.CharField(default='INBOX', help_text='IMAP Mailbox from which to check for messages.', max_length=64, verbose_name='Mailbox'), + preserve_default=True, + ), + ] diff --git a/mayan/apps/sources/models.py b/mayan/apps/sources/models.py index ebb7574f2d..1df74b26e1 100644 --- a/mayan/apps/sources/models.py +++ b/mayan/apps/sources/models.py @@ -354,6 +354,11 @@ class EmailBaseModel(IntervalBaseModel): ), null=True, related_name='email_from', verbose_name=_('From metadata type') ) + store_body = models.BooleanField( + default=True, help_text=_( + 'Store the body of the email as a text document.' + ), verbose_name=_('Store email body') + ) def clean(self): if self.subject_metadata_type: @@ -453,7 +458,7 @@ class EmailBaseModel(IntervalBaseModel): logger.debug('content_type: %s', content_type) - if content_type == 'text/plain': + if content_type == 'text/plain' and source.store_body: content = part.get_payload(decode=True).decode(part.get_content_charset()) with ContentFile(content=content, name='email_body.txt') as file_object: source.handle_upload(