Commit db2dd7d3 authored by Nelso Jost's avatar Nelso Jost

FIX: board cleaning

parent ea30cbd3
......@@ -361,12 +361,13 @@ def view_clean_board(id):
if board is None:
abort(400)
nickname = board.nickname
Board.clean_rawsensordata(id)
for sensor in board.sensors.all():
sensor.rawdata.delete()
db.session.commit()
update_need_refresh()
# flash("A estação <id={} nickname='{}'> foi completamente removida!"
# .format(id, nickname))
update_need_refresh()
return redirect(url_for('.view_board', id=id))
......@@ -474,8 +475,8 @@ def view_export_csv(board_id):
# form=form)
@main.route('/api/board/post/rawsensordata/<int:board_id>', methods=['POST'])
def api_board_post_rawsensordata(board_id):
@main.route('/api/post/rawsensordata/<int:board_id>', methods=['POST'])
def api_post_rawsensordata(board_id):
''' Add a bunch of sensor data from specified board.
Expects JSON data on the format:
......@@ -502,10 +503,9 @@ def api_board_post_rawsensordata(board_id):
abort(400)
for nickname, value in d['sensors'].items():
sensor = Board.get_sensor(board.id, nickname)
db.session.add(RawSensorData(sensor_id=sensor.id,
datetime=d['datetime'],
value=value))
sensor = board.get_sensor(nickname).add_rawdata(
datetime=d['datetime'], value=value)
db.session.commit()
main.need_refresh = True
return jsonify(d)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment