拍爱

models.py 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # -*- coding: utf-8 -*-
  2. from django.db import models
  3. from django.utils.translation import ugettext_lazy as _
  4. from models_ext import BaseModelMixin
  5. from shortuuidfield import ShortUUIDField
  6. class BrandInfo(BaseModelMixin):
  7. brand_id = ShortUUIDField(_(u'brand_id'), max_length=32, help_text=u'品牌唯一标识', db_index=True, unique=True)
  8. brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
  9. brand_descr = models.TextField(_(u'brand_descr'), max_length=255, blank=True, null=True, help_text=u'品牌描述')
  10. position = models.IntegerField(_(u'position'), default=1, help_text=u'排序')
  11. class Meta:
  12. verbose_name = _(u'品牌信息')
  13. verbose_name_plural = _(u'品牌信息')
  14. def __unicode__(self):
  15. return unicode(self.pk)
  16. @property
  17. def data(self):
  18. return {
  19. 'brand_id': self.brand_id,
  20. 'brand_name': self.brand_name,
  21. 'brand_descr': self.brand_descr,
  22. }
  23. class ModelInfo(BaseModelMixin):
  24. model_id = ShortUUIDField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True, unique=True)
  25. model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称')
  26. model_descr = models.TextField(_(u'model_descr'), max_length=255, blank=True, null=True, help_text=u'型号描述')
  27. position = models.IntegerField(_(u'position'), default=1, help_text=u'排序')
  28. class Meta:
  29. verbose_name = _(u'型号信息')
  30. verbose_name_plural = _(u'型号信息')
  31. def __unicode__(self):
  32. return unicode(self.pk)
  33. @property
  34. def data(self):
  35. return {
  36. 'model_id': self.model_id,
  37. 'model_name': self.model_name,
  38. 'model_descr': self.model_descr,
  39. }
  40. class DistributorInfo(BaseModelMixin):
  41. distributor_id = ShortUUIDField(_(u'distributor_id'), max_length=32, help_text=u'经销商唯一标识', db_index=True, unique=True)
  42. distributor_name = models.CharField(_(u'distributor_name'), max_length=255, blank=True, null=True, help_text=u'经销商名称')
  43. distributor_descr = models.TextField(_(u'distributor_descr'), max_length=255, blank=True, null=True, help_text=u'经销商描述')
  44. position = models.IntegerField(_(u'position'), default=1, help_text=u'排序')
  45. class Meta:
  46. verbose_name = _(u'经销商信息')
  47. verbose_name_plural = _(u'经销商信息')
  48. def __unicode__(self):
  49. return unicode(self.pk)
  50. @property
  51. def data(self):
  52. return {
  53. 'distributor_id': self.distributor_id,
  54. 'distributor_name': self.distributor_name,
  55. 'distributor_descr': self.distributor_descr,
  56. }