예제 #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])