def final_evaluate(user_id, lid): okr = Okr.query.get(lid) okrlist = json.loads(okr.o_kr) if request.method == 'POST': # 拿到评价的数据以及insert的查询字段 okr_json = request.values.get('okr_json') o_kr = json.loads(okr_json) status = int(o_kr['status']) summary = o_kr['summary'] okrtext = json.dumps(o_kr['okrs']) okr_update = Okr.query.get(lid) okr_update.status = status okr_update.summary = summary okr_update.o_kr = okrtext okr_update.save() if int(status) == OKR_STATUS_EVALUATION_APPLY: flash(u'已发送申请', 'success') account_okr_apply_signal.send(current_app._get_current_object(), okr=okr_update) else: flash(u'修改成功', 'success') return redirect(url_for('account_okr.index')) if okr.status == 6: return tpl('/account/okr/final_evaluate.html', okrlist=okrlist, okr=okr, priority_list=PRIORITY_LIST) else: return tpl( '/account/okr/update_final_eval.html', okrlist=okrlist, okr=okr, )
def final_evaluate(user_id, lid): okr = Okr.query.get(lid) okrlist = json.loads(okr.o_kr) if request.method == 'POST': # 拿到评价的数据以及insert的查询字段 okr_json = request.values.get('okr_json') o_kr = json.loads(okr_json) status = int(o_kr['status']) summary = o_kr['summary'] okrtext = json.dumps(o_kr['okrs']) okr_update = Okr.query.get(lid) okr_update.status = status okr_update.summary = summary okr_update.o_kr = okrtext okr_update.save() if int(status) == OKR_STATUS_EVALUATION_APPLY: flash(u'已发送申请', 'success') account_okr_apply_signal.send( current_app._get_current_object(), okr=okr_update) else: flash(u'修改成功', 'success') return redirect(url_for('account_okr.index')) if okr.status == 6: return tpl('/account/okr/final_evaluate.html', okrlist=okrlist, okr=okr, priority_list=PRIORITY_LIST) else: return tpl('/account/okr/update_final_eval.html', okrlist=okrlist, okr=okr, )
def update(user_id, lid): okr_old = Okr.query.get(lid) if request.method == 'POST': okr_json = request.values.get('okr_json') o_kr = json.loads(okr_json) quarter = int(o_kr['quarter']) status = int(o_kr['status']) year = int(o_kr['year']) okrtext = json.dumps(o_kr['okrs']) if quarter == okr_old.quarter and year == okr_old.year: okr_update = Okr.query.get(lid) okr_update.year = year okr_update.quarter = quarter okr_update.status = status okr_update.o_kr = okrtext okr_update.creator_id = user_id okr_update.save() if int(status) == OKR_STATUS_APPLY: flash(u'已发送申请', 'success') account_okr_apply_signal.send( current_app._get_current_object(), okr=okr_update) else: flash(u'修改成功', 'success') return redirect(url_for('account_okr.index')) elif Okr.query.filter_by(quarter=quarter, year=year, creator=g.user).first(): flash(u'您已经填写过该季度的OKR表了!', 'danger') return tpl('/account/okr/update_new.html', okrlist=o_kr['okrs'], year=year, quarter=quarter, year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST) okr_update = Okr.query.get(lid) okr_update.year = year okr_update.quarter = quarter okr_update.status = status okr_update.o_kr = okrtext okr_update.creator_id = user_id okr_update.save() if int(status) == OKR_STATUS_APPLY: flash(u'已发送申请', 'success') account_okr_apply_signal.send(current_app._get_current_object(), okr=okr_update) else: flash(u'修改成功', 'success') return redirect(url_for('account_okr.index')) okr = Okr.query.get(lid) okrlist = json.loads(okr.o_kr) return tpl('/account/okr/update_new.html', okr=okr, okrlist=okrlist, year=str(okr.year), quarter=okr.quarter, year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST)
def update(user_id, lid): okr_old = Okr.query.get(lid) if request.method == 'POST': okr_json = request.values.get('okr_json') o_kr = json.loads(okr_json) quarter = int(o_kr['quarter']) status = int(o_kr['status']) year = int(o_kr['year']) okrtext = json.dumps(o_kr['okrs']) if quarter == okr_old.quarter and year == okr_old.year: okr_update = Okr.query.get(lid) okr_update.year = year okr_update.quarter = quarter okr_update.status = status okr_update.o_kr = okrtext okr_update.creator_id = user_id okr_update.save() if int(status) == OKR_STATUS_APPLY: flash(u'已发送申请', 'success') account_okr_apply_signal.send( current_app._get_current_object(), okr=okr_update) else: flash(u'修改成功', 'success') return redirect(url_for('account_okr.index')) elif Okr.query.filter_by(quarter=quarter, year=year, creator=g.user).first(): flash(u'您已经填写过该季度的OKR表了!', 'danger') return tpl('/account/okr/update_new.html', okrlist=o_kr['okrs'], year=year, quarter=quarter, year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST) okr_update = Okr.query.get(lid) okr_update.year = year okr_update.quarter = quarter okr_update.status = status okr_update.o_kr = okrtext okr_update.creator_id = user_id okr_update.save() if int(status) == OKR_STATUS_APPLY: flash(u'已发送申请', 'success') account_okr_apply_signal.send( current_app._get_current_object(), okr=okr_update) else: flash(u'修改成功', 'success') return redirect(url_for('account_okr.index')) okr = Okr.query.get(lid) okrlist = json.loads(okr.o_kr) return tpl('/account/okr/update_new.html', okr=okr, okrlist=okrlist, year=str(okr.year), quarter=okr.quarter, year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST)
def status(user_id, lid): okr_status = int(request.values.get('status', 1)) okr = Okr.query.get(lid) okr.status = okr_status okr.save() flash(okr.status_cn, 'success') account_okr_apply_signal.send(current_app._get_current_object(), okr=okr) if status in [OKR_STATUS_APPLY, OKR_STATUS_BACK]: return redirect(url_for('account_okr.index', user_id=user_id)) else: return redirect(url_for('account_okr.subordinates'))
def status(user_id, lid): okr_status = int(request.values.get('status', 1)) okr = Okr.query.get(lid) okr.status = okr_status okr.save() flash(okr.status_cn, 'success') account_okr_apply_signal.send( current_app._get_current_object(), okr=okr) if status in [OKR_STATUS_APPLY, OKR_STATUS_BACK]: return redirect(url_for('account_okr.index', user_id=user_id)) else: return redirect(url_for('account_okr.subordinates'))
def create(): if request.method == 'POST': okr_json = request.values.get('okr_json') o_kr = json.loads(okr_json) status = int(o_kr['status']) year = int(o_kr['year']) quarter = int(o_kr['quarter']) okrtext = json.dumps(o_kr['okrs']) # 判断是否填写过,下拉框 id=quarter if Okr.query.filter_by(quarter=quarter, year=year, creator=g.user).first(): flash(u'您已经填写过该季度的OKR表了!', 'danger') return tpl('/account/okr/update_new.html', okrlist=o_kr['okrs'], year=year, quarter=quarter, year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST) newokr = Okr.add( year=year, quarter=quarter, status=status, o_kr=okrtext, creator=g.user, ) if int(status) == OKR_STATUS_NORMAL: flash(u'添加成功', 'success') else: flash(u'已发送申请', 'success') account_okr_apply_signal.send(current_app._get_current_object(), okr=newokr) return redirect(url_for('account_okr.index')) return tpl('/account/okr/create.html', year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST)
def create(): if request.method == 'POST': okr_json = request.values.get('okr_json') o_kr = json.loads(okr_json) status = int(o_kr['status']) year = int(o_kr['year']) quarter = int(o_kr['quarter']) okrtext = json.dumps(o_kr['okrs']) # 判断是否填写过,下拉框 id=quarter if Okr.query.filter_by(quarter=quarter, year=year, creator=g.user).first(): flash(u'您已经填写过该季度的OKR表了!', 'danger') return tpl('/account/okr/update_new.html', okrlist=o_kr['okrs'], year=year, quarter=quarter, year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST) newokr = Okr.add( year=year, quarter=quarter, status=status, o_kr=okrtext, creator=g.user, ) if int(status) == OKR_STATUS_NORMAL: flash(u'添加成功', 'success') else: flash(u'已发送申请', 'success') account_okr_apply_signal.send( current_app._get_current_object(), okr=newokr) return redirect(url_for('account_okr.index')) return tpl('/account/okr/create.html', year_list=YEAR_LIST, quarters=OKR_QUARTER_CN, priority_list=PRIORITY_LIST)