예제 #1
0
def show_gw(gw_id=None):
    if request.method == 'GET':
        info = None
        if gw_id:
            gw = Gateway.get_or_404(gw_id)
            info = _wrapper_dict(gw, ['id', 'name', 'url', 'address', 'latitude', 'longitude'])
    return render_template('edit.html', gateway=info, username=session.get('username'))
예제 #2
0
def update_gw(gw_id):
    if request.method == 'POST':
        post = {}
        for key in FORM_DATA:
            post[key] = request.form.get(key, None)
        gw = Gateway.get_or_404(gw_id)
        gw.update(**post)
        db.session.commit()
        flash('The entry was successfully updated.')
    return redirect(url_for('list_all_gws'), 302)
예제 #3
0
def update_gw(gw_id):
    if request.method == 'POST':
        post = {}
        for key in FORM_DATA:
            post[key] = request.form.get(key, None)
        gw = Gateway.get_or_404(gw_id)
        gw.update(**post)
        db.session.commit()
        flash('The entry was successfully updated.')
    return redirect(url_for('list_all_gws'), 302)
예제 #4
0
def delete_gw():
    if request.method == 'POST':
        gw_str = request.form.get('id', None)
        print gw_str
        if gw_str:
            gw_list = gw_str.split(',')
            for gw_id in gw_list:
                gw = Gateway.get_or_404(gw_id)
                gw.delete()
            flash('Gateway {} was successfully deleted.'.format(str(gw_str)))
    return redirect(url_for('list_all_gws'), 302)
예제 #5
0
def delete_gw():
    if request.method == 'POST':
        gw_str = request.form.get('id', None)
        print gw_str
        if gw_str:
            gw_list = gw_str.split(',')
            for gw_id in gw_list:
                try:
                    gw = Gateway.get_or_404(gw_id)
                    gw.delete()
                    flash('Gateway {} was successfully deleted.'.format(
                        str(gw_str)))
                except IntegrityError:
                    flash(
                        'Unable to delete gateway {} because it has remaining user bindings. Plz check.'
                        .format(str(gw_str)))
    return redirect(url_for('list_all_gws'), 302)