|
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
from pai2.basemodels import CreateUpdateMixin
from utils.url_utils import img_url
class UUIDInfo(CreateUpdateMixin):
uuid = models.CharField(_(u'uuid'), max_length=22, blank=True, null=True, help_text=u'唯一标识', db_index=True, unique=True)
lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True)
class Meta:
verbose_name = _('uuidinfo')
verbose_name_plural = _('uuidinfo')
def __unicode__(self):
return u'{0.pk}'.format(self)
@property
def data(self):
return {
'pk': self.pk,
'uuid': self.uuid,
'lensman_id': self.lensman_id,
}
class PhotoUUIDInfo(CreateUpdateMixin):
photo_md5 = models.CharField(_(u'photo_md5'), max_length=255, blank=True, null=True, help_text=u'照片唯一标识', db_index=True, unique=True)
photo_path = models.CharField(_(u'photo_path'), max_length=255, blank=True, null=True, help_text=u'照片路径')
photo_w = models.IntegerField(_(u'photo_w'), default=0, help_text=u'照片宽度')
photo_h = models.IntegerField(_(u'photo_h'), default=0, help_text=u'照片高度')
photo_watermark_path = models.CharField(_(u'photo_watermark_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,Box上传,有水印,服务器添加')
photo_watermark_w = models.IntegerField(_(u'photo_watermark_w'), default=0, help_text=u'照片水印图宽度')
photo_watermark_h = models.IntegerField(_(u'photo_watermark_h'), default=0, help_text=u'照片水印图高度')
photo_thumbnail_path = models.CharField(_(u'photo_thumbnail_path'), max_length=255, blank=True, null=True, help_text=u'照片缩略图存放路径')
photo_thumbnail_w = models.IntegerField(_(u'photo_thumbnail_w'), default=0, help_text=u'照片缩略图宽度')
photo_thumbnail_h = models.IntegerField(_(u'photo_thumbnail_h'), default=0, help_text=u'照片缩略图高度')
photo_thumbnail2_path = models.CharField(_(u'photo_thumbnail2_path'), max_length=255, blank=True, null=True, help_text=u'照片缩略图存放路径')
photo_thumbnail2_w = models.IntegerField(_(u'photo_thumbnail2_w'), default=0, help_text=u'照片缩略图宽度')
photo_thumbnail2_h = models.IntegerField(_(u'photo_thumbnail2_h'), default=0, help_text=u'照片缩略图高度')
class Meta:
verbose_name = _('photouuidinfo')
verbose_name_plural = _('photouuidinfo')
def __unicode__(self):
return u'{0.pk}'.format(self)
class PhotosInfo(CreateUpdateMixin):
lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True)
session_id = models.CharField(_(u'session_id'), max_length=255, blank=True, null=True, help_text=u'照片组唯一标识', db_index=True)
photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'照片唯一标识', db_index=True)
p_photo_path = models.CharField(_(u'p_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,Box上传,有水印,服务器添加')
m_photo_path = models.CharField(_(u'm_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,Box上传,无水印')
l_photo_path = models.CharField(_(u'l_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,美化大图')
r_photo_path = models.CharField(_(u'r_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,高清大图')
class Meta:
verbose_name = _('photosinfo')
verbose_name_plural = _('photosinfo')
index_together = [
['lensman_id', 'session_id'],
]
unique_together = (
('lensman_id', 'session_id', 'photo_id'),
)
def __unicode__(self):
return u'{0.pk}'.format(self)
@property
def p_photo_url(self):
return img_url(self.p_photo_path)
@property
def m_photo_url(self):
return img_url(self.m_photo_path)
@property
def l_photo_url(self):
return img_url(self.l_photo_path)
@property
def r_photo_url(self):
return img_url(self.r_photo_path)
@property
def data(self):
return {
'pk': self.pk,
'user_id': self.lensman_id,
'session_id': self.session_id,
'photo_id': self.photo_id,
}
@property
def detail(self):
return {
'pk': self.pk,
'user_id': self.lensman_id,
'session_id': self.session_id,
'photo_id': self.photo_id,
'photo_url': self.p_photo_url,
}
|