當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。