'GET /api/requests
Displays a collection (list) of sequencing requests.'

@web.expose_api
def index(self, trans, **kwd):

    if trans.user_is_admin():
        query = trans.sa_session.query(trans.app.model.Request).filter((trans.app.model.Request.table.c.deleted == false())).all()
    else:
        query = trans.sa_session.query(trans.app.model.Request).filter(and_(((trans.app.model.Request.table.c.user_id == trans.user.id) and (trans.app.model.Request.table.c.deleted == false())))).all()
    rval = []
    for request in query:
        item = request.to_dict()
        item['url'] = url_for('requests', id=trans.security.encode_id(request.id))
        item['id'] = trans.security.encode_id(item['id'])
        if trans.user_is_admin():
            item['user'] = request.user.email
        rval.append(item)
    return rval
