Ejemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     mobile_form = UpdateMobileForm(request.POST)
     if mobile_form.is_valid():
         mobile = mobile_form.cleaned_data["mobile"]
         #已经存在的记录不能重复注册
         # if request.user.mobile == mobile:
         #     return JsonResponse({
         #         "mobile": "和当前号码一致"
         #     })
         if UserProfile.objects.filter(mobile=mobile):
             return JsonResponse({"mobile": "该手机号码已经被占用"})
         user = request.user
         user.mobile = mobile
         user.username = mobile
         user.save()
         return JsonResponse({"status": "success"})
     else:
         return JsonResponse(mobile_form.errors)
Ejemplo n.º 2
0
 def post(self, request, *args, **kwargs):
     mobile_form = UpdateMobileForm(request.POST)
     if mobile_form.is_valid():
         mobile = mobile_form.cleaned_data["mobile"]
         #已经存在的记录不能重复注册
         if UserProfile.objects.filter(mobile=mobile):
             return JsonResponse({
                 "status": "fail"
             })
         user = request.user
         user.mobile = mobile
         user.username = mobile
         user.save()
         # logout(request)
         return JsonResponse({
             "status": "success"
         })
     else:
         return JsonResponse(mobile_form.errors)
Ejemplo n.º 3
0
    def post(self, request, *args, **kwargs):
        mobile_form = UpdateMobileForm(request.POST)
        if mobile_form.is_valid():
            mobile = mobile_form.cleaned_data['mobile']
            # 已经存在的记录不能重复注册
            if request.user.mobile == mobile:
                return JsonResponse({
                    'mobile':'和当前号码一致'
                })

            if UserProfile.objects.filter(mobile=mobile):
                return JsonResponse({
                    'mobile': '该手机号已经被占用'
                })
            user = request.user
            user.mobile = mobile
            user.username = mobile
            user.save()
            return JsonResponse({
                'status':'success'
            })
        else:
            return JsonResponse(mobile_form.errors)
Ejemplo n.º 4
0
 def post(self, request, *args, **kwargs):
     mobile_form = UpdateMobileForm(request.POST)
     if mobile_form.is_valid():
         mobile = mobile_form.cleaned_data["mobile"]
         # 已经注册过的手机号不能再注册
         # if request.user.mobile==mobile:
         #     return JsonResponse({
         #         "mobile":"和当前号码一致",
         #     })
         if UserProfile.objects.filter(mobile=mobile):
             return JsonResponse({
                 "mobile": "手机号已被注册",
             })
         user = request.user
         user.mobile = mobile
         user.username = mobile
         user.save()
         # logout(request)
         return JsonResponse({
             "status": "success",
         })
     # 表单验证失败
     else:
         return JsonResponse(mobile_form.errors)