forked from mirror/django-mailbox
add DJANGO_MAILBOX_ATTACHMENT_UPLOAD_TO setting
This commit is contained in:
parent
688759bd7a
commit
1a04087159
5 changed files with 27 additions and 2 deletions
|
|
@ -71,6 +71,12 @@ ATTACHMENT_INTERPOLATION_HEADER = getattr(
|
||||||
'X-Django-Mailbox-Interpolate-Attachment'
|
'X-Django-Mailbox-Interpolate-Attachment'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ATTACHMENT_UPLOAD_TO = getattr(
|
||||||
|
settings,
|
||||||
|
'DJANGO_MAILBOX_ATTACHMENT_UPLOAD_TO',
|
||||||
|
'mailbox_attachments/%Y/%m/%d/'
|
||||||
|
)
|
||||||
|
|
||||||
STORE_ORIGINAL_MESSAGE = getattr(
|
STORE_ORIGINAL_MESSAGE = getattr(
|
||||||
settings,
|
settings,
|
||||||
'DJANGO_MAILBOX_STORE_ORIGINAL_MESSAGE',
|
'DJANGO_MAILBOX_STORE_ORIGINAL_MESSAGE',
|
||||||
|
|
@ -717,7 +723,7 @@ class MessageAttachment(models.Model):
|
||||||
|
|
||||||
document = models.FileField(
|
document = models.FileField(
|
||||||
_(u'Document'),
|
_(u'Document'),
|
||||||
upload_to='mailbox_attachments/%Y/%m/%d/'
|
upload_to=ATTACHMENT_UPLOAD_TO,
|
||||||
)
|
)
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
|
|
|
||||||
0
django_mailbox/runtests.py
Normal file → Executable file
0
django_mailbox/runtests.py
Normal file → Executable file
|
|
@ -3,3 +3,4 @@ from .test_message_flattening import *
|
||||||
from .test_process_email import *
|
from .test_process_email import *
|
||||||
from .test_transports import *
|
from .test_transports import *
|
||||||
from .test_integration_imap import *
|
from .test_integration_imap import *
|
||||||
|
from .test_settings import *
|
||||||
|
|
|
||||||
10
django_mailbox/tests/test_settings.py
Normal file
10
django_mailbox/tests/test_settings.py
Normal 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/')
|
||||||
|
|
@ -12,7 +12,7 @@ Settings
|
||||||
|
|
||||||
* Default: ``False``
|
* Default: ``False``
|
||||||
* Type: ``boolean``
|
* Type: ``boolean``
|
||||||
* Controls whether or not we remove mimetypes not specified in
|
* Controls whether or not we remove mimetypes not specified in
|
||||||
``DJANGO_MAILBOX_PRESERVED_MIMETYPES`` from the message prior to storage.
|
``DJANGO_MAILBOX_PRESERVED_MIMETYPES`` from the message prior to storage.
|
||||||
|
|
||||||
* ``DJANGO_MAILBOX_ALLOWED_MIMETYPES``
|
* ``DJANGO_MAILBOX_ALLOWED_MIMETYPES``
|
||||||
|
|
@ -59,6 +59,14 @@ Settings
|
||||||
this field is the primary key of the ``django_mailbox.MessageAttachment``
|
this field is the primary key of the ``django_mailbox.MessageAttachment``
|
||||||
instance currently storing this payload component's contents.
|
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``
|
* ``DJANGO_MAILBOX_MAX_MESSAGE_SIZE``
|
||||||
|
|
||||||
* Default: ``False``
|
* Default: ``False``
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue