示例#1
0
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)
示例#2
0
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])
示例#3
0
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)
示例#4
0
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])
示例#5
0
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)
示例#6
0
def farmsJSON():
    """Create JSON version of each farm."""
    farms = db_session.query(Farm).all()
    return jsonify(farms=[f.serialize for f in farms])