mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
add DJANGO_MAILBOX_MESSAGE_UPLOAD_TO to settings, change utils.get_attachment_save_path to utils.get_save_path, change eml upload_to in model
This commit is contained in:
parent
6004a2286f
commit
2824cde5e9
3 changed files with 17 additions and 5 deletions
|
|
@ -66,7 +66,13 @@ def get_settings():
|
|||
settings,
|
||||
'DJANGO_MAILBOX_default_charset',
|
||||
'iso8859-1',
|
||||
),
|
||||
'message_upload_to': getattr(
|
||||
settings,
|
||||
'DJANGO_MAILBOX_MESSAGE_UPLOAD_TO',
|
||||
'messages/'
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -138,14 +144,14 @@ def get_body_from_message(message, maintype, subtype):
|
|||
return body
|
||||
|
||||
|
||||
def get_attachment_save_path(instance, filename):
|
||||
def get_save_path(instance, filename, setting):
|
||||
settings = get_settings()
|
||||
|
||||
path = settings['attachment_upload_to']
|
||||
path = settings[setting]
|
||||
if '%' in path:
|
||||
path = datetime.datetime.utcnow().strftime(path)
|
||||
|
||||
return os.path.join(
|
||||
path,
|
||||
filename,
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue