def get_locations_as_lookup():
    locations = qlocations.get_locations_country("LR")

    def filter_ADM1(location):
        return location.feature_code == u'ADM1'

    return dict(
        map(lambda l: (l.name.replace(" County", "").lower(), l.id),
            filter(filter_ADM1, locations)))
Пример #2
0
def api_locations(country_code):
    """Returns locations and tries to sort them. Note that there may be cases where
    this will break as the geonames data does not always contain
    good information about the hierarchical relationships between locations."""
    locations = list(
        map(lambda x: x.as_dict(),
            qlocation.get_locations_country(country_code)))
    for i, location in enumerate(locations):
        if location["feature_code"] == "ADM2":
            locations[i]["name"] = " - %s" % location["name"]
    return jsonify(locations=locations)
Пример #3
0
def api_locations(country_code):
    """Returns locations and tries to sort them. Note that there may be cases where
    this will break as the geonames data does not always contain
    good information about the hierarchical relationships between locations."""
    
    locations = list(map(lambda x: x.as_dict(), 
                     qlocation.get_locations_country(country_code)))
    
    for i, location in enumerate(locations):
        if location["feature_code"] == "ADM2":
            locations[i]["name"] = " - %s" % location["name"]
    
    return jsonify(locations = locations)
Пример #4
0
def activity_edit(activity_id):
    activity = qactivity.get_activity(activity_id)
    locations = qlocation.get_locations_country(
                                    activity.recipient_country_code)
    return render_template("activity_edit.html",
                activity = activity,
                loggedinuser=current_user,
                codelists = codelists.get_codelists(),
                locations = locations,
                api_locations_url ="/api/locations/%s/" % activity.recipient_country_code,
                api_activity_locations_url = "/api/activity_locations/%s/" % activity_id,
                api_activity_finances_url = "/api/activity_finances/%s/" % activity_id,
                api_update_activity_finances_url = "/api/activity_finances/%s/update_finances/" % activity_id,
                users = quser.user()
          )
Пример #5
0
def activity_edit(activity_id):
    activity = qactivity.get_activity(activity_id)
    locations = qlocation.get_locations_country(
                                    activity.recipient_country_code)
    return render_template(
        "activity_edit.html",
        activity=activity,
        loggedinuser=current_user,
        codelists=codelists.get_codelists(),
        organisations=qorganisations.get_organisations(),
        locations=locations,
        api_locations_url=url_for("api.api_locations", country_code=activity.recipient_country_code),
        api_activity_locations_url=url_for("api.api_activity_locations", activity_id=activity_id),
        api_activity_finances_url=url_for("api.api_activity_finances", activity_id=activity_id),
        api_activity_milestones_url=url_for("api.api_activity_milestones", activity_id=activity_id),
        api_update_activity_finances_url=url_for("api.finances_edit_attr", activity_id=activity_id),
        api_iati_search_url=url_for("api.api_iati_search"),
        api_activity_forwardspends_url=url_for("api.api_activity_forwardspends", activity_id=activity_id),
        api_activity_counterpart_funding_url = url_for("api.api_activity_counterpart_funding", activity_id=activity_id),
        users=quser.user()
    )
Пример #6
0
def activity(activity_id):
    activity = qactivity.get_activity(activity_id)
    if not activity:
        return(abort(404))
    locations = qlocation.get_locations_country(
                                    activity.recipient_country_code)
    return render_template(
        "activity.html",
        activity=activity,
        loggedinuser=current_user,
        codelists=codelists.get_codelists(),
        codelist_lookups=codelists.get_codelists_lookups(),
        locations=locations,
        api_locations_url=url_for("api.api_locations", country_code=activity.recipient_country_code),
        api_activity_locations_url=url_for("api.api_activity_locations", activity_id=activity_id),
        api_activity_finances_url=url_for("api.api_activity_finances", activity_id=activity_id),
        api_update_activity_finances_url=url_for("api.finances_edit_attr", activity_id=activity_id),
        api_iati_search_url=url_for("api.api_iati_search"),
        api_activity_forwardspends_url=url_for("api.api_activity_forwardspends", activity_id=activity_id),
        users=quser.user()
    )