Skip to content

Commit 02acef8

Browse files
Ilya TleukenovIlya Tleukenov
Ilya Tleukenov
authored and
Ilya Tleukenov
committed
fix utils.get_save_path
fix get_save_path in Migration
1 parent 2824cde commit 02acef8

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

django_mailbox/migrations/0005_auto_20160523_2240.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class Migration(migrations.Migration):
1212
migrations.AlterField(
1313
model_name='messageattachment',
1414
name='document',
15-
field=models.FileField(upload_to=django_mailbox.utils.get_attachment_save_path, verbose_name='Document'),
15+
field=models.FileField(upload_to=django_mailbox.utils.get_save_path(setting='attachment_upload_to'), verbose_name='Document'),
1616
),
1717
]

django_mailbox/utils.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from django.conf import settings
77

8-
98
logger = logging.getLogger(__name__)
109

1110

@@ -144,14 +143,16 @@ def get_body_from_message(message, maintype, subtype):
144143
return body
145144

146145

147-
def get_save_path(instance, filename, setting):
148-
settings = get_settings()
146+
def get_save_path(setting):
147+
def _tmp(instance, filename):
148+
settings = get_settings()
149149

150-
path = settings[setting]
151-
if '%' in path:
152-
path = datetime.datetime.utcnow().strftime(path)
150+
path = settings[setting]
151+
if '%' in path:
152+
path = datetime.datetime.utcnow().strftime(path)
153153

154-
return os.path.join(
155-
path,
156-
filename,
157-
)
154+
return os.path.join(
155+
path,
156+
filename,
157+
)
158+
return _tmp

0 commit comments

Comments
 (0)