def check_username(request): username = request.REQUEST.get('username') count = User.objects.filter(username=username).count() if count > 0: return getResult(False, u'用户名已经注册过了') else: return getResult(True, u'用户名可用')
def check_username(request): username = request.REQUEST.get('username') count=User.objects.filter(username=username).count() if count>0: return getResult(False,u'用户名已经注册过了') else: return getResult(True,u'用户名可用')
def androidSave(request): ap = getParam(request) del ap['res'] if isinstance(ap, HttpResponse): return getResult(False, ap.content, None) result = save(ap, request.user) return getResult(result.get('success'), result.get('msg', {}).get('desc', u''), result)
def userDeviceid(request): ''' 重置用户设备 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) user.person.deviceid=None user.person.save() return getResult(True, u'注销用户设备指纹成功,用户可以使用新的设备。') except: return getResult(False, u'用户不存在') return getResult(False, u'请传递用户id')
def userPassword(request): ''' 离职用户 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) user.set_password('111111') user.save() return getResult(True, u'重置用户密码成功') except: return getResult(False, u'用户不存在') return getResult(False, u'请传递用户id')
def userDelete(request): ''' 离职用户 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) user.is_active = False user.save() return getResult(True, u'设置用户离职成功') except: return getResult(False, u'用户不存在') return getResult(False, u'请传递用户id')
def userDeviceid(request): ''' 重置用户设备 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) user.person.deviceid = None user.person.save() return getResult(True, u'注销用户设备指纹成功,用户可以使用新的设备。') except: return getResult(False, u'用户不存在') return getResult(False, u'请传递用户id')
def userPassword(request): ''' 离职用户 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) user.set_password('111111') user.save() return getResult(True, u'重置用户密码成功') except: return getResult(False, u'用户不存在') return getResult(False, u'请传递用户id')
def userDelete(request): ''' 离职用户 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) user.is_active = False user.save() return getResult(True, u'设置用户离职成功') except: return getResult(False, u'用户不存在') return getResult(False, u'请传递用户id')
def userSave(request): ''' 保存用户信息 ''' id = request.REQUEST.get('userid') username = request.REQUEST.get('ygbh') fullname = request.REQUEST.get('truename') sex = request.REQUEST.get('sex') tel = request.REQUEST.get('tel') if id: user = User.objects.get(pk=id) user.first_name = fullname user.is_active = True person = user.person if not person: person = Person() else: user = User() user.username = username user.set_password('111111') user.first_name = fullname user.is_active = True person = Person() count=User.objects.filter(username=username).count() if count>0: return getResult(False,u'用户名已经注册过了') user.save() person.user = user if sex == '0': person.sex = True else: person.sex = False person.tel = tel person.save() if id: message = u'修改成功' else: message = u'添加成功' return getResult(True, message, user.id)
def userSave(request): ''' 保存用户信息 ''' id = request.REQUEST.get('userid') username = request.REQUEST.get('ygbh') fullname = request.REQUEST.get('truename') sex = request.REQUEST.get('sex') tel = request.REQUEST.get('tel') if id: user = User.objects.get(pk=id) user.first_name = fullname user.is_active = True person = user.person if not person: person = Person() else: user = User() user.username = username user.set_password('111111') user.first_name = fullname user.is_active = True person = Person() count = User.objects.filter(username=username).count() if count > 0: return getResult(False, u'用户名已经注册过了') user.save() person.user = user if sex == '0': person.sex = True else: person.sex = False person.tel = tel person.save() if id: message = u'修改成功' else: message = u'添加成功' return getResult(True, message, user.id)
def userOpen(request): ''' 离职用户 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) # if user.is_active: user.is_active = True msg=u'开通用户成功' # else: # user.is_active = False # msg=u'设置用户离职成功' user.save() return getResult(True,msg ) except: return getResult(False, msg) return getResult(False, u'请传递用户id')
def userOpen(request): ''' 离职用户 ''' id = request.REQUEST.get('userid') if id: try: user = User.objects.get(pk=id) # if user.is_active: user.is_active = True msg = u'开通用户成功' # else: # user.is_active = False # msg=u'设置用户离职成功' user.save() return getResult(True, msg) except: return getResult(False, msg) return getResult(False, u'请传递用户id')
def clientLogin(request): if request.method == "POST": username = request.POST.get('username') if username: userlist = User.objects.filter(username=username)[:1] if len(userlist) > 0: user = userlist[0] if not user.is_active: return getResult(False, u'用户已经离职,不能在使用本系统。') form = AuthenticationForm(data=request.POST) if form.is_valid(): # Okay, security checks complete. Log the user in. auth_login(request, form.get_user()) if request.session.test_cookie_worked(): request.session.delete_test_cookie() return getResult(True, u'登录成功') else: return getResult(False, u'用户名密码错误')
def clientLogin(request): if request.method == "POST": username = request.POST.get('username') if username: userlist = User.objects.filter(username=username)[:1] if len(userlist)>0: user=userlist[0] if not user.is_active: return getResult(False,u'用户已经离职,不能在使用本系统。') form = AuthenticationForm(data=request.POST) if form.is_valid(): # Okay, security checks complete. Log the user in. auth_login(request, form.get_user()) if request.session.test_cookie_worked(): request.session.delete_test_cookie() return getResult(True,u'登录成功') else: return getResult(False,u'用户名密码错误')