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


Python Job.from_json方法代码示例

本文整理汇总了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()
开发者ID:niravshah,项目名称:refrew,代码行数:20,代码来源:views.py

示例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])
开发者ID:niravshah,项目名称:refrew,代码行数:42,代码来源:jobs.py

示例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)
开发者ID:niravshah,项目名称:refrew,代码行数:24,代码来源:jobs.py


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