def delete_alarm(id): alarm = model.Alarm.query.filter(model.Alarm.id == id).first() if alarm is None: flask.abort(404) model.db.session.delete(alarm) model.db.session.commit() comm.send_message(app, comm.ReloadAlarmsMessage()) return '', 204
def add_alarm(): alarm = model.Alarm() alarm.update_from_dict(flask.request.json) alarm.schedule_next_alarm() model.db.session.add(alarm) model.db.session.commit() comm.send_message(app, comm.ReloadAlarmsMessage()) return flask.jsonify(alarm.to_dict())
def update_alarm(id): alarm = model.Alarm.query.filter(model.Alarm.id == id).first() if alarm is None: flask.abort(404) alarm.update_from_dict(flask.request.json) alarm.schedule_next_alarm() model.db.session.add(alarm) model.db.session.commit() comm.send_message(app, comm.ReloadAlarmsMessage()) return flask.jsonify(alarm.to_dict())