| @@ -0,0 +1,19 @@ | ||
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +from __future__ import unicode_literals | |
| 3 | + | |
| 4 | +from django.db import models, migrations | |
| 5 | + | |
| 6 | + | |
| 7 | +class Migration(migrations.Migration): | |
| 8 | + | |
| 9 | + dependencies = [ | |
| 10 | +        ('account', '0007_auto_20160120_1830'), | |
| 11 | + ] | |
| 12 | + | |
| 13 | + operations = [ | |
| 14 | + migrations.AddField( | |
| 15 | + model_name='userinfo', | |
| 16 | + name='unionid', | |
| 17 | + field=models.CharField(help_text='\u5fae\u4fe1 Union ID', max_length=255, null=True, verbose_name='unionid', blank=True), | |
| 18 | + ), | |
| 19 | + ] | 
| @@ -102,6 +102,8 @@ class UserInfo(CreateUpdateMixin): | ||
| 102 | 102 | password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'用户密码') | 
| 103 | 103 | # 微信授权用户 | 
| 104 | 104 | wx_uid = models.CharField(_(u'wx_uid'), max_length=255, blank=True, null=True, help_text=u'微信唯一标识', db_index=True, unique=True) | 
| 105 | + unionid = models.CharField(_(u'unionid'), max_length=255, blank=True, null=True, help_text=u'微信 Union ID') | |
| 106 | + # openid = models.CharField(_(u'openid'), max_length=255, blank=True, null=True, help_text=u'微信 Open ID') | |
| 105 | 107 | # 用户基本信息 | 
| 106 | 108 | name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'用户姓名') | 
| 107 | 109 | sex = models.IntegerField(_(u'sex'), choices=SEX_TYPE, default=MALE, help_text=u'用户性别') | 
| @@ -133,6 +133,8 @@ def wx_authorize_api(request): | ||
| 133 | 133 |      user_id = request.POST.get('user_id', '') | 
| 134 | 134 |      wx_uid = request.POST.get('wx_uid', '') | 
| 135 | 135 |  | 
| 136 | +    unionid = request.POST.get('unionid', '') | |
| 137 | + | |
| 136 | 138 |      sex = request.POST.get('sex', 0) | 
| 137 | 139 |      nickname = request.POST.get('nickname', '') or request.POST.get('screen_name', '') | 
| 138 | 140 |      avatar = request.POST.get('headimgurl', '') or request.POST.get('profile_image_url', '') | 
| @@ -147,6 +149,7 @@ def wx_authorize_api(request): | ||
| 147 | 149 | user = None | 
| 148 | 150 |  | 
| 149 | 151 | if user: | 
| 152 | + user.unionid = unionid | |
| 150 | 153 | user.sex = sex | 
| 151 | 154 | user.nickname = nickname | 
| 152 | 155 | user.avatar = avatar | 
| @@ -174,6 +177,7 @@ def wx_authorize_api(request): | ||
| 174 | 177 | if user and user.user_status == UserInfo.ASSIGN: | 
| 175 | 178 | user.user_from = UserInfo.WX_USER | 
| 176 | 179 | user.wx_uid = wx_uid | 
| 180 | + user.unionid = unionid | |
| 177 | 181 | user.sex = sex | 
| 178 | 182 | user.nickname = nickname | 
| 179 | 183 | user.avatar = avatar | 
| @@ -188,6 +192,7 @@ def wx_authorize_api(request): | ||
| 188 | 192 | user_id=CurtailUUID.uuid(UserInfo, 'user_id'), | 
| 189 | 193 | user_from=UserInfo.WX_USER, | 
| 190 | 194 | wx_uid=wx_uid, | 
| 195 | + unionid=unionid, | |
| 191 | 196 | sex=sex, | 
| 192 | 197 | nickname=nickname, | 
| 193 | 198 | avatar=avatar, |