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, })
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
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) )
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)