def search(request): form = request.GET if 'search' not in form: return index(request) term = form['search'] location = form['location'] #TODO fix getting location if location == "": #handle blank location with IP track!!! location = get_default() business_list = search_site(term, location) businesses = get_bus_data(business_list,request.user,True) context = get_default_blank_context(request.user) context.update( { 'search_term' : term, 'business_list' : businesses, 'nonempty' : True, 'all_businesses' : businesses, 'page_template': "ratings/listing/entry.html", } ) return render_to_response('ratings/sort.html', context_instance=RequestContext(request,context))
def index(request, template='ratings/index.html', extra_context=None): if request.user.is_authenticated(): current_businesses = [] # community_businesses = get_businesses_by_community(request.user,request.GET.get('page'),[],True) # current_businesses+=community_businesses#.object_list # top_businesses = get_businesses_by_your(request.user,request.GET.get('page'),[],True) current_businesses+=top_businesses#.object_list your_businesses = get_businesses_by_your(request.user,request.GET.get('page'),[],True) current_businesses+=your_businesses#.object_list your_businesses = Business.objects.all() context = get_default_blank_context(request.user) context.update( { #'community_businesses' : community_businesses, 'your_businesses' : your_businesses, 'all_businesses': top_businesses, 'feed' : get_all_recent_activity(), 'your_businesses' : your_businesses, 'nonempty' : True, 'page_template': "ratings/listing/entry.html", } ) return render_to_response(template, context_instance=RequestContext(request,context)) else: businesses = [] try: busMembership = BusinessMembership.objects.filter(community = get_default()) for b in busMembership: businesses.append(b.business) except: logger.debug("error in getting businesses community, maybe businesses wasnt put in community?") businesses = Business.objects.all() context = get_unauthenticated_context() return render_to_response('ratings/index.html', context_instance=RequestContext(request,context))