Exemplo n.º 1
0
    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 ''
Exemplo n.º 2
0
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())
Exemplo n.º 3
0
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())
Exemplo n.º 4
0
def expression_add_get():
    g.menu = 'expressions'
    a = None
    o = Expression.get(int(request.args.get('id', '0').strip()))
    if o:
        a = Action.get(o.action_id)
    return render_template('expression/add.html',
                           data={'action': a, 'expression': o, 'uic_address': UIC_ADDRESS['external']})
Exemplo n.º 5
0
def expression_view_get(eid):
    eid = int(eid)
    g.menu = 'expressions'
    a = None
    o = Expression.get(eid)
    if o:
        a = Action.get(o.action_id)
    else:
        return 'no such expression'
    return render_template('expression/view.html', data={'action': a, 'expression': o})
Exemplo n.º 6
0
def expression_view_get(eid):
    eid = int(eid)
    g.menu = "expressions"
    a = None
    o = Expression.get(eid)
    if o:
        a = Action.get(o.action_id)
    else:
        return "no such expression"
    return render_template("expression/view.html", data={"action": a, "expression": o}, config=config)
Exemplo n.º 7
0
def expression_add_get():
    g.menu = "expressions"
    a = None
    o = Expression.get(int(request.args.get("id", "0").strip()))
    if o:
        a = Action.get(o.action_id)
    return render_template(
        "expression/add.html",
        data={"action": a, "expression": o, "uic_address": UIC_ADDRESS["external"]},
        config=config,
    )
Exemplo n.º 8
0
def template_update_get(tpl_id):
    g.menu = 'templates'
    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('template/update.html', data={'tpl': t, 'ss': ss, 'uic': UIC_ADDRESS['external']})
Exemplo n.º 9
0
def expression_add_get():
    g.menu = 'expressions'
    a = None
    o = Expression.get(int(request.args.get('id', '0').strip()))
    if o:
        a = Action.get(o.action_id)
    return render_template('expression/add.html',
                           data={
                               'action': a,
                               'expression': o,
                               'uic_address': UIC_ADDRESS['external']
                           })
Exemplo n.º 10
0
def expression_view_get(eid):
    eid = int(eid)
    g.menu = 'expressions'
    a = None
    o = Expression.get(eid)
    if o:
        a = Action.get(o.action_id)
    else:
        return 'no such expression'
    return render_template('expression/view.html',
                           data={
                               'action': a,
                               'expression': o
                           })
Exemplo n.º 11
0
def expressions_get():
    g.menu = "expressions"
    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(
        "expression/list.html",
        data={"vs": vs, "total": total, "query": query, "limit": limit, "page": page, "mine": mine},
        config=config,
    )
Exemplo n.º 12
0
def template_update_get(tpl_id):
    g.menu = 'templates'
    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('template/update.html',
                           data={
                               'tpl': t,
                               'ss': ss,
                               'uic': UIC_ADDRESS['external']
                           })
Exemplo n.º 13
0
def expressions_get():
    g.menu = 'expressions'
    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('expression/list.html',
                           data={
                               'vs': vs,
                               'total': total,
                               'query': query,
                               'limit': limit,
                               'page': page,
                               'mine': mine,
                           })
Exemplo n.º 14
0
def expressions_get():
    g.menu = 'expressions'
    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(
        'expression/list.html',
        data={
            'vs': vs,
            'total': total,
            'query': query,
            'limit': limit,
            'page': page,
            'mine': mine,
        }
    )
Exemplo n.º 15
0
    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 ''