コード例 #1
0
ファイル: views.py プロジェクト: densho/encyc-front
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,
    })
コード例 #2
0
ファイル: models.py プロジェクト: densho/encyc-front
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
コード例 #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_to_response(
        template_name,
        {'categories': categories,
         'locations': locations,
         'timeout': timeout,},
        context_instance=RequestContext(request)
    )
コード例 #4
0
ファイル: api.py プロジェクト: densho/encyc-front
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)