mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
fix utils.get_save_path
fix get_save_path in Migration
This commit is contained in:
parent
2824cde5e9
commit
02acef8ede
2 changed files with 12 additions and 11 deletions
|
|
@ -12,6 +12,6 @@ class Migration(migrations.Migration):
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='messageattachment',
|
model_name='messageattachment',
|
||||||
name='document',
|
name='document',
|
||||||
field=models.FileField(upload_to=django_mailbox.utils.get_attachment_save_path, verbose_name='Document'),
|
field=models.FileField(upload_to=django_mailbox.utils.get_save_path(setting='attachment_upload_to'), verbose_name='Document'),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import os
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -144,14 +143,16 @@ def get_body_from_message(message, maintype, subtype):
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|
||||||
def get_save_path(instance, filename, setting):
|
def get_save_path(setting):
|
||||||
settings = get_settings()
|
def _tmp(instance, filename):
|
||||||
|
settings = get_settings()
|
||||||
|
|
||||||
path = settings[setting]
|
path = settings[setting]
|
||||||
if '%' in path:
|
if '%' in path:
|
||||||
path = datetime.datetime.utcnow().strftime(path)
|
path = datetime.datetime.utcnow().strftime(path)
|
||||||
|
|
||||||
return os.path.join(
|
return os.path.join(
|
||||||
path,
|
path,
|
||||||
filename,
|
filename,
|
||||||
)
|
)
|
||||||
|
return _tmp
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue