Sin Descripción

models.py 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # -*- coding: utf-8 -*-
  2. from django.db import models
  3. from django.utils.translation import ugettext_lazy as _
  4. from django_models_ext import BaseModelMixin, SexModelMixin
  5. from shortuuidfield import ShortUUIDField
  6. class ScreenAdminInfo(BaseModelMixin):
  7. ACTIVATED = 1
  8. DISABLED = 2
  9. DELETED = 3
  10. USER_STATUS_TUPLE = (
  11. (ACTIVATED, u'已激活'),
  12. (DISABLED, u'已禁用'),
  13. (DELETED, u'已删除'),
  14. )
  15. admin_id = ShortUUIDField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'大屏管理员唯一标识', db_index=True, unique=True)
  16. unionid = models.CharField(_(u'unionid'), max_length=32, blank=True, null=True, help_text=u'微信 Union ID', db_index=True)
  17. openid = models.CharField(_(u'openid'), max_length=32, blank=True, null=True, help_text=u'微信 Open ID', db_index=True)
  18. name = models.CharField(_(u'name'), max_length=8, blank=True, null=True, help_text=u'用户姓名')
  19. sex = models.IntegerField(_(u'sex'), choices=SexModelMixin.SEX_TUPLE, default=SexModelMixin.UNKNOWN, help_text=u'用户性别')
  20. nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户昵称')
  21. avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像')
  22. phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'用户电话', db_index=True)
  23. country = models.CharField(_(u'country'), max_length=16, blank=True, null=True, help_text=u'用户国家')
  24. province = models.CharField(_(u'province'), max_length=16, blank=True, null=True, help_text=u'用户省份')
  25. city = models.CharField(_(u'city'), max_length=16, blank=True, null=True, help_text=u'用户城市')
  26. location = models.CharField(_(u'location'), max_length=255, blank=True, null=True, help_text=u'用户地址')
  27. brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
  28. brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
  29. user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS_TUPLE, default=ACTIVATED, help_text=u'管理员状态', db_index=True)
  30. class Meta:
  31. verbose_name = _(u'ScreenAdminInfo')
  32. verbose_name_plural = _(u'ScreenAdminInfo')
  33. unique_together = (
  34. ('brand_id', 'unionid', 'openid'),
  35. )
  36. def __unicode__(self):
  37. return unicode(self.pk)
  38. @property
  39. def data(self):
  40. return {
  41. 'admin_id': self.admin_id,
  42. 'nickname': self.nickname,
  43. 'avatar': self.avatar,
  44. }