mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 16:41:56 +00:00
增加逻辑判断用户名重复的问题
This commit is contained in:
parent
f3be10161f
commit
e84039eea1
@ -145,10 +145,10 @@ class UserChangePasswordAPITest(APITestCase):
|
||||
self.assertEqual(response.data, {"code": 0, "data": u"用户密码修改成功!"})
|
||||
|
||||
|
||||
class UserAPITest(APITestCase):
|
||||
class UserAdminAPITest(APITestCase):
|
||||
def setUp(self):
|
||||
self.client = APIClient()
|
||||
self.url = reverse("user_list_api")
|
||||
self.url = reverse("user_admin_api")
|
||||
user = User.objects.create(username="testx", real_name="xx", admin_type=SUPER_ADMIN)
|
||||
user.set_password("testxx")
|
||||
user.save()
|
||||
|
@ -135,6 +135,12 @@ class UserAdminAPIView(APIView):
|
||||
user = User.objects.get(id=data["id"])
|
||||
except User.DoesNotExist:
|
||||
return error_response(u"该用户不存在!")
|
||||
try:
|
||||
user = User.objects.get(username=data["username"])
|
||||
if user.id != data["id"]:
|
||||
return error_response(u"昵称已经存在")
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
user.username = data["username"]
|
||||
user.real_name = data["real_name"]
|
||||
user.email = data["email"]
|
||||
|
Loading…
Reference in New Issue
Block a user