Beispiel #1
0
def locations_kml(request, category=None):
    try:
        locations = loc.locations()
    except requests.exceptions.Timeout:
        return HttpResponse(status=408)
    locations = loc.filter_by_category(locations, category)
    kml = loc.kml(locations)
    return HttpResponse(kml, content_type="text/xml")
Beispiel #2
0
def category(request, category, format=None):
    """DOCUMENTATION GOES HERE.
    """
    try:
        locations = loc.locations()
    except requests.exceptions.Timeout:
        return Response(status=status.HTTP_408_REQUEST_TIMEOUT)
    data = loc.filter_by_category(locations, category)
    for category in data:
        if category['location_uri']:
            url = makeurl(request, reverse('wikiprox-api-page', args=([category['location_uri']])))
            category['location_url'] = url
    return Response(data)
Beispiel #3
0
def locations(request, category=None, template_name='locations/locations.html'):
    try:
        locations = loc.locations()
        timeout = False
    except requests.exceptions.Timeout:
        locations = []
        timeout = True
    locations = loc.filter_by_category(locations, category)
    categories = loc.categories(locations)
    return render(request, template_name, {
        'categories': categories,
        'locations': locations,
        'timeout': timeout,
    })
Beispiel #4
0
def index_locations():
    """
    @param title: str
    """
    try:
        locations = loc.locations()
        categories = loc.categories(locations)
        timeout = False
    except requests.exceptions.Timeout:
        locations = []
        categories = []
        timeout = True

    for category in categories:
        pass
Beispiel #5
0
def locations(request, category=None, template_name='locations/locations.html'):
    try:
        locations = loc.locations()
        timeout = False
    except requests.exceptions.Timeout:
        locations = []
        timeout = True
    locations = loc.filter_by_category(locations, category)
    categories = loc.categories(locations)
    return render_to_response(
        template_name,
        {'categories': categories,
         'locations': locations,
         'timeout': timeout,},
        context_instance=RequestContext(request)
    )
Beispiel #6
0
def locations(request, format=None):
    """DOCUMENTATION GOES HERE.
    """
    try:
        locations = loc.locations()
    except requests.exceptions.Timeout:
        return Response(status=status.HTTP_408_REQUEST_TIMEOUT)
    data = [
        {
            'id': c[0],
            'title': c[1],
            'url': makeurl(request, reverse('locations-api-category', args=([c[0]]))),
        }
        for c in loc.categories(locations)
    ]
    return Response(data)