def tracker_enable(): item_id = request.json['item_id'] try: item = Item.query.get(item_id) item.enabled = 1 db.session.commit() all_data = Item.query.all() dump = items_schema.dump(all_data) return jsonify(dump) except NoResultFound: all_data = Item.query.all() dump = items_schema.dump(all_data) return jsonify({'error': 'item not found', 'data': dump})
def tracker_add(): name = request.json['name'] tracker = create_item(name=name, enabled=1) all_data = Item.query.all() dump = items_schema.dump(all_data) if tracker: return jsonify(dump) else: return jsonify({'error': 'error with adding item', 'data': dump})
def tracker_select(): get_trackers = Item.query.all() dump = items_schema.dump(get_trackers) return jsonify(dump)
def tracker_data(): get_trackers = db.session.query(Item).filter(Item.enabled == 1).all() dump = items_schema.dump(get_trackers) return jsonify(dump)