拍爱

models.py 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # -*- coding: utf-8 -*-
  2. from django.db import models
  3. from django.utils.translation import ugettext_lazy as _
  4. from pai2.basemodels import CreateUpdateMixin
  5. class LensmanInfo(CreateUpdateMixin):
  6. MALE = 0
  7. FEMALE = 1
  8. SEX_TYPE = (
  9. (MALE, u'男'),
  10. (FEMALE, u'女'),
  11. )
  12. lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True, unique=True)
  13. username = models.CharField(_(u'username'), max_length=255, blank=True, null=True, help_text=u'摄影师用户名', db_index=True, unique=True)
  14. password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'摄影师密码')
  15. encryption = models.CharField(_(u'encryption'), max_length=255, blank=True, null=True, help_text=u'摄影师密码')
  16. name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'摄影师姓名')
  17. sex = models.IntegerField(_(u'sex'), choices=SEX_TYPE, default=MALE, help_text=u'摄影师性别')
  18. phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'摄影师电话', db_index=True, unique=True)
  19. location = models.CharField(_(u'location'), max_length=255, blank=True, null=True, help_text=u'摄影师地址')
  20. proportion = models.FloatField(_(u'proportion'), default=1.0, help_text=u'摄影师分成比例(0.0 ~ 1.0)')
  21. signup_ip = models.CharField(_(u'signup_ip'), max_length=255, blank=True, null=True, help_text=_(u'注册IP'))
  22. login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP'))
  23. login_at = models.DateTimeField(_(u'login_at'), blank=True, null=True, help_text=_(u'登录时间'))
  24. class Meta:
  25. verbose_name = _(u'lensmaninfo')
  26. verbose_name_plural = _(u'lensmaninfo')
  27. def __unicode__(self):
  28. return unicode(self.pk)
  29. class LensmanLoginLogInfo(CreateUpdateMixin):
  30. SUCCESS = 0
  31. PWD_ERROR = 1
  32. OTHER = 2
  33. LOGIN_RESULT = (
  34. (SUCCESS, u'登录成功'),
  35. (PWD_ERROR, u'密码错误'),
  36. (OTHER, u'其他'),
  37. )
  38. lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True)
  39. login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP'))
  40. login_result = models.IntegerField(_(u'login_result'), choices=LOGIN_RESULT, default=SUCCESS)
  41. class Meta:
  42. verbose_name = _(u'lensmanloginloginfo')
  43. verbose_name_plural = _(u'lensmanloginloginfo')
  44. def __unicode__(self):
  45. return unicode(self.pk)
  46. class UserInfo(CreateUpdateMixin):
  47. APP_USER = 0
  48. WX_USER = 1
  49. USER_FROM = (
  50. (APP_USER, u'APP 创建用户'),
  51. (WX_USER, u'微信授权用户'),
  52. )
  53. UNVERIFIED = 0
  54. ACTIVATED = 1
  55. DISABLED = 2
  56. DELETED = 3
  57. ASSIGN = 10
  58. USER_STATUS = (
  59. (UNVERIFIED, u'未验证'),
  60. (ACTIVATED, u'已激活'),
  61. (DISABLED, u'已禁用'),
  62. (DELETED, u'已删除'),
  63. (ASSIGN, u'已分配'),
  64. )
  65. MALE = 0
  66. FEMALE = 1
  67. SEX_TYPE = (
  68. (MALE, u'男'),
  69. (FEMALE, u'女'),
  70. )
  71. user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True, unique=True)
  72. user_from = models.IntegerField(_(u'user_from'), choices=USER_FROM, default=APP_USER, help_text=u'用户来源')
  73. # APP 创建用户
  74. username = models.CharField(_(u'username'), max_length=255, blank=True, null=True, help_text=u'用户用户名', db_index=True, unique=True)
  75. password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'用户密码')
  76. # 微信授权用户
  77. wx_uid = models.CharField(_(u'wx_uid'), max_length=255, blank=True, null=True, help_text=u'微信唯一标识', db_index=True, unique=True)
  78. # 用户基本信息
  79. name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'用户姓名')
  80. sex = models.IntegerField(_(u'sex'), choices=SEX_TYPE, default=MALE, help_text=u'用户性别')
  81. nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户昵称')
  82. avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像')
  83. phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'用户电话', db_index=True, unique=True)
  84. country = models.CharField(_(u'country'), max_length=255, blank=True, null=True, help_text=u'用户国家')
  85. province = models.CharField(_(u'province'), max_length=255, blank=True, null=True, help_text=u'用户省份')
  86. city = models.CharField(_(u'city'), max_length=255, blank=True, null=True, help_text=u'用户城市')
  87. location = models.CharField(_(u'location'), max_length=255, blank=True, null=True, help_text=u'用户地址')
  88. user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS, default=UNVERIFIED)
  89. assign_ip = models.CharField(_(u'assign_ip'), max_length=255, blank=True, null=True, help_text=_(u'分配IP'))
  90. assign_at = models.DateTimeField(_(u'assign_at'), blank=True, null=True, help_text=_(u'分配时间'))
  91. signup_ip = models.CharField(_(u'signup_ip'), max_length=255, blank=True, null=True, help_text=_(u'注册IP'))
  92. signup_at = models.DateTimeField(_(u'signup_at'), blank=True, null=True, help_text=_(u'注册时间'))
  93. login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP'))
  94. login_at = models.DateTimeField(_(u'login_at'), blank=True, null=True, help_text=_(u'登录时间'))
  95. class Meta:
  96. verbose_name = _(u'userinfo')
  97. verbose_name_plural = _(u'userinfo')
  98. def __unicode__(self):
  99. return unicode(self.pk)
  100. @property
  101. def final_nickname(self):
  102. if self.user_from == self.APP_USER:
  103. return self.username
  104. elif self.user_from == self.WX_USER:
  105. return self.nickname
  106. def _data(self):
  107. return {
  108. 'user_id': self.user_id,
  109. 'username': self.username,
  110. 'nickname': self.nickname,
  111. }
  112. data = property(_data)
  113. class UserLoginLogInfo(CreateUpdateMixin):
  114. SUCCESS = 0
  115. PWD_ERROR = 1
  116. OTHER = 2
  117. LOGIN_RESULT = (
  118. (SUCCESS, u'登录成功'),
  119. (PWD_ERROR, u'密码错误'),
  120. (OTHER, u'其他'),
  121. )
  122. user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
  123. login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP'))
  124. login_result = models.IntegerField(_(u'login_result'), choices=LOGIN_RESULT, default=SUCCESS)
  125. class Meta:
  126. verbose_name = _(u'userloginloginfo')
  127. verbose_name_plural = _(u'userloginloginfo')
  128. def __unicode__(self):
  129. return unicode(self.pk)