本文整理汇总了Python中DoctorSpring.models.User.getById方法的典型用法代码示例。如果您正苦于以下问题:Python User.getById方法的具体用法?Python User.getById怎么用?Python User.getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoctorSpring.models.User
的用法示例。
在下文中一共展示了User.getById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getAcountInfo
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
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)
示例2: getMobileVerifyCode
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
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)
示例3: avatarfileUpload
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def avatarfileUpload():
userId=None
if session.has_key('userId'):
userId=session['userId']
if userId is None:
return redirect(LOGIN_URL)
user=User.getById(userId)
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
file_infos.append(dict(
name=filename,
url=fileurl))
result=rs.ResultStatus(rs.SUCCESS.status,rs.SUCCESS.msg,file_infos)
return json.dumps(result.__dict__,ensure_ascii=False)
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)
示例4: updateReport
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
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)
示例5: setConsultsResult
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
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')
示例6: resetPasswd
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
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: addOrUpdateReport
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def addOrUpdateReport():
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.Admin) == False:
return json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)
form = ReportForm(request.form)
formResult=form.validate()
if formResult.status==rs.SUCCESS.status:
diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
if diagnose is None:
return json.dumps(rs.NO_DATA.__dict__,ensure_ascii=False)
#session['remember_me'] = form.remember_me.data
# login and validate the user...
report = None
if form.reportId:
report=Report.getReportById(form.reportId)
if report.type==constant.ReportType.Doctor:
return json.dumps(rs.PERMISSION_DENY.__dict__,ensure_ascii=False)
Report.update(form.reportId,None,form.status,None,form.techDesc,form.imageDesc,form.diagnoseDesc)
else:
report=Report(form.techDesc,form.imageDesc,form.diagnoseDesc,form.fileUrl,ReportType.Admin,form.status)
Report.save(report)
diagnose.reportId=report.id
Diagnose.save(diagnose)
#flash('成功添加诊断评论')
if form.status and form.status == constant.ReportStatus.Commited:
diagnose=Diagnose.getDiagnoseById(form.diagnoseId)
if diagnose:
Diagnose.changeDiagnoseStatus(diagnose.id,constant.DiagnoseStatus.NeedDiagnose)
if form.reportId is None and report:
form.reportId = report.id
Report.update(form.reportId,constant.ReportType.Doctor,status=constant.ReportStatus.Draft)
if diagnose and hasattr(diagnose,'doctor'):
doctor=diagnose.doctor
if doctor and doctor.userId:
content=dataChangeService.getDoctorNeedDiagnoseMessageContent(diagnose,doctor)
#诊断通知
message=Message(constant.DefaultSystemAdminUserId,doctor.userId,'诊断通知',content,constant.MessageType.Diagnose)
Message.save(message)
#诊断日志
diagoseLog=DiagnoseLog(userId,form.diagnoseId,constant.DiagnoseLogAction.FetchDiagnoseEndAction)
DiagnoseLog.save(db_session,diagoseLog)
return json.dumps(formResult.__dict__,ensure_ascii=False)
return json.dumps(formResult.__dict__,ensure_ascii=False)
示例8: setDiagnoseCommentsDetailInfo
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def setDiagnoseCommentsDetailInfo(diagnoseCommentsDict):
if diagnoseCommentsDict is None or len(diagnoseCommentsDict)<1:
return
for diagnoseComment in diagnoseCommentsDict:
if diagnoseComment.has_key('observer'):
observer=diagnoseComment.get('observer')
user=User.getById(observer)
if user:
diagnoseComment['avatar']=user.imagePath
diagnoseComment['senderName']=user.name
if diagnoseComment.has_key('receiver'):
receiver=diagnoseComment.get('receiver')
user=User.getById(receiver)
if user:
#diagnoseComment['receiverName']=user.name
doctor=Doctor.getByUserId(receiver)
if doctor and hasattr(doctor,"hospital") and doctor.hospital :
diagnoseComment['doctorUserId']=receiver
diagnoseComment['hospitalId']= doctor.hospitalId
diagnoseComment['hospitalName']=doctor.hospital.name
diagnoseComment['receiverName']=doctor.username
if diagnoseComment.has_key('diagnoseId'):
diagnose=Diagnose.getDiagnoseById(diagnoseComment.get('diagnoseId'))
if diagnose:
if diagnose.score:
diagnoseComment['scoreName']=constant.DiagnoseScore[diagnose.score]
# if diagnose.hospitalId and hasattr(diagnose,'hospital') and diagnose.hospital and diagnose.hospita.name:
# diagnoseComment['hospitalId']= diagnose.hospitalId
# diagnoseComment['hospitalName']=diagnose.hospital.name
if hasattr(diagnose,"pathology") and diagnose.pathology:
pathology=diagnose.pathology
if hasattr(pathology,"pathologyPostions") and pathology.pathologyPostions:
pathologyPositons=pathology.pathologyPostions
if pathologyPositons and len(pathologyPositons)>0:
positions=u''
for pathologyPositon in pathologyPositons:
position=pathologyPositon.position
positions+=(u' '+position.name)
diagnoseComment['positionName']=positions
示例9: setThanksNoteDetail
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def setThanksNoteDetail(thanksNoteDicts):
if thanksNoteDicts and len(thanksNoteDicts) < 1:
return
for thanksNoteDict in thanksNoteDicts:
if thanksNoteDict.has_key("sender"):
observer = thanksNoteDict.get("sender")
user = User.getById(observer)
if user:
thanksNoteDict["observer"] = observer
thanksNoteDict["observerName"] = user.name
if user.imagePath:
thanksNoteDict["avatarUrl"] = user.imagePath
示例10: updateReport
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
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)
patient_id = Diagnose.get_patientID_by_diagnoseID(form.diagnoseId)
identity_Phone = Patient.get_identityPhone_by_patientID(patient_id)
#identityPhone = Patient.get_identityPhone_by_patientID(patient_id)[0].decode(encoding='UTF-8')
identityPhone = identity_Phone[0]
#print(identityPhone)
if form.reportId:
#session['remember_me'] = form.remember_me.data
# login and validate the user...
if form.status and form.status==constant.ReportStatus.Commited:
#first update based on form , then generate html
Report.update(reportId=form.reportId,techDesc=form.techDesc,imageDesc=form.imageDesc,diagnoseDesc=form.diagnoseDesc)
# fileUrl=pdf_utils.generatorPdf(form.diagnoseId, identityPhone)#需要先生存文檔上傳到服務器,獲取url
fileUrl=pdf_utils.generatorHtml(form.diagnoseId, identityPhone)
if fileUrl:
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:
return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
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)
示例11: renderHtmlFromDiagnose
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def renderHtmlFromDiagnose(diagnose):
if hasattr(diagnose,'report'):
report=diagnose.report
#edit by lichuan , any one can take a look at the html
# if diagnose and report and report.status==ReportStatus.Commited and report.type==ReportType.Doctor:
if diagnose and report:
data={}
data['techDesc']=report.techDesc
data['imageDesc']=report.imageDesc
if hasattr(diagnose,'diagnoseSeriesNumber'):
data['diagnoseSN'] = diagnose.diagnoseSeriesNumber
data['diagnoseDesc']=report.diagnoseDesc
data['seriesNumber']=report.seriesNumber
data['fileUrl']=report.fileUrl
createDate=report.createDate
if createDate:
createDate=createDate.strftime('%Y-%m-%d')
data['createDate']=createDate
postions=dataChangeService.getDiagnosePositonFromDiagnose(diagnose)
if postions:
data['postions']=postions
if hasattr(diagnose,'patient') and diagnose.patient:
data['gender']=diagnose.patient.gender
birthDate=diagnose.patient.birthDate
if birthDate:
birthDate=birthDate.strftime('%Y-%m-%d')
data['birthDate']=pdf_utils.getAge(birthDate)
data['name']=diagnose.patient.realname
if hasattr(diagnose,'doctor'):
data['doctorName']=diagnose.doctor.username
if hasattr(diagnose,'adminId'):
adminUser = User.getById(diagnose.adminId)
if adminUser.name:
data['adminName']= adminUser.name
html = render_template('diagnoseResultPdf.html',data=data)
# fileName=constant.DirConstant.DIAGNOSE_PDF_DIR+'test.pdf'
# result = open(fileName, 'wb') # Changed from file to filename
#
# pdf = pdf_utils.save_pdf(html,result,diagnoseId,fileName)
# result.close()
# return render_template("testpdf.html",getAvatar=getAvatar)
return html
return None
示例12: changePasswd
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
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)
示例13: setConsultsResult
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def setConsultsResult(consutsDict):
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
if type==0:
if consutDict.get('userId'):
user=User.getById(consutDict.get('userId'))
if user:
consutDict['userName']=user.name
consutDict['avartarUrl']=user.imagePath
示例14: endterHospitalUserHome
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def endterHospitalUserHome():
userId=session['userId']
user=User.getById(userId)
if user is None:
return redirect(ERROR_URL)
resultDate={}
# messageCount=Message.getMessageCountByReceiver(userId)
# resultDate['messageCount']=messageCount
#
# diagnoseCount=Diagnose.getNewDiagnoseCountByUserId(userId)
# resultDate['diagnoseCount']=diagnoseCount
#
# resultDate['user']=user
#pager=Pagger(1,20)
# diagnoses=Diagnose.getDiagnosesByDoctorId(db_session,doctor.id,pager)
# diagnoseDict=dataChangeService.userCenterDiagnoses(diagnoses)
# resultDate['diagnoses']=diagnoseDict
return render_template("hospitalUser.html",data=resultDate)
示例15: endterPatientHome
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import getById [as 别名]
def endterPatientHome():
if session.has_key('userId'):
userId=session['userId']
user=User.getById(userId)
if user is None:
return redirect(ERROR_URL)
resultDate={}
messageCount=Message.getMessageCountByReceiver(userId)
resultDate['messageCount']=messageCount
diagnoseCount=Diagnose.getNewDiagnoseCountByUserId(userId)
resultDate['diagnoseCount']=diagnoseCount
resultDate['user']=user
#pager=Pagger(1,20)
# diagnoses=Diagnose.getDiagnosesByDoctorId(db_session,doctor.id,pager)
# diagnoseDict=dataChangeService.userCenterDiagnoses(diagnoses)
# resultDate['diagnoses']=diagnoseDict
return render_template("patientHome.html",data=resultDate)
else:
return redirect(LOGIN_URL)