Sin Descripción

models.py 6.9KB

    # -*- coding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from pai2.basemodels import CreateUpdateMixin class LensmanInfo(CreateUpdateMixin): MALE = 0 FEMALE = 1 SEX_TYPE = ( (MALE, u'男'), (FEMALE, u'女'), ) lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True, unique=True) username = models.CharField(_(u'username'), max_length=255, blank=True, null=True, help_text=u'摄影师用户名', db_index=True, unique=True) password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'摄影师密码') encryption = models.CharField(_(u'encryption'), max_length=255, blank=True, null=True, help_text=u'摄影师密码') 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, unique=True) location = models.CharField(_(u'location'), max_length=255, blank=True, null=True, help_text=u'摄影师地址') proportion = models.FloatField(_(u'proportion'), default=1.0, help_text=u'摄影师分成比例(0.0 ~ 1.0)') signup_ip = models.CharField(_(u'signup_ip'), max_length=255, blank=True, null=True, help_text=_(u'注册IP')) login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP')) login_at = models.DateTimeField(_(u'login_at'), blank=True, null=True, help_text=_(u'登录时间')) class Meta: verbose_name = _(u'lensmaninfo') verbose_name_plural = _(u'lensmaninfo') def __unicode__(self): return unicode(self.pk) class LensmanLoginLogInfo(CreateUpdateMixin): SUCCESS = 0 PWD_ERROR = 1 OTHER = 2 LOGIN_RESULT = ( (SUCCESS, u'登录成功'), (PWD_ERROR, u'密码错误'), (OTHER, u'其他'), ) lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True) login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP')) login_result = models.IntegerField(_(u'login_result'), choices=LOGIN_RESULT, default=SUCCESS) class Meta: verbose_name = _(u'lensmanloginloginfo') verbose_name_plural = _(u'lensmanloginloginfo') def __unicode__(self): return unicode(self.pk) class UserInfo(CreateUpdateMixin): APP_USER = 0 WX_USER = 1 USER_FROM = ( (APP_USER, u'APP 创建用户'), (WX_USER, u'微信授权用户'), ) UNVERIFIED = 0 ACTIVATED = 1 DISABLED = 2 DELETED = 3 ASSIGN = 10 USER_STATUS = ( (UNVERIFIED, u'未验证'), (ACTIVATED, u'已激活'), (DISABLED, u'已禁用'), (DELETED, u'已删除'), (ASSIGN, u'已分配'), ) MALE = 1 FEMALE = 0 SEX_TYPE = ( (MALE, u'男'), (FEMALE, u'女'), ) user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True, unique=True) user_from = models.IntegerField(_(u'user_from'), choices=USER_FROM, default=APP_USER, help_text=u'用户来源') # APP 创建用户 username = models.CharField(_(u'username'), max_length=255, blank=True, null=True, help_text=u'用户用户名', db_index=True, unique=True) password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'用户密码') # 微信授权用户 wx_uid = models.CharField(_(u'wx_uid'), max_length=255, blank=True, null=True, help_text=u'微信唯一标识', db_index=True, unique=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'用户性别') nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户昵称') avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像') phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'用户电话', db_index=True, unique=True) country = models.CharField(_(u'country'), max_length=255, blank=True, null=True, help_text=u'用户国家') province = models.CharField(_(u'province'), max_length=255, blank=True, null=True, help_text=u'用户省份') city = models.CharField(_(u'city'), max_length=255, blank=True, null=True, help_text=u'用户城市') location = models.CharField(_(u'location'), max_length=255, blank=True, null=True, help_text=u'用户地址') user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS, default=UNVERIFIED) assign_ip = models.CharField(_(u'assign_ip'), max_length=255, blank=True, null=True, help_text=_(u'分配IP')) assign_at = models.DateTimeField(_(u'assign_at'), blank=True, null=True, help_text=_(u'分配时间')) signup_ip = models.CharField(_(u'signup_ip'), max_length=255, blank=True, null=True, help_text=_(u'注册IP')) signup_at = models.DateTimeField(_(u'signup_at'), blank=True, null=True, help_text=_(u'注册时间')) login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP')) login_at = models.DateTimeField(_(u'login_at'), blank=True, null=True, help_text=_(u'登录时间')) class Meta: verbose_name = _(u'userinfo') verbose_name_plural = _(u'userinfo') def __unicode__(self): return unicode(self.pk) @property def final_nickname(self): if self.user_from == self.APP_USER: return self.username elif self.user_from == self.WX_USER: return self.nickname @property def data(self): return { 'user_id': self.user_id, 'username': self.username, 'nickname': self.nickname, } class UserLoginLogInfo(CreateUpdateMixin): SUCCESS = 0 PWD_ERROR = 1 OTHER = 2 LOGIN_RESULT = ( (SUCCESS, u'登录成功'), (PWD_ERROR, u'密码错误'), (OTHER, u'其他'), ) user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) login_ip = models.CharField(_(u'login_ip'), max_length=255, blank=True, null=True, help_text=_(u'登录IP')) login_result = models.IntegerField(_(u'login_result'), choices=LOGIN_RESULT, default=SUCCESS) class Meta: verbose_name = _(u'userloginloginfo') verbose_name_plural = _(u'userloginloginfo') def __unicode__(self): return unicode(self.pk)