Exemple #1
0
def edit(id):
    """
  Edit sensor form to modify a sensor.
  """
    sensor = Sensor.query.get(id)
    form = SensorForm(request.form, obj=sensor)
    if request.method == 'POST':
        form.populate_obj(sensor)
        if form.validate():
            db.session.commit()
            flash('You have successfully modified the sensor.', 'success')
            return redirect(url_for('sensors.edit', id=sensor.id))
    return render_template('sensors/edit.html', form=form, sensor=sensor)