|
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from pai2.basemodels import CreateUpdateMixin
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)
def _data(self):
return {
'pk': self.pk,
'uuid': self.uuid,
'lensman_id': self.lensman_id,
}
data = property(_data)
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, unique=True)
photo_name = models.CharField(_(u'photo_name'), max_length=255, blank=True, null=True, help_text=u'照片存放名称')
photo_path = models.CharField(_(u'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'],
]
def __unicode__(self):
return u'{0.pk}'.format(self)
@property
def photo_url(self):
return u'{0}/media/{1}'.format(settings.DOMAIN, self.photo_path) if self.photo_path else ''
# return u'{0}/p/{1}'.format(settings.DOMAIN, self.photo_name) if self.photo_name else ''
def _data(self):
return {
'pk': self.pk,
'user': self.lensman_id,
'session': self.session_id,
'photo': self.photo_id,
# 'photo_url': self.photo_url,
}
data = property(_data)
|