本文整理汇总了Python中models.Job.from_json方法的典型用法代码示例。如果您正苦于以下问题:Python Job.from_json方法的具体用法?Python Job.from_json怎么用?Python Job.from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Job
的用法示例。
在下文中一共展示了Job.from_json方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: jobs
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import from_json [as 别名]
def jobs():
if request.method == 'POST':
form = AddJobForm(request.form)
if request_has_json():
try:
json_data = json.dumps(request.json,default=json_util.default)
model = Job.from_json(json_data)
model.save()
except ValidationError as e:
return jsonify(item=str(e))
else:
if form.validate():
form.save()
else:
return render_template('add_job.html',form=form)
return list_jobs()
else:
return list_jobs()
示例2: job
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import from_json [as 别名]
def job(jobid):
if request.method == 'GET':
job = Job.objects(jobid=int(jobid)).first()
stages = Stage.objects(job=job)
ref = Referral.objects(job=job)
if request_wants_json():
return mongodoc_jsonify(item=job.to_mongo())
else:
return render_template('list_job.html', job=job, referrals=ref, stages=stages)
if request.method == 'PUT':
job = Job.objects(jobid=int(jobid)).first()
if request_has_json():
json_data = json.dumps(request.json, default=json_util.default)
model = Job.from_json(json_data)
job.locationName = model.locationName
job.title = model.title
job.permOrCont = model.permOrCont
job.remuneration = model.remuneration
job.tSkill1 = model.tSkill1
job.tSkill2 = model.tSkill2
job.tSkill3 = model.tSkill3
job.pSkill1 = model.pSkill1
job.pSkill2 = model.pSkill2
job.pSkill3 = model.pSkill3
job.qalNeeded = model.qalNeeded
job.qal = model.qal
job.projChar1 = model.projChar1
job.projChar2 = model.projChar2
job.projChar3 = model.projChar3
job.teamChar1 = model.teamChar1
job.teamChar2 = model.teamChar2
job.teamChar3 = model.teamChar3
job.save()
'''Job.objects(jobid=int(jobid)).first().update(json_data)'''
return mongodoc_jsonify(item=job.reload().to_mongo())
else:
form = AddJobForm(request.form)
form.populate_obj(job)
job.save()
return render_template('list_job.html', jobs=[job])
示例3: jobs
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import from_json [as 别名]
def jobs():
if request.method == 'POST':
form = AddJobForm(request.form)
if request_has_json():
try:
json_data = json.dumps(request.json, default=json_util.default)
model = Job.from_json(json_data)
model.save()
return mongodoc_jsonify(item=model.to_mongo())
except ValidationError as e:
return jsonify(item=str(e))
else:
if form.validate():
form.save()
else:
return render_template('add_job.html', form=form)
return list_jobs(10, 0)
else:
records_to_fetch = request.args.get('rec', 10)
last = request.args.get('last', 0)
user = request.args.get('user', '')
return list_jobs(records_to_fetch, last, user)