当前位置: 首页>>代码示例>>Python>>正文


Python models.User类代码示例

本文整理汇总了Python中DoctorSpring.models.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: avatarfileUpload

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)
开发者ID:LichuanLu,项目名称:redberry,代码行数:35,代码来源:user_center.py

示例2: validate

 def validate(self):
     try:
         if self.email is None or "@" not in self.email:
             failure = ResultStatus(FAILURE.status, "邮箱地址格式不正确")
             return failure
         else:
             user = User.get_by_name(self.email)
             if user is not None:
                 failure = ResultStatus(FAILURE.status, "邮箱地址已注册")
                 return failure
         if self.username is None:
             failure = ResultStatus(FAILURE.status, "用户名为空")
             return failure
         if self.password is None:
             failure = ResultStatus(FAILURE.status, "密码为空")
             return failure
         if self.real_name is None:
             failure = ResultStatus(FAILURE.status, "真实姓名为空")
             return failure
         if self.identity_phone is None:
             failure = ResultStatus(FAILURE.status, "注册号码为空")
             return failure
         if self.cellphone is None:
             failure = ResultStatus(FAILURE.status, "手机号码格式不对")
             return failure
         else:
             user = User.get_by_name(self.cellphone)
             if user is not None:
                 failure = ResultStatus(FAILURE.status, "手机号码已注册")
                 return failure
     except Exception, e:
         return FAILURE
开发者ID:LichuanLu,项目名称:redberry,代码行数:32,代码来源:forms.py

示例3: updateAcountInfo

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)
开发者ID:LichuanLu,项目名称:blueberry,代码行数:27,代码来源:user_center.py

示例4: test_add_patient

 def test_add_patient(self):
     new_user = User("[email protected]", "123456")
     new_user.type = UserStatus.patent
     User.save(new_user)
     new_patient = Patient(new_user.id)
     Patient.save(new_patient)
     new_userrole = UserRole(new_user.id, RoleId.Patient)
     UserRole.save(new_userrole)
开发者ID:LichuanLu,项目名称:blueberry,代码行数:8,代码来源:base_model.py

示例5: resetPasswd

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)
开发者ID:LichuanLu,项目名称:redberry,代码行数:9,代码来源:user_center.py

示例6: test_addKefu

    def test_addKefu(self):
        user=User('kefu','77777777777','123456')
        user.sex=0
        user.status=0
        user.email='[email protected]'
        user.address='四川省 通江县'
        user.phone = '77777777777'
        user.type = UserStatus.doctor
        user.name = "客服人员"
        User.save(user)

        new_userrole2 = UserRole(user.id, RoleId.Kefu)
        UserRole.save(new_userrole2)
开发者ID:LichuanLu,项目名称:redberry,代码行数:13,代码来源:real_model.py

示例7: test_addFenzhen

    def test_addFenzhen(self):
        user=User('fenzhen','13426026573','123456')
        user.sex=0
        user.status=0
        user.email='[email protected]'
        user.address='四川省 通江县'
        user.phone = '13426026573'
        user.type = UserStatus.doctor
        user.name = "分诊医生"
        User.save(user)

        new_userrole2 = UserRole(user.id, RoleId.Admin)
        UserRole.save(new_userrole2)
开发者ID:LichuanLu,项目名称:redberry,代码行数:13,代码来源:real_model.py

示例8: register_patient

def register_patient():
    form = RegisterFormPatent(request.form)
    form_result = form.validate()
    if form_result.status == rs.SUCCESS.status:
        new_user = User(form.nickname, form.name, form.password)
        new_user.type = UserStatus.patent
        User.save(new_user)
        new_userrole = UserRole(new_user.id, RoleId.Patient)
        UserRole.save(new_userrole)
        login_session(new_user)
        form_result.msg = request.host_url + "homepage"
        return jsonify(form_result.__dict__, ensure_ascii=False)

    return jsonify(form_result.__dict__, ensure_ascii=False)
开发者ID:LichuanLu,项目名称:redberry,代码行数:14,代码来源:user_view.py

示例9: setConsultsResult

def setConsultsResult(consutsDict, userId=0):
    if consutsDict is None:
        return
    for consutDict in consutsDict:
        type=consutDict.get('type')
        if type==1:
            if consutDict.get('doctorId'):
                    doctor=Doctor.getById(consutDict.get('doctorId'))
                    if doctor:
                        consutDict['doctorName']=doctor.username
                        consutDict['doctorTitle']=doctor.title
                        if hasattr(doctor,'user') and doctor.user and doctor.user.imagePath:
                            consutDict['avartarUrl']= doctor.user.imagePath
                    consutDict["statusText"] = getStatusText(consutDict.get("status"),
                                                             UserRole.checkRole(db_session,userId,constant.RoleId.Doctor))

        if type==0:
            if consutDict.get('userId'):
                user=User.getById(consutDict.get('userId'))
                if user:
                    consutDict['userName']=user.name
                    consutDict['avartarUrl']=user.imagePath
                    consutDict["statusText"] = getStatusText(consutDict.get("status"),
                                                             UserRole.checkRole(db_session,userId,constant.RoleId.Doctor))
        consutDict['amount']=consutDict.get('count')
开发者ID:LichuanLu,项目名称:redberry,代码行数:25,代码来源:data_change_service.py

示例10: updateReport

def updateReport():

    userId=session['userId']
    user=User.getById(userId)
    if user is None:
        return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)

    # if UserRole.checkRole(db_session,userId,constant.RoleId.Doctor):
    #     return  json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)

    form =  ReportForm(request.form)

    if form.reportId:
        #session['remember_me'] = form.remember_me.data
        # login and validate the user...
        if form.status and form.status==constant.ReportStatus.Commited:

            fileUrl=pdf_utils.generatorPdf(form.diagnoseId)#需要先生存文檔上傳到服務器,獲取url
            report=Report.update(form.reportId,constant.ReportType.Doctor,form.status,fileUrl,form.techDesc,form.imageDesc,form.diagnoseDesc)
            Diagnose.changeDiagnoseStatus(form.diagnoseId,constant.DiagnoseStatus.Diagnosed)
            #需要給用戶發信和記錄操作日誌
            diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
            sendMessageAndRecordLog(diagnose,userId)

        else:
            fileUrl=None#這是草稿,不需要生存文檔

            diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
            if diagnose is None:
                return  json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
            report=Report.update(form.reportId,constant.ReportType.Doctor,form.status,fileUrl,form.techDesc,form.imageDesc,form.diagnoseDesc)
            recordDiagnoseLog(diagnose,userId)

        return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
    return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
开发者ID:LichuanLu,项目名称:blueberry,代码行数:35,代码来源:diagnose.py

示例11: getAcountInfo

def getAcountInfo():
    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']
    #userId='5'
    if userId is None:
        return redirect(LOGIN_URL)
    user=User.getById(userId)
    if user:
        userDict=object2dict.to_json(user,user.__class__)
        if type==2:
            result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,userDict)
            return json.dumps(result.__dict__,ensure_ascii=False)
        elif type==1:
            userDict=dataChangeService.getAccountInfo(userDict)
            result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,userDict)
            return json.dumps(result.__dict__,ensure_ascii=False)
        else:
            return  json.dumps(rs.PARAM_ERROR.__dict__,ensure_ascii=False)

    return json.dumps(rs.NO_LOGIN.__dict__,ensure_ascii=False)
开发者ID:LichuanLu,项目名称:blueberry,代码行数:26,代码来源:user_center.py

示例12: checkVerifyCode

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)
开发者ID:LichuanLu,项目名称:redberry,代码行数:32,代码来源:user_center.py

示例13: getMobileVerifyCode

def getMobileVerifyCode():
    try:
        from DoctorSpring.util import verify_code,sms_utils
        verifyCode= verify_code.generatorVerifyCode()
        LOG.info("产生验证码")
        session['verifyCode']=verifyCode
        telPhoneNo=None
        userId=session.get('userId')
        diagnoseId=request.args.get('diagnoseId')

        diagnose=Diagnose.getDiagnoseById(diagnoseId)

        if diagnose and hasattr(diagnose,'patient') and diagnose.patient:
            telPhoneNo=diagnose.patient.identityPhone
            if telPhoneNo is None and hasattr(diagnose.patient,'user') and diagnose.patient.user:
                telPhoneNo=diagnose.patient.user.phone
        if telPhoneNo is None:
            user=User.getById(userId)
            telPhoneNo=user.phone
        if telPhoneNo:
            smsRc=sms_utils.RandCode()
            template_param = {'param1':verifyCode}
            smsRc.send_emp_sms(telPhoneNo,smsRc.TEMPLATE_ID_1,json.dumps(template_param))
            return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)
        else:
            LOG.error("诊断[%s]发送验证码错误"%diagnoseId)
            return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)

    except Exception,e:
        LOG.error(e.message)
        return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
开发者ID:LichuanLu,项目名称:redberry,代码行数:31,代码来源:user_center.py

示例14: updateDoctorInfo

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)
开发者ID:LichuanLu,项目名称:redberry,代码行数:17,代码来源:user_center.py

示例15: changePasswd

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)
开发者ID:LichuanLu,项目名称:blueberry,代码行数:18,代码来源:user_center.py


注:本文中的DoctorSpring.models.User类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。