def update_expression(cls, expression_id, content, func, op, right_value, uic_groups, max_step, priority, note, url, callback, before_callback_sms, before_callback_mail, after_callback_sms, after_callback_mail): e = Expression.get(expression_id) if not e: return 'no such expression %s' % expression_id a = Action.get(e.action_id) if not a: return 'no relation action' Action.update_dict( { 'uic': uic_groups, 'url': url, 'callback': callback, 'before_callback_sms': before_callback_sms, 'before_callback_mail': before_callback_mail, 'after_callback_sms': after_callback_sms, 'after_callback_mail': after_callback_mail }, 'id=%s', [a.id]) Expression.update_dict( { 'expression': content, 'func': func, 'op': op, 'right_value': right_value, 'max_step': max_step, 'priority': priority, 'note': note, }, 'id=%s', [e.id]) return ''
def api_action_get(action_id): action_id = int(action_id) a = Action.get(action_id) if not a: return jsonify(msg="no such action") return jsonify(msg='', data=a.to_json())
def expression_add_get(): a = None o = Expression.get(int(request.args.get('id', '0').strip())) if o: a = Action.get(o.action_id) return render_template('portal/expression/add.html', data={'action': a, 'expression': o})
def expression_view_get(eid): eid = int(eid) a = None o = Expression.get(eid) if o: a = Action.get(o.action_id) else: return 'no such expression' return render_template('portal/expression/view.html', data={'action': a, 'expression': o})
def template_view_get(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') t.parent = Template.get(t.parent_id) ss = Strategy.select_vs(where='tpl_id = %s', params=[tpl_id], order='metric') t.action = Action.get(t.action_id) return render_template('portal/template/view.html', data={'tpl': t, 'ss': ss})
def template_view_get(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') t.parent = Template.get(t.parent_id) ss = Strategy.select_vs(where='tpl_id = %s', params=[tpl_id], order='metric') t.action = Action.get(t.action_id) return render_template('portal/template/view.html', data={ 'tpl': t, 'ss': ss })
def expressions_get(): page = int(request.args.get('p', 1)) limit = int(request.args.get('limit', 6)) query = request.args.get('q', '').strip() mine = request.args.get('mine', '1') me = g.user.name if mine == '1' else None vs, total = Expression.query(page, limit, query, me) for v in vs: v.action = Action.get(v.action_id) return render_template('portal/expression/list.html', data={ 'vs': vs, 'total': total, 'query': query, 'limit': limit, 'page': page, 'mine': mine, })
def template_update_get(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') t.parent = Template.get(t.parent_id) ss = Strategy.select_vs(where='tpl_id = %s', params=[tpl_id], order='metric') t.action = Action.get(t.action_id) log.debug(t) for s in ss: s.hook = Hook.total(where="strategy_id={id}".format(id=s.id)) return render_template('portal/template/update.html', data={ 'tpl': t, 'ss': ss })
def expressions_get(): page = int(request.args.get('p', 1)) limit = int(request.args.get('limit', 6)) query = request.args.get('q', '').strip() mine = request.args.get('mine', '1') me = g.user.name if mine == '1' else None vs, total = Expression.query(page, limit, query, me) for v in vs: v.action = Action.get(v.action_id) return render_template( 'portal/expression/list.html', data={ 'vs': vs, 'total': total, 'query': query, 'limit': limit, 'page': page, 'mine': mine, } )
def update_expression(cls, expression_id, content, func, op, right_value, uic_groups, max_step, priority, note, url, callback, before_callback_sms, before_callback_mail, after_callback_sms, after_callback_mail): e = Expression.get(expression_id) if not e: return 'no such expression %s' % expression_id a = Action.get(e.action_id) if not a: return 'no relation action' Action.update_dict( { 'uic': uic_groups, 'url': url, 'callback': callback, 'before_callback_sms': before_callback_sms, 'before_callback_mail': before_callback_mail, 'after_callback_sms': after_callback_sms, 'after_callback_mail': after_callback_mail }, 'id=%s', [a.id] ) Expression.update_dict( { 'expression': content, 'func': func, 'op': op, 'right_value': right_value, 'max_step': max_step, 'priority': priority, 'note': note, }, 'id=%s', [e.id] ) return ''