mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-17 07:41:26 +00:00
update account api
remove 'note' releated operation
This commit is contained in:
@@ -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:
|
||||||
|
@@ -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¬e=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)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user