1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +00:00

update account api

remove 'note' releated operation
This commit is contained in:
lian
2017-01-07 17:00:16 +08:00
parent d89f2cdbf4
commit 53d09bae5e
2 changed files with 3 additions and 18 deletions

View File

@@ -104,18 +104,12 @@ class Account(APIView):
# update account profile # update account profile
name = request.data.get("name", None) name = request.data.get("name", None)
note = request.data.get("note", None) if name is not None:
if name is not None or note is not None:
profile = Profile.objects.get_profile_by_user(email) profile = Profile.objects.get_profile_by_user(email)
if profile is None: if profile is None:
profile = Profile(user=email) profile = Profile(user=email)
if name is not None:
profile.nickname = name profile.nickname = name
if note is not None:
profile.intro = note
profile.save() profile.save()
# update account detailed profile # update account detailed profile
@@ -171,13 +165,6 @@ class Account(APIView):
return api_error(status.HTTP_400_BAD_REQUEST, return api_error(status.HTTP_400_BAD_REQUEST,
_(u"Name should not include '/'.")) _(u"Name should not include '/'."))
# argument check for note
note = request.data.get("note", None)
if note is not None:
if len(note) > 256:
return api_error(status.HTTP_400_BAD_REQUEST,
_(u'Note is too long (maximum is 256 characters)'))
# argument check for department # argument check for department
department = request.data.get("department", None) department = request.data.get("department", None)
if department is not None: if department is not None:

View File

@@ -45,7 +45,7 @@ class AccountTest(BaseTestCase):
def _do_update(self): def _do_update(self):
return self.client.put( return self.client.put(
reverse('api2-account', args=[self.user1.username]), reverse('api2-account', args=[self.user1.username]),
'password=654321&is_staff=1&is_active=0&name=user1&note=this_is_user1&storage=102400', 'password=654321&is_staff=1&is_active=0&name=user1&storage=102400',
'application/x-www-form-urlencoded', 'application/x-www-form-urlencoded',
) )
@@ -101,8 +101,6 @@ class AccountTest(BaseTestCase):
self.assertFalse(User.objects.get(self.user1.username).is_active) self.assertFalse(User.objects.get(self.user1.username).is_active)
self.assertEqual(Profile.objects.get_profile_by_user( self.assertEqual(Profile.objects.get_profile_by_user(
self.user1.username).nickname, 'user1') self.user1.username).nickname, 'user1')
self.assertEqual(Profile.objects.get_profile_by_user(
self.user1.username).intro, 'this_is_user1')
self.assertEqual(seafile_api.get_user_quota( self.assertEqual(seafile_api.get_user_quota(
self.user1.username), 102400000000) self.user1.username), 102400000000)