def search (request, topic_map): form_data = request.GET or None entity_types = EntityType.objects.all() form = EntitySearchForm(topic_map, data=form_data, entity_types=entity_types) results = [] user_preferences = {} if form.is_valid(): name = form.cleaned_data['name'] entity_type_id = form.cleaned_data['entity_type'] entity_type = None if entity_type_id: entity_type = EntityType.objects.get_by_identifier(entity_type_id) results_list = topic_map.lookup_entities(name, entity_type) paginator = Paginator(results_list, 10) page = request.GET.get('page') try: results = paginator.page(page) except PageNotAnInteger: results = paginator.page(1) except EmptyPage: results = paginator.page(paginator.num_pages) user_preferences = get_user_preferences(request) context_data = { 'property_assertion_full_certainty': \ topic_map.property_assertion_full_certainty, 'search_form': form, 'search_results': results} context_data['user_is_editor'] = user_is_editor(request.user) context_data.update(user_preferences) return render_to_response('eats/display/search.html', context_data, context_instance=RequestContext(request))
def search(request, topic_map): form_data = request.GET or None entity_types = EntityType.objects.all() form = EntitySearchForm(topic_map, data=form_data, entity_types=entity_types) results = [] user_preferences = {} if form.is_valid(): name = form.cleaned_data['name'] entity_type_id = form.cleaned_data['entity_type'] entity_type = None if entity_type_id: entity_type = EntityType.objects.get_by_identifier(entity_type_id) results_list = topic_map.lookup_entities(name, entity_type) paginator = Paginator(results_list, 10) page = request.GET.get('page') try: results = paginator.page(page) except PageNotAnInteger: results = paginator.page(1) except EmptyPage: results = paginator.page(paginator.num_pages) user_preferences = get_user_preferences(request) context_data = { 'property_assertion_full_certainty': \ topic_map.property_assertion_full_certainty, 'search_form': form, 'search_results': results} context_data['user_is_editor'] = user_is_editor(request.user) context_data.update(user_preferences) return render_to_response('eats/display/search.html', context_data, context_instance=RequestContext(request))
def search (request, topic_map): form_data = request.GET or None form = EntitySearchForm(data=form_data) results = [] user_preferences = {} if form.is_valid(): name = form.cleaned_data['name'] results_list = topic_map.lookup_entities(name) paginator = Paginator(results_list, 10) page = request.GET.get('page') try: results = paginator.page(page) except PageNotAnInteger: results = paginator.page(1) except EmptyPage: results = paginator.page(paginator.num_pages) user_preferences = get_user_preferences(request) context_data = {'search_form': form, 'search_results': results} context_data['user_is_editor'] = user_is_editor(request.user) context_data.update(user_preferences) return render_to_response('eats/display/search.html', context_data, context_instance=RequestContext(request))