1
0
Fork 0

Merge pull request #51 from eupharis/master

add DJANGO_MAILBOX_ATTACHMENT_UPLOAD_TO setting
This commit is contained in:
Adam Coddington 2015-06-24 18:20:27 -07:00
commit 87828b0154
5 changed files with 27 additions and 2 deletions

View file

@ -71,6 +71,12 @@ ATTACHMENT_INTERPOLATION_HEADER = getattr(
'X-Django-Mailbox-Interpolate-Attachment'
)
ATTACHMENT_UPLOAD_TO = getattr(
settings,
'DJANGO_MAILBOX_ATTACHMENT_UPLOAD_TO',
'mailbox_attachments/%Y/%m/%d/'
)
STORE_ORIGINAL_MESSAGE = getattr(
settings,
'DJANGO_MAILBOX_STORE_ORIGINAL_MESSAGE',
@ -717,7 +723,7 @@ class MessageAttachment(models.Model):
document = models.FileField(
_(u'Document'),
upload_to='mailbox_attachments/%Y/%m/%d/'
upload_to=ATTACHMENT_UPLOAD_TO,
)
def delete(self, *args, **kwargs):

0
django_mailbox/runtests.py Normal file → Executable file
View file

View file

@ -3,3 +3,4 @@ from .test_message_flattening import *
from .test_process_email import *
from .test_transports import *
from .test_integration_imap import *
from .test_settings import *

View file

@ -0,0 +1,10 @@
from django.test import TestCase
from django.conf import settings
from django_mailbox.models import ATTACHMENT_UPLOAD_TO
class TestSettings(TestCase):
def test_default_attachment_upload_to(self):
user_setting = getattr(settings, 'DJANGO_MAILBOX_ATTACHMENT_UPLOAD_TO', False)
self.assertFalse(user_setting)
self.assertEqual(ATTACHMENT_UPLOAD_TO, 'mailbox_attachments/%Y/%m/%d/')

View file

@ -59,6 +59,14 @@ Settings
this field is the primary key of the ``django_mailbox.MessageAttachment``
instance currently storing this payload component's contents.
* ``DJANGO_MAILBOX_ATTACHMENT_UPLOAD_TO``
* Default: ``mailbox_attachments/%Y/%m/%d/``
* Type: ``string``
* Attachments will be saved to this location. Specifies the ``upload_to`` setting
for the attachment FileField. For more on FileFields and upload_to, see the
`Django docs <https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files-with-a-model>`__
* ``DJANGO_MAILBOX_MAX_MESSAGE_SIZE``
* Default: ``False``