def eventJSON(farm_id, event_id): """Create JSON version of a particular event from a particular farm.""" event = db_session.query(Event).filter_by(farm_id=farm_id, id=event_id).one() return jsonify(event=event.serialize)
def eventsJSON(farm_id): """Create JSON version of events from a particular farm.""" events = db_session.query(Event).filter_by(farm_id=farm_id).all() return jsonify(events=[e.serialize for e in events])
def itemJSON(farm_id, menu_id): """Create JSON version of each item in a catalog.""" item = db_session.query(CatalogItem).filter_by(farm_id=farm_id, id=menu_id).one() return jsonify(item=item.serialize)
def catalogJSON(farm_id): """Create JSON version of a farm catalog.""" items = db_session.query(CatalogItem).filter_by(farm_id=farm_id).all() return jsonify(catalog=[i.serialize for i in items])
def farmJSON(farm_id): """Create JSON version of a particular farm.""" farm = db_session.query(Farm).filter_by(id=farm_id).one() return jsonify(farm=farm.serialize)
def farmsJSON(): """Create JSON version of each farm.""" farms = db_session.query(Farm).all() return jsonify(farms=[f.serialize for f in farms])