@@ -1,24 +1,20 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
-import datetime |
|
4 | 3 |
import os |
5 |
-import time |
|
6 | 4 |
|
7 | 5 |
from django.conf import settings |
8 | 6 |
from django.db import models |
9 | 7 |
from django.utils.translation import ugettext_lazy as _ |
8 |
+from TimeConvert import TimeConvert as tc |
|
10 | 9 |
|
11 | 10 |
from pai2.basemodels import CreateUpdateMixin, PlatformMixin, VersionMixin |
12 | 11 |
|
13 | 12 |
|
14 | 13 |
def upload_path(instance, old_filename): |
15 |
- extension = os.path.splitext(old_filename)[1].lower() |
|
16 |
- today = datetime.datetime.today() |
|
17 |
- return 'file/{year}{month}/{timestamp}{extension}'.format( |
|
18 |
- year=today.year, |
|
19 |
- month=today.month, |
|
20 |
- timestamp=int(time.time()), |
|
21 |
- extension=extension |
|
14 |
+ return 'file/{ym}/{stamp}{ext}'.format( |
|
15 |
+ ym=tc.local_string(format='%Y%m'), |
|
16 |
+ stamp=tc.local_timestamp(ms=True), |
|
17 |
+ ext=os.path.splitext(old_filename)[1].lower(), |
|
22 | 18 |
) |
23 | 19 |
|
24 | 20 |
|