Esempio 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 UserProfile.objects.filter(mobile=mobile):
             return JsonResponse({"status": "该手机号码已被占用"})
         user = request.user
         user.mobile = mobile
         user.username = mobile
         user.save()
         return JsonResponse({"status": "success"})
     else:
         return JsonResponse(mobile_form.errors)
Esempio 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 request.user.mobile == mobile:
             return JsonResponse({'mobile': '该号码和当前号码一致'})
         elif UserProfile.objects.filter(mobile=mobile):
             return JsonResponse({'mobile': '该手机号码已经被占用'})
         else:
             user = request.user
             user.mobile = mobile
             user.username = mobile
             user.save()
             return JsonResponse({'status': 'success'})
     else:
         return JsonResponse(mobile_form.errors)
Esempio n. 3
0
    def post(self,request,*args,**kwargs):
        mobile_forms=UpdateMobileForm(request.POST)

        if mobile_forms.is_valid():
            mobile=mobile_forms.cleaned_data['mobile']
            #已经存在的数据不能重复注册
            if UserProfile.objects.filter(mobile=mobile):
                return JsonResponse({'mobile':'该手机手机号已被占用'})
            user=request.user
            user.mobile=mobile
            user.username=mobile
            user.save()
            # login(request)
            return JsonResponse({'status':'success'})
        else:
            return JsonResponse(mobile_forms.errors)
Esempio 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': '该手机号已经被占用',
             })
         else:
             user = request.user
             user.mobile = mobile
             user.username = mobile
             user.save()
             # logout(request) # 可选择是否推出
             return JsonResponse({
                 'status': 'success',
             })
     else:
         return JsonResponse(mobile_form.errors)
Esempio n. 5
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)
Esempio n. 6
0
 def get(self, request):
     """个人资料显示"""
     mobile_form = UpdateMobileForm(request.POST)
     return render(request, 'usercenter-info.html', {'mobile_form': mobile_form, 'active': 'user_info'})