@@ -1,23 +1,13 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
-import os |
|
4 |
- |
|
5 | 3 |
from django.db import models |
6 | 4 |
from django.utils.translation import ugettext_lazy as _ |
7 |
-from TimeConvert import TimeConvert as tc |
|
5 |
+from models_ext import upload_path |
|
8 | 6 |
|
9 | 7 |
from manual.basemodels import CreateUpdateMixin |
10 | 8 |
from utils.url_utils import upload_file_url |
11 | 9 |
|
12 | 10 |
|
13 |
-def upload_path(instance, old_filename): |
|
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(), |
|
18 |
- ) |
|
19 |
- |
|
20 |
- |
|
21 | 11 |
class HotQueryInfo(CreateUpdateMixin): |
22 | 12 |
query = models.CharField(_(u'query'), max_length=255, blank=True, null=True, help_text=u'搜索关键词', unique=True) |
23 | 13 |
|
@@ -38,6 +28,7 @@ class HotQueryInfo(CreateUpdateMixin): |
||
38 | 28 |
class HotRecommendInfo(CreateUpdateMixin): |
39 | 29 |
title = models.CharField(_(u'title'), max_length=255, blank=True, null=True, help_text=u'热门标题', unique=True) |
40 | 30 |
image = models.ImageField(_(u'image'), upload_to=upload_path, blank=True, null=True, help_text=u'热门图片') |
31 |
+ video = models.FileField(_(u'video'), upload_to=upload_path, blank=True, null=True, help_text=u'热门视频') |
|
41 | 32 |
|
42 | 33 |
class Meta: |
43 | 34 |
verbose_name = _(u'热门推荐') |
@@ -51,8 +42,13 @@ class HotRecommendInfo(CreateUpdateMixin): |
||
51 | 42 |
return upload_file_url(self.image) |
52 | 43 |
|
53 | 44 |
@property |
45 |
+ def video_url(self): |
|
46 |
+ return upload_file_url(self.video) |
|
47 |
+ |
|
48 |
+ @property |
|
54 | 49 |
def data(self): |
55 | 50 |
return { |
56 | 51 |
'title': self.title, |
57 | 52 |
'image_url': self.image_url, |
53 |
+ 'video_url': self.video_url, |
|
58 | 54 |
} |
@@ -1,23 +1,14 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
-import os |
|
4 | 3 |
|
5 | 4 |
from django.db import models |
6 | 5 |
from django.utils.translation import ugettext_lazy as _ |
7 |
-from TimeConvert import TimeConvert as tc |
|
6 |
+from models_ext import upload_path |
|
8 | 7 |
|
9 | 8 |
from manual.basemodels import CreateUpdateMixin |
10 | 9 |
from utils.url_utils import upload_file_url |
11 | 10 |
|
12 | 11 |
|
13 |
-def upload_path(instance, old_filename): |
|
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(), |
|
18 |
- ) |
|
19 |
- |
|
20 |
- |
|
21 | 12 |
class IntroCategoryInfo(CreateUpdateMixin): |
22 | 13 |
category = models.CharField(_(u'category'), max_length=255, blank=True, null=True, help_text=u'分类', unique=True) |
23 | 14 |
position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
@@ -1,23 +1,13 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
-import os |
|
4 |
- |
|
5 | 3 |
from django.db import models |
6 | 4 |
from django.utils.translation import ugettext_lazy as _ |
7 |
-from TimeConvert import TimeConvert as tc |
|
5 |
+from models_ext import upload_path |
|
8 | 6 |
|
9 | 7 |
from manual.basemodels import CreateUpdateMixin |
10 | 8 |
from utils.url_utils import upload_file_url |
11 | 9 |
|
12 | 10 |
|
13 |
-def upload_path(instance, old_filename): |
|
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(), |
|
18 |
- ) |
|
19 |
- |
|
20 |
- |
|
21 | 11 |
class MessageInfo(CreateUpdateMixin): |
22 | 12 |
msg_image = models.ImageField(_(u'msg_image'), upload_to=upload_path, blank=True, null=True, help_text=u'消息图片') |
23 | 13 |
msg_image_airtime = models.DateTimeField(_(u'msg_image_airtime'), blank=True, null=True, help_text=u'消息图片开始日期') |
@@ -2,14 +2,15 @@ Django==1.11.3 |
||
2 | 2 |
MySQL-python==1.2.5 |
3 | 3 |
StatusCode==1.0.0 |
4 | 4 |
TimeConvert==1.4.1 |
5 |
-django-admin==1.0.6 |
|
5 |
+django-admin==1.0.12 |
|
6 | 6 |
django-detect==1.0.5 |
7 | 7 |
django-json-response==1.1.5 |
8 | 8 |
django-logit==1.0.6 |
9 |
+django-models-ext==1.0.2 |
|
9 | 10 |
django-paginator2==1.0.3 |
10 | 11 |
django-shortuuidfield==0.1.3 |
11 | 12 |
django-uniapi==1.0.0 |
12 |
-django-we==1.0.12 |
|
13 |
+django-we==1.0.14 |
|
13 | 14 |
hiredis==0.2.0 |
14 | 15 |
pyPdf==1.13 |
15 | 16 |
redis==2.10.6 |