Няма описание

models.py 1.4KB

    # -*- 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 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_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 '' def _data(self): return { 'pk': self.pk, 'lensman_id': self.lensman_id, 'session_id': self.session_id, 'photo_id': self.photo_id, 'photo_url': self.photo_url, } data = property(_data)