Beispiel #1
0
def getstate(statename):

    state_length = range(4, 15)

    if len(statename) == 2:
        state = db.states.find({'info.abbr': statename.upper()}, { '_id': False })
        return helpers.wrap_response(state)
    elif len(statename) not in state_length:
        message = 'That is not a recognizable value for a state.'
        return helpers.bad_request_response(message)
    else:
        state = db.states.find({'name': statename.title()}, { '_id': False })
        return helpers.wrap_response(state)
Beispiel #2
0
def getstates():
    filter = request.args.get('require', '')
    if (filter):
        if filter not in ('strict', 'id', 'photo'):
            message = ('%s is not a valid require value.  Use either strict, '
                'photo or id.' % filter)
            return helpers.bad_request_response(message)
        else:
            states = db.states.find({'vote.' + filter: True}, { '_id': False })
            return helpers.wrap_response(states)

    else:
        states = db.states.find({}, { '_id' : False })
        return helpers.wrap_response(states)