コード例 #1
0
ファイル: user_center.py プロジェクト: LichuanLu/blueberry
def updateAcountInfo():
    type=request.args.get('type')
    if type:
        type=string.atoi(type)  #医生:1 病人:2
    else:
        type=2
    userId=None
    if session.has_key('userId'):
        userId=session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form=UserUpdateForm(request.form)
    paraRs=form.validate()
    if rs.SUCCESS.status==paraRs.status:
        User.update(userId,form.name,form.account,form.mobile,form.address,form.email,form.identityCode,form.yibaoCard)
        if type==1:
            doctor=Doctor(userId)
            doctor.identityPhone=form.identityPhone
            hospitalId=Doctor.update(doctor)
            if hospitalId:
                hospital=Hospital(form.hospitalName)
                hospital.id=hospitalId
                Hospital.updateHospital(hospital)

        return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)

    return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
コード例 #2
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def avatarfileUpload():
    userId = None
    userId = request.form.get("userId")
    if session.has_key('userId') and userId is None:
        userId = session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    userId = string.atoi(userId)
    user = User.getById(userId, None)
    if user is None:
        return json.dumps(rs.ResultStatus(rs.FAILURE.status, "账户不存在"),
                          ensure_ascii=False)

    try:
        if request.method == 'POST':
            file_infos = []
            files = request.files
            for key, file in files.iteritems():
                if file and isPicture(file.filename):
                    filename = file.filename
                    # file_url = oss_util.uploadFile(diagnoseId, filename)
                    from DoctorSpring.util.oss_util import uploadAvatarFromFileStorage
                    fileurl = uploadAvatarFromFileStorage(
                        userId, filename, file, '', {})
                    if fileurl:
                        user.imagePath = fileurl
                        User.update(userId, imagePath=fileurl)
                        file_infos.append(dict(name=filename, url=fileurl))
                        return jsonify(files=file_infos)
                else:
                    return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
        return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
    except Exception, e:
        print e.message
        return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
コード例 #3
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def updateAcountInfo():
    type = request.form.get('type')
    if type:
        type = string.atoi(type)  #医生:1 病人:2
    else:
        type = 2
    userId = None
    if session.has_key('userId'):
        userId = session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form = UserUpdateForm(request.form)
    paraRs = form.validate()
    if rs.SUCCESS.status == paraRs.status:
        User.update(userId, form.name, form.account, form.mobile, form.address,
                    form.email, form.identityCode, form.yibaoCard)
        if type == 1:
            doctor = Doctor(userId)
            doctor.identityPhone = form.identityPhone
            doctor.username = form.name
            hospitalId = Doctor.update(doctor)
            # if hospitalId:
            #     hospital=Hospital(form.hospitalName)
            #     hospital.id=hospitalId
            #     Hospital.updateHospital(hospital)

        return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)

    return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
コード例 #4
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def avatarfileUpload():
    userId=None
    userId=request.form.get("userId")
    if session.has_key('userId') and userId is None:
        userId=session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    userId = string.atoi(userId)
    user=User.getById(userId,None)
    if user is None:
        return  json.dumps(rs.ResultStatus(rs.FAILURE.status,"账户不存在"),ensure_ascii=False )

    try:
        if request.method == 'POST':
            file_infos = []
            files = request.files
            for key, file in files.iteritems():
                if file and isPicture(file.filename):
                    filename = file.filename
                    # file_url = oss_util.uploadFile(diagnoseId, filename)
                    from DoctorSpring.util.oss_util import uploadAvatarFromFileStorage
                    fileurl = uploadAvatarFromFileStorage(userId, filename, file,'',{})
                    if fileurl:
                        user.imagePath=fileurl
                        User.update(userId,imagePath=fileurl)
                        file_infos.append(dict(
                                           name=filename,
                                           url=fileurl))
                        return jsonify(files=file_infos)
                else:
                    return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
        return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
    except Exception,e:
        print e.message
        return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
コード例 #5
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def resetPasswd(mobileNumber):
    userId = str(int(User.get_id_by_phone(mobileNumber)[0]))
    form = UserResetPasswdForm(request.form)
    result = form.validate()
    if result.status == rs.SUCCESS.status:
        user = User.getById(userId)
        newHashPasswd = generate_password_hash(form.newPasswd)
        User.update(userId, passwd=newHashPasswd)
    return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
コード例 #6
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def resetPasswd(mobileNumber):
    userId=str(int(User.get_id_by_phone(mobileNumber)[0]))
    form=UserResetPasswdForm(request.form)
    result=form.validate()
    if result.status==rs.SUCCESS.status:
        user = User.getById(userId)
        newHashPasswd=generate_password_hash(form.newPasswd)
        User.update(userId,passwd=newHashPasswd)
    return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
コード例 #7
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def checkVerifyCode():
    code = request.form.get('verifyCode')
    mobile = request.form.get('mobile')
    verifyCode = session.get('verifyCode')
    userId = session.get('userId')

    if verifyCode is None:
        result = rs.ResultStatus(rs.FAILURE.status, "请重新产生验证码")
        return json.dumps(result.__dict__, ensure_ascii=False)
    if code is None:
        result = rs.ResultStatus(rs.FAILURE.status, "验证码不能为空,请输入验证码")
        return json.dumps(result.__dict__, ensure_ascii=False)
    if code == verifyCode:
        if mobile:
            import re
            #p = re.compile(r"((13|14|15|18)d{9}$)")
            if len(mobile) == 11:
                user = User.update(userId,
                                   mobile=mobile,
                                   isBindPhone=constant.UserPhoneBind.Binded)
                if user:
                    return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
                else:
                    result = rs.ResultStatus(rs.FAILURE.status, "更新失败")
                    return json.dumps(result.__dict__, ensure_ascii=False)
            else:
                result = rs.ResultStatus(rs.FAILURE.status, "输入的电话号码格式有问题")
                return json.dumps(result.__dict__, ensure_ascii=False)
        else:
            result = rs.ResultStatus(rs.FAILURE.status, "请输入电话号码")
            return json.dumps(result.__dict__, ensure_ascii=False)
    else:
        result = rs.ResultStatus(rs.FAILURE.status, "验证码错误,请重新输入验证码")
        return json.dumps(result.__dict__, ensure_ascii=False)
コード例 #8
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def checkVerifyCode():
    code=request.form.get('verifyCode')
    mobile=request.form.get('mobile')
    verifyCode=session.get('verifyCode')
    userId=session.get('userId')

    if verifyCode is None:
        result=rs.ResultStatus(rs.FAILURE.status,"请重新产生验证码")
        return  json.dumps(result.__dict__,ensure_ascii=False)
    if code is None:
        result=rs.ResultStatus(rs.FAILURE.status,"验证码不能为空,请输入验证码")
        return  json.dumps(result.__dict__,ensure_ascii=False)
    if code == verifyCode:
        if mobile:
            import re
            #p = re.compile(r"((13|14|15|18)d{9}$)")
            if len(mobile)==11:
                user=User.update(userId,mobile=mobile,isBindPhone=constant.UserPhoneBind.Binded);
                if user:
                    return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
                else:
                    result=rs.ResultStatus(rs.FAILURE.status,"更新失败")
                    return  json.dumps(result.__dict__,ensure_ascii=False)
            else:
                result=rs.ResultStatus(rs.FAILURE.status,"输入的电话号码格式有问题")
                return  json.dumps(result.__dict__,ensure_ascii=False)
        else:
            result=rs.ResultStatus(rs.FAILURE.status,"请输入电话号码")
            return  json.dumps(result.__dict__,ensure_ascii=False)
    else:
        result=rs.ResultStatus(rs.FAILURE.status,"验证码错误,请重新输入验证码")
        return  json.dumps(result.__dict__,ensure_ascii=False)
コード例 #9
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def updateDoctorInfo():
    form = DoctorUpdateForm(request.form)
    doctor = Doctor(form.userId)
    doctor.departmentId = form.department
    doctor.hospitalId = form.hospital
    doctor.status = form.status
    doctor.title = form.title
    Doctor.update(doctor)
    doctor = Doctor.getByUserId(form.userId)

    if doctor:
        for skill in form.skills:
            doctorsKill = Doctor2Skill(doctor.id, skill)
            Doctor2Skill.save(doctorsKill)
    User.update(form.userId, status=constant.ModelStatus.Normal)
    result = rs.ResultStatus(rs.SUCCESS.status, rs.SUCCESS.msg, None)
    return json.dumps(result.__dict__, ensure_ascii=False)
コード例 #10
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def updateDoctorInfo():
    form=DoctorUpdateForm(request.form)
    doctor=Doctor(form.userId)
    doctor.departmentId=form.department
    doctor.hospitalId=form.hospital
    doctor.status=form.status
    doctor.title=form.title
    Doctor.update(doctor)
    doctor=Doctor.getByUserId(form.userId)

    if doctor:
        for skill in form.skills:
            doctorsKill=Doctor2Skill(doctor.id,skill)
            Doctor2Skill.save(doctorsKill)
    User.update(form.userId,status=constant.ModelStatus.Normal)
    result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,None)
    return  json.dumps(result.__dict__,ensure_ascii=False)
コード例 #11
0
ファイル: user_center.py プロジェクト: LichuanLu/redberry
def changePasswd():
    userId = None
    if session.has_key('userId'):
        userId = session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form = UserChangePasswdForm(request.form)
    result = form.validate()
    if result.status == rs.SUCCESS.status:
        user = User.getById(userId)
        if user and user.check_password(form.oldPasswd):
            newHashPasswd = generate_password_hash(form.newPasswd)
            User.update(userId, passwd=newHashPasswd)
            return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)
        else:
            resultStatus = rs.ResultStatus(rs.FAILURE.status, "未登录或者密码错误")
            return json.dumps(resultStatus.__dict__, ensure_ascii=False)
    return json.dumps(result.__dict__, ensure_ascii=False)
コード例 #12
0
ファイル: user_center.py プロジェクト: LichuanLu/blueberry
def changePasswd():
    userId=None
    if session.has_key('userId'):
        userId=session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form=UserChangePasswdForm(request.form)
    result=form.validate()
    if result.status==rs.SUCCESS.status:
        user = User.getById(userId)
        if user and user.check_password(form.oldPasswd):
            newHashPasswd=generate_password_hash(form.newPasswd)
            User.update(userId,passwd=newHashPasswd)
            return  json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
        else:
            resultStatus=rs.ResultStatus(rs.FAILURE.status,"未登录或者密码错误")
            return json.dumps(resultStatus.__dict__,ensure_ascii=False)
    return json.dumps(result.__dict__,ensure_ascii=False)