|
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django_models_ext import upload_path
from manual.basemodels import CreateUpdateMixin
from utils.url_utils import upload_file_url
class HotQueryInfo(CreateUpdateMixin):
query = models.CharField(_(u'query'), max_length=255, blank=True, null=True, help_text=u'搜索关键词', unique=True)
class Meta:
verbose_name = _(u'热门搜索')
verbose_name_plural = _(u'热门搜索')
def __unicode__(self):
return unicode(self.pk)
@property
def data(self):
return {
'query': self.query,
}
class HotRecommendInfo(CreateUpdateMixin):
title = models.CharField(_(u'title'), max_length=255, blank=True, null=True, help_text=u'热门标题', unique=True)
image = models.ImageField(_(u'image'), upload_to=upload_path, blank=True, null=True, help_text=u'热门图片')
video = models.FileField(_(u'video'), upload_to=upload_path, blank=True, null=True, help_text=u'热门视频')
class Meta:
verbose_name = _(u'热门推荐')
verbose_name_plural = _(u'热门推荐')
def __unicode__(self):
return unicode(self.pk)
@property
def image_url(self):
return upload_file_url(self.image)
@property
def video_url(self):
return upload_file_url(self.video)
@property
def data(self):
return {
'title': self.title,
'image_url': self.image_url,
'video_url': self.video_url,
}
|