diff --git a/.travis.yml b/.travis.yml index 9644893..cb03bb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,28 @@ language: python + python: - - "2.6" - - "2.7" - - "3.3" + - "2.6" + - "2.7" + - "3.3" + env: - - DJANGO=1.4.14 - - DJANGO=1.5.9 - - DJANGO=1.6.6 + - DJANGO=1.4.14 + - DJANGO=1.5.9 + - DJANGO=1.6.8 + - DJANGO=1.7.1 + matrix: - exclude: - - env: DJANGO=1.4.14 - python: "3.3" + allow_failures: + # Allow failures for legacy django versions + - env: DJANGO=1.4.14 + - env: DJANGO=1.5.9 + exclude: + - env: DJANGO=1.4.14 + python: "3.3" + - env: DJANGO=1.7.1 + python: "2.6" install: - - pip install -q Django==$DJANGO --use-mirrors - - pip install -q -e . --use-mirrors + - pip install -q Django==$DJANGO --use-mirrors + - pip install -q -e . --use-mirrors script: - - python setup.py test + - python setup.py test diff --git a/django_mailbox/migrations/0001_initial.py b/django_mailbox/migrations/0001_initial.py index 4faa4fa..dfb6ffa 100644 --- a/django_mailbox/migrations/0001_initial.py +++ b/django_mailbox/migrations/0001_initial.py @@ -1,59 +1,59 @@ # -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models +from __future__ import unicode_literals + +from django.db import models, migrations -class Migration(SchemaMigration): +class Migration(migrations.Migration): - def forwards(self, orm): - # Adding model 'Mailbox' - db.create_table('django_mailbox_mailbox', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('name', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('uri', self.gf('django.db.models.fields.CharField')(max_length=255)), - )) - db.send_create_signal('django_mailbox', ['Mailbox']) + dependencies = [ + ] - # Adding model 'Message' - db.create_table('django_mailbox_message', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('mailbox', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['django_mailbox.Mailbox'])), - ('subject', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('message_id', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('from_address', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('body', self.gf('django.db.models.fields.TextField')()), - ('received', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), - )) - db.send_create_signal('django_mailbox', ['Message']) - - - def backwards(self, orm): - # Deleting model 'Mailbox' - db.delete_table('django_mailbox_mailbox') - - # Deleting model 'Message' - db.delete_table('django_mailbox_message') - - - models = { - 'django_mailbox.mailbox': { - 'Meta': {'object_name': 'Mailbox'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'uri': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - }, - 'django_mailbox.message': { - 'Meta': {'object_name': 'Message'}, - 'body': ('django.db.models.fields.TextField', [], {}), - 'from_address': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'mailbox': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_mailbox.Mailbox']"}), - 'message_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'received': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'subject': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['django_mailbox'] \ No newline at end of file + operations = [ + migrations.CreateModel( + name='Mailbox', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('name', models.CharField(max_length=255, verbose_name='Name')), + ('uri', models.CharField(default=None, max_length=255, blank=True, help_text="Example: imap+ssl://myusername:mypassword@someserver

Internet transports include 'imap' and 'pop3'; common local file transports include 'maildir', 'mbox', and less commonly 'babyl', 'mh', and 'mmdf'.

Be sure to urlencode your username and password should they contain illegal characters (like @, :, etc).", null=True, verbose_name='URI')), + ('from_email', models.CharField(default=None, max_length=255, blank=True, help_text="Example: MailBot <mailbot@yourdomain.com>
'From' header to set for outgoing email.

If you do not use this e-mail inbox for outgoing mail, this setting is unnecessary.
If you send e-mail without setting this, your 'From' header will'be set to match the setting `DEFAULT_FROM_EMAIL`.", null=True, verbose_name='From email')), + ('active', models.BooleanField(default=True, help_text='Check this e-mail inbox for new e-mail messages during polling cycles. This checkbox does not have an effect upon whether mail is collected here when this mailbox receives mail from a pipe, and does not affect whether e-mail messages can be dispatched from this mailbox. ', verbose_name='Active')), + ], + options={ + 'verbose_name_plural': 'Mailboxes', + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='Message', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('subject', models.CharField(max_length=255, verbose_name='Subject')), + ('message_id', models.CharField(max_length=255, verbose_name='Message ID')), + ('from_header', models.CharField(max_length=255, verbose_name='From header')), + ('to_header', models.TextField(verbose_name='To header')), + ('outgoing', models.BooleanField(default=False, verbose_name='Outgoing')), + ('body', models.TextField(verbose_name='Body')), + ('encoded', models.BooleanField(default=False, help_text='True if the e-mail body is Base64 encoded', verbose_name='Encoded')), + ('processed', models.DateTimeField(auto_now_add=True, verbose_name='Processed')), + ('read', models.DateTimeField(default=None, null=True, verbose_name='Read', blank=True)), + ('in_reply_to', models.ForeignKey(related_name='replies', verbose_name='In reply to', blank=True, to='django_mailbox.Message', null=True)), + ('mailbox', models.ForeignKey(related_name='messages', verbose_name='Mailbox', to='django_mailbox.Mailbox')), + ], + options={ + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='MessageAttachment', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('headers', models.TextField(null=True, verbose_name='Headers', blank=True)), + ('document', models.FileField(upload_to=b'mailbox_attachments/%Y/%m/%d/', verbose_name='Document')), + ('message', models.ForeignKey(related_name='attachments', verbose_name='Message', blank=True, to='django_mailbox.Message', null=True)), + ], + options={ + }, + bases=(models.Model,), + ), + ] diff --git a/django_mailbox/runtests.py b/django_mailbox/runtests.py index 62094fd..068871a 100644 --- a/django_mailbox/runtests.py +++ b/django_mailbox/runtests.py @@ -3,6 +3,7 @@ import sys from os.path import dirname, abspath +from django import setup from django.conf import settings if not settings.configured: @@ -27,6 +28,8 @@ def runtests(*test_args): test_args = ['django_mailbox'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) + # ensure that AppRegistry has loaded + setup() runner = DjangoTestSuiteRunner( verbosity=1, interactive=False, diff --git a/django_mailbox/south_migrations/0001_initial.py b/django_mailbox/south_migrations/0001_initial.py new file mode 100644 index 0000000..4faa4fa --- /dev/null +++ b/django_mailbox/south_migrations/0001_initial.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +import 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 'Mailbox' + db.create_table('django_mailbox_mailbox', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('uri', self.gf('django.db.models.fields.CharField')(max_length=255)), + )) + db.send_create_signal('django_mailbox', ['Mailbox']) + + # Adding model 'Message' + db.create_table('django_mailbox_message', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('mailbox', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['django_mailbox.Mailbox'])), + ('subject', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('message_id', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('from_address', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('body', self.gf('django.db.models.fields.TextField')()), + ('received', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + )) + db.send_create_signal('django_mailbox', ['Message']) + + + def backwards(self, orm): + # Deleting model 'Mailbox' + db.delete_table('django_mailbox_mailbox') + + # Deleting model 'Message' + db.delete_table('django_mailbox_message') + + + models = { + 'django_mailbox.mailbox': { + 'Meta': {'object_name': 'Mailbox'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'uri': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + 'django_mailbox.message': { + 'Meta': {'object_name': 'Message'}, + 'body': ('django.db.models.fields.TextField', [], {}), + 'from_address': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'mailbox': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_mailbox.Mailbox']"}), + 'message_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'received': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'subject': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + } + } + + complete_apps = ['django_mailbox'] \ No newline at end of file diff --git a/django_mailbox/migrations/0002_auto__chg_field_mailbox_uri.py b/django_mailbox/south_migrations/0002_auto__chg_field_mailbox_uri.py similarity index 100% rename from django_mailbox/migrations/0002_auto__chg_field_mailbox_uri.py rename to django_mailbox/south_migrations/0002_auto__chg_field_mailbox_uri.py diff --git a/django_mailbox/migrations/0003_auto__add_field_mailbox_active.py b/django_mailbox/south_migrations/0003_auto__add_field_mailbox_active.py similarity index 100% rename from django_mailbox/migrations/0003_auto__add_field_mailbox_active.py rename to django_mailbox/south_migrations/0003_auto__add_field_mailbox_active.py diff --git a/django_mailbox/migrations/0004_auto__add_field_message_outgoing.py b/django_mailbox/south_migrations/0004_auto__add_field_message_outgoing.py similarity index 100% rename from django_mailbox/migrations/0004_auto__add_field_message_outgoing.py rename to django_mailbox/south_migrations/0004_auto__add_field_message_outgoing.py diff --git a/django_mailbox/migrations/0005_rename_fields.py b/django_mailbox/south_migrations/0005_rename_fields.py similarity index 100% rename from django_mailbox/migrations/0005_rename_fields.py rename to django_mailbox/south_migrations/0005_rename_fields.py diff --git a/django_mailbox/migrations/0006_auto__add_field_message_in_reply_to.py b/django_mailbox/south_migrations/0006_auto__add_field_message_in_reply_to.py similarity index 100% rename from django_mailbox/migrations/0006_auto__add_field_message_in_reply_to.py rename to django_mailbox/south_migrations/0006_auto__add_field_message_in_reply_to.py diff --git a/django_mailbox/migrations/0007_auto__del_field_message_address__add_field_message_from_header__add_fi.py b/django_mailbox/south_migrations/0007_auto__del_field_message_address__add_field_message_from_header__add_fi.py similarity index 100% rename from django_mailbox/migrations/0007_auto__del_field_message_address__add_field_message_from_header__add_fi.py rename to django_mailbox/south_migrations/0007_auto__del_field_message_address__add_field_message_from_header__add_fi.py diff --git a/django_mailbox/migrations/0008_populate_from_to_fields.py b/django_mailbox/south_migrations/0008_populate_from_to_fields.py similarity index 100% rename from django_mailbox/migrations/0008_populate_from_to_fields.py rename to django_mailbox/south_migrations/0008_populate_from_to_fields.py diff --git a/django_mailbox/migrations/0009_remove_references_table.py b/django_mailbox/south_migrations/0009_remove_references_table.py similarity index 100% rename from django_mailbox/migrations/0009_remove_references_table.py rename to django_mailbox/south_migrations/0009_remove_references_table.py diff --git a/django_mailbox/migrations/0010_auto__add_field_mailbox_from_email.py b/django_mailbox/south_migrations/0010_auto__add_field_mailbox_from_email.py similarity index 100% rename from django_mailbox/migrations/0010_auto__add_field_mailbox_from_email.py rename to django_mailbox/south_migrations/0010_auto__add_field_mailbox_from_email.py diff --git a/django_mailbox/migrations/0011_auto__add_field_message_read.py b/django_mailbox/south_migrations/0011_auto__add_field_message_read.py similarity index 100% rename from django_mailbox/migrations/0011_auto__add_field_message_read.py rename to django_mailbox/south_migrations/0011_auto__add_field_message_read.py diff --git a/django_mailbox/migrations/0012_auto__add_messageattachment.py b/django_mailbox/south_migrations/0012_auto__add_messageattachment.py similarity index 100% rename from django_mailbox/migrations/0012_auto__add_messageattachment.py rename to django_mailbox/south_migrations/0012_auto__add_messageattachment.py diff --git a/django_mailbox/migrations/0013_auto__add_field_messageattachment_message.py b/django_mailbox/south_migrations/0013_auto__add_field_messageattachment_message.py similarity index 100% rename from django_mailbox/migrations/0013_auto__add_field_messageattachment_message.py rename to django_mailbox/south_migrations/0013_auto__add_field_messageattachment_message.py diff --git a/django_mailbox/migrations/0014_migrate_message_attachments.py b/django_mailbox/south_migrations/0014_migrate_message_attachments.py similarity index 100% rename from django_mailbox/migrations/0014_migrate_message_attachments.py rename to django_mailbox/south_migrations/0014_migrate_message_attachments.py diff --git a/django_mailbox/migrations/0015_auto__add_field_messageattachment_headers.py b/django_mailbox/south_migrations/0015_auto__add_field_messageattachment_headers.py similarity index 100% rename from django_mailbox/migrations/0015_auto__add_field_messageattachment_headers.py rename to django_mailbox/south_migrations/0015_auto__add_field_messageattachment_headers.py diff --git a/django_mailbox/migrations/0016_auto__add_field_message_encoded.py b/django_mailbox/south_migrations/0016_auto__add_field_message_encoded.py similarity index 100% rename from django_mailbox/migrations/0016_auto__add_field_message_encoded.py rename to django_mailbox/south_migrations/0016_auto__add_field_message_encoded.py diff --git a/django_mailbox/south_migrations/__init__.py b/django_mailbox/south_migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django_mailbox/tests/messages/generic_message.eml b/django_mailbox/tests/messages/generic_message.eml index b3c9f33..bf5f0fe 100644 --- a/django_mailbox/tests/messages/generic_message.eml +++ b/django_mailbox/tests/messages/generic_message.eml @@ -1,5 +1,4 @@ MIME-Version: 1.0 -Received: by 10.221.0.211 with HTTP; Sun, 20 Jan 2013 11:53:53 -0800 (PST) X-Originating-IP: [24.22.122.177] Date: Sun, 20 Jan 2013 11:53:53 -0800 Delivered-To: test@adamcoddington.net diff --git a/django_mailbox/tests/messages/message_with_attachment.eml b/django_mailbox/tests/messages/message_with_attachment.eml index 34e7093..ac1cc43 100644 --- a/django_mailbox/tests/messages/message_with_attachment.eml +++ b/django_mailbox/tests/messages/message_with_attachment.eml @@ -17,8 +17,8 @@ This message has an attachment. --047d7b33dd729737fe04d3bde348 Content-Type: image/png; name="heart.png" Content-Disposition: attachment; filename="heart.png" -Content-Transfer-Encoding: base64 X-Attachment-Id: f_hc6mair60 +Content-Transfer-Encoding: base64 iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAFoTx1HAAAAzUlEQVQoz32RWxXDIBBEr4NIQEIl ICESkFAJkRAJSIgEpEQCEqYfu6QUkn7sCcyDGQiSACKSKCAkGwBJwhDwZQNMEiYAIBdQvk7rfaHf