Exemplo n.º 1
0
def bulk_change_state():
    new_state_str = request.form['new_state']
    new_state = PatchState.from_string(new_state_str)
    patches_ids_str = request.form['patches']
    ids = [int(id) for id in patches_ids_str.split(",")]
    for id in ids:
        for p in Patch.query.filter_by(id=id):
            p.state = new_state
    db.session.commit()
    return redirect(request.referrer)
Exemplo n.º 2
0
    def wrapped(*args, **kwargs):
        d = f(*args, **kwargs)

        q = d['query']

        state = request.args.get('state', None, type=str)
        if state:
            q = q.filter_by(state=PatchState.from_string(state))

        # add more filters later
        d['query'] = q
        return d
Exemplo n.º 3
0
def change_state():
    new_state = request.form['new_state']
    g.patch.state = PatchState.from_string(new_state)
    db.session.commit()
    return redirect(url_for('patch.index', patch_id=g.patch.id))