Example #1
0
def packs():
    packs = Pack.query \
        .options(
            db.joinedload(Pack.tags),
            db.joinedload(Pack.queries),
            db.joinedload(Pack.queries, Query.packs, innerjoin=True)
        ).all()
    return render_template('packs.html', packs=packs)
Example #2
0
def queries():
    queries = Query.query \
        .options(
            db.joinedload(Query.tags),
            db.joinedload(Query.packs),
            db.joinedload(Query.packs, Pack.queries, innerjoin=True)
        ).all()
    return render_template('queries.html', queries=queries)
Example #3
0
def queries():
    queries = Query.query \
        .options(
            db.joinedload(Query.tags),
            db.joinedload(Query.packs),
            db.joinedload(Query.packs, Pack.queries, innerjoin=True)
        ).all()
    return render_template('queries.html', queries=queries)
Example #4
0
def packs():
    packs = Pack.query \
        .options(
            db.joinedload(Pack.tags),
            db.joinedload(Pack.queries),
            db.joinedload(Pack.queries, Query.packs, innerjoin=True)
        ).all()
    return render_template('packs.html', packs=packs)
Example #5
0
def queries():
    queries = Query.query \
        .options(
            db.lazyload('*'),
            db.joinedload(Query.packs),
            db.contains_eager(Query.tags),
        ).join(Query.tags).all()
    return render_template('queries.html', queries=queries)
Example #6
0
def get_node(node_id):
    node = Node.query.filter_by(id=node_id).first_or_404()
    form = UpdateNodeForm(request.form)

    if form.validate_on_submit():
        node_info = node.node_info.copy()

        if form.display_name.data:
            node_info['display_name'] = form.display_name.data
        elif 'display_name' in node_info:
            node_info.pop('display_name')

        node.node_info = node_info
        node.is_active = form.is_active.data
        node.save()

        if request.is_xhr:
            return '', 204

        return redirect(url_for('manage.get_node', node_id=node.id))

    form = UpdateNodeForm(request.form, obj=node)
    flash_errors(form)

    packs = node.packs \
        .options(
            db.joinedload(Pack.tags, innerjoin=True),
            db.joinedload(Pack.queries, innerjoin=True),
        ).order_by(Pack.name)

    queries = node.queries \
        .options(
            db.joinedload(Query.tags, innerjoin=True),
            db.joinedload(Query.packs)
        ).order_by(Query.name)

    return render_template('node.html',
                           form=form,
                           node=node,
                           packs=packs,
                           queries=queries)
Example #7
0
def get_node(node_id):
    node = Node.query.filter_by(id=node_id).first_or_404()
    form = UpdateNodeForm(request.form)

    if form.validate_on_submit():
        node_info = node.node_info.copy()

        if form.display_name.data:
            node_info['display_name'] = form.display_name.data
        elif 'display_name' in node_info:
            node_info.pop('display_name')

        node.node_info = node_info
        node.is_active = form.is_active.data
        node.save()

        if request.is_xhr:
            return '', 204

        return redirect(url_for('manage.get_node', node_id=node.id))

    form = UpdateNodeForm(request.form, obj=node)
    flash_errors(form)

    packs = node.packs \
        .options(
            db.joinedload(Pack.tags, innerjoin=True),
            db.joinedload(Pack.queries, innerjoin=True),
        ).order_by(Pack.name)

    queries = node.queries \
        .options(
            db.joinedload(Query.tags, innerjoin=True),
            db.joinedload(Query.packs)
        ).order_by(Query.name)

    return render_template('node.html', form=form, node=node,
                           packs=packs, queries=queries)