说明书

models.py 3.2KB

    # -*- coding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from shortuuidfield import ShortUUIDField from manual.basemodels import CreateUpdateMixin class MachineBodyInfo(CreateUpdateMixin): body = models.CharField(_(u'body'), max_length=255, blank=True, null=True, help_text=u'机身', unique=True) position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') class Meta: verbose_name = _(u'机身配置') verbose_name_plural = _(u'机身配置') def __unicode__(self): return unicode(self.body) @property def data(self): return { 'pk': self.pk, 'body': self.body, } class MachineBackInfo(CreateUpdateMixin): back = models.CharField(_(u'back'), max_length=255, blank=True, null=True, help_text=u'机背', unique=True) position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') class Meta: verbose_name = _(u'机背配置') verbose_name_plural = _(u'机背配置') def __unicode__(self): return unicode(self.back) @property def data(self): return { 'pk': self.pk, 'back': self.back, } class MachineSupportPrebookInfo(CreateUpdateMixin): MALE = 1 FEMALE = 0 SEX_TYPE = ( (MALE, u'男'), (FEMALE, u'女'), ) SLICE0 = 0 SLICE1 = 1 SLICE2 = 2 SLICE3 = 3 TIME_SLICE = ( (SLICE0, u'09:00 - 12:00'), (SLICE1, u'12:00 - 14:00'), (SLICE2, u'14:00 - 18:00'), (SLICE3, u'18:00 - 21:00'), ) NOT_HANDLE = 0 HAS_CONTACTED = 1 HAS_HANDLED = 10 HANDLE_STATUS = ( (NOT_HANDLE, u'未处理'), (HAS_CONTACTED, u'已联系'), (HAS_HANDLED, u'已处理'), ) prebook_id = ShortUUIDField(_(u'prebook_id'), max_length=255, help_text=u'支持唯一标识', db_index=True, unique=True) user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'用户姓名') sex = models.IntegerField(_(u'sex'), choices=SEX_TYPE, default=MALE, help_text=u'用户性别') phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'用户电话', db_index=True) weekday = models.IntegerField(_(u'weekday'), default=0, help_text=u'周几:周日为0', db_index=True) timeslice = models.IntegerField(_(u'timeslice'), default=SLICE0, choices=TIME_SLICE, help_text=u'时间段', db_index=True) body = models.ForeignKey(MachineBodyInfo, verbose_name=_(u'body'), blank=True, null=True, help_text=u'机身') back = models.ForeignKey(MachineBackInfo, verbose_name=_(u'back'), blank=True, null=True, help_text=u'机背') handle_status = models.IntegerField(_(u'handle_status'), choices=HANDLE_STATUS, default=NOT_HANDLE, help_text=u'处理状态') class Meta: verbose_name = _(u'machinesupportprebookinfo') verbose_name_plural = _(u'machinesupportprebookinfo') def __unicode__(self): return unicode(self.pk)