Skip to content

Commit

Permalink
fix(userdetail): 修改不能改名的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyueLongguikeji committed Nov 5, 2019
1 parent 545c2f8 commit 16ec589
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
23 changes: 23 additions & 0 deletions oneid_meta/migrations/0063_auto_20191104_1454.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.0.13 on 2019-11-04 06:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('oneid_meta', '0062_auto_20191102_1745'),
]

operations = [
migrations.AlterField(
model_name='dinguser',
name='account',
field=models.CharField(blank=True, max_length=64, verbose_name='钉钉账号(手机)'),
),
migrations.AlterField(
model_name='dinguser',
name='uid',
field=models.CharField(blank=True, max_length=255, verbose_name='员工在企业内的唯一标识'),
),
]
4 changes: 2 additions & 2 deletions oneid_meta/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ class DingUser(BaseModel):
钉钉用户
'''
user = models.OneToOneField(User, verbose_name='用户', related_name='ding_user', on_delete=models.PROTECT)
account = models.CharField(max_length=64, blank=False, verbose_name='钉钉账号(手机)')
uid = models.CharField(max_length=255, blank=False, verbose_name='员工在企业内的唯一标识')
account = models.CharField(max_length=64, blank=True, verbose_name='钉钉账号(手机)')
uid = models.CharField(max_length=255, blank=True, verbose_name='员工在企业内的唯一标识')
data = models.TextField(blank=True, default='{}', verbose_name='钉钉员工详细数据(JSON)')
ding_id = models.TextField(max_length=255, blank=True, verbose_name='钉钉ID')
open_id = models.TextField(max_length=255, blank=True, verbose_name='用户在当前开放应用内的唯一标识')
Expand Down
27 changes: 27 additions & 0 deletions siteapi/v1/tests/test_ding.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,33 @@ def test_ding_register_bind(self, mock_clear_sms_token, mock_check_sms_token):
self.assertEqual(res.status_code, 201)
self.assertIn('token', res.json())

@mock.patch('siteapi.v1.serializers.ucenter.SMSClaimSerializer.check_sms_token')
@mock.patch('siteapi.v1.serializers.ucenter.SMSClaimSerializer.clear_sms_token')
def test_patch_name(self, mock_clear_sms_token, mock_check_sms_token):
client = self.client
mock_clear_sms_token.return_value = True
mock_check_sms_token.side_effect = [{'mobile': '18812341234'}]
res = client.post(reverse('siteapi:ding_register_bind'),
data={
'username': 'username',
'password': 'password',
'sms_token': 'test_sms_token',
'user_id': 'test_ding_id'
})
patch_data = {
'username': 'username',
'name': 'new_name',
'ding_usre': {
'account': "",
'uid': "",
'data': "{}"
},
}
res = client.json_patch(reverse('siteapi:user_detail', args=('username', )), patch_data)
self.assertEqual(res.status_code, 200)
res = res.json()['user']
self.assertIn('new_name', res['name'])

def test_ding_qr_register_forbidden(self):
client = self.client
account_config = AccountConfig.get_current()
Expand Down

0 comments on commit 16ec589

Please sign in to comment.