def productAJAX(request): if request.method == 'POST': product = request.POST["term"] neighbours = getNeighbours() cache_status, neighbour_markers = taskallocator.getNeighbourProductMarkers(product_name=product, neighbours=neighbours, task_id=product) product = product.replace("-", " ") neighbouring_list_title = "Nearby " + product + " Profiles" context = Context({'product': product, 'neighbouring_branches': neighbour_markers[1], 'neighbouring_branches_count': neighbour_markers[2], 'neighbour_markers': neighbour_markers[0], 'neighbouring_list_title': neighbouring_list_title}) if neighbour_markers[2] > 0: template = loader.get_template('sections/neighbouring_businesses.html') return HttpResponse(template.render(context)) else: return HttpResponse("") else: return HttpResponseForbidden()
def categoryAJAX(request): if request.method == 'POST': category = request.POST["data[term]"] featuredcount = 0 featuredcount = int(request.POST["data[featuredcount]"]) neighbours = getNeighbours() cache_status, neighbour_markers = taskallocator.getNeighbourMarkers(category_name=category, neighbours=neighbours, task_id=category) category = category.replace("-", " ") neighbouring_list_title = "Nearby " + category + " Profiles" context = Context({'category': category, 'neighbouring_branches': neighbour_markers[1], 'neighbouring_branches_count': neighbour_markers[2], 'neighbour_markers': neighbour_markers[0], 'neighbouring_list_title': neighbouring_list_title, 'featuredcount': featuredcount}) if neighbour_markers[2] > 0: template = loader.get_template('sections/neighbouring_businesses.html') return HttpResponse(template.render(context)) else: return HttpResponse("") else: return HttpResponseForbidden()