def ajax_browse(request, content_type=None, template_name="", extra_context={}): x1 = request.POST.get("x1", False) x2 = request.POST.get("x2", False) y1 = request.POST.get("y1", False) y2 = request.POST.get("y2", False) offset = request.POST.get("offset", 0) count = request.POST.get("count", 14) if content_type==None: content_type = request.POST.get("content_type", None) items = GeoPointTag.objects.search_in_area(float(x1), float(y1), float(x2), float(y2)) user_id = request.POST.get("user_id", False) network = request.POST.get("network", False) if user_id: items = social_query(get_object_or_404(User, pk=user_id), network, items) if(content_type): content_type = get_target_contenttype(content_type) items = items.filter(content_type=content_type) return render_to_response(template_name, { "items": items[offset:(offset+count)], }, context_instance=RequestContext(request))
def get_clusters(request): count = request.POST.get("count", 1000) offset = request.POST.get("offset", 0) zoom_level = request.POST.get("zoom", 2) x1 = request.POST.get("x1", False) x2 = request.POST.get("x2", False) y1 = request.POST.get("y1", False) y2 = request.POST.get("y2", False) total_q = GeoAbstractModel.objects.search_in_area(float(x1), float(y1), float(x2), float(y2)) user_id = request.POST.get("user_id", False) network = request.POST.get("network", False) if user_id: total_q = social_query(get_object_or_404(User, pk=user_id), network, total_q) total_count = total_q.count() total = total_q[offset:count] clusters = cluster_all_geoitems(total, int(zoom_level)+3) for cluster in clusters: pass #cluster.set_overlay_html = data = {} data["type"] = "success" data["code"] = 1 data["clusters"] = [cluster.get_data() for cluster in clusters] return HttpResponse(simplejson.dumps(data), status=200, mimetype='application/json')