Ejemplo n.º 1
0
def view():

    typ = flask.request.args.get("type", 0)
    country = flask.request.args.get("country", 0)
    state = flask.request.args.get("state", 0)
    description_id = flask.request.args.get("description_id", 0)

    loc = Location(db)
    if description_id > 0:
        return flask.jsonify(data=loc.for_one_resource(description_id=description_id))
    else:
        return flask.jsonify(data=loc.for_many_resources(typ=typ, country=country))
Ejemplo n.º 2
0
def view():

    typ = flask.request.args.get("type", 0)
    country = flask.request.args.get("country", 0)
    state = flask.request.args.get("state", 0)
    description_id = flask.request.args.get("description_id", 0)

    loc = Location(db)
    try:
        desc_id = int(description_id)
    except ValueError:
        desc_id = 0

    if desc_id > 0:
        return flask.jsonify(data=loc.for_one_resource(description_id=description_id))
    elif int(typ) > 0 and int(country) > 0:
        return flask.jsonify(data=loc.for_many_resources(type_id=typ, country_id=country))
    else:
        main = Main(db)
        prefs = main.get_user_pref()
        country_name = main.get_country_name(prefs[2])
        state_name = main.get_state_name(prefs[3])
        bound_location = "%s, %s" % (state_name, country_name)
        return flask.jsonify(data={"boundLocation": bound_location})