def do_geosearch(self, point): recommendations, more = get_healers_geosearch( self.request, point=point, exclude_users=self.get_exclude_users(), count=self.get_remaining_count(), random_order=True) self.recommendations.extend(provider.user for provider in recommendations)
def modality_description(request, modality_id, full_page=False): try: healer = None if modality_id: if request.user.is_superuser: modality = Modality.objects healer = get_object_or_404(Healer, user__username=request.user.username) else: modality = Modality.objects_approved modality = modality.get(pk=modality_id) else: modality = None providers = None if modality is not None: providers = get_healers_geosearch(request, modality_id=modality)[0][:settings.MAX_PROVIDERS_ON_SPECIALITY_PAGE] initial_data = {} session_data = request.session.get('search_state', None) if session_data is not None: initial_data.update(session_data) no_city = not request.session.get('point', False) initial_data['modality_id'] = modality_id form = HealerSearchForm(initial=initial_data) ctx = { "modality": modality, "user": request.user, "healer": healer, 'full_page': full_page, "base_template": 'base_common.html' if full_page else 'base_blank.html', 'providers': providers, 'form': form, 'no_city': no_city, } if request.user.is_superuser: # already = ModalityCategory.objects.filter(modality=modality) # c['categories'] = ModalityCategory.objects.exclude(pk__in=already) ctx['categories'] = ModalityCategory.objects.filter(modality=modality) ctx['category_options'] = ModalityCategory.objects.exclude(modality=modality) except Modality.DoesNotExist: raise Http404 return render_to_response("modality/modality.html", ctx, context_instance=RequestContext(request))
def modality_providers(request, modality_id, zipcode=None): if zipcode: try: zipcode_object = Zipcode.objects.get(code=zipcode) except Zipcode.DoesNotExist: return HttpResponse("Could not find Zipcode " + zipcode) request.session['point'] = zipcode_object.point zipcode = zipcode_object.code request.session['zipcode'] = zipcode else: zipcode = request.session.get('zipcode', None) if not zipcode: t = loader.get_template("modality/modality_get_zipcode.html") return HttpResponse(t.render(Context({"modality_id": modality_id}))) NUM_PROVIDERS = 20 try: modality = Modality.objects_approved.get(pk=modality_id) except Modality.DoesNotExist: return HttpResponse("Could not find Modality " + modality_id) providers, more = get_healers_geosearch(request, NUM_PROVIDERS, modality_id=modality_id) provider_count = len(providers) # if provider_count < NUM_PROVIDERS: # providers = set(list(providers) + list(Healer.objects.filter(modality=modality_id)[:NUM_PROVIDERS-provider_count])) providers = [p.user for p in providers] show_more = provider_count == NUM_PROVIDERS # just approximate for now return render_to_response("modality/modality_providers.html", { "modality": modality, "user": request.user, "providers": providers, "show_more_link": show_more, "zipcode": zipcode })