def search_entities(request): sources = json.loads(request.POST.get('sources')) or [] if 'documents' in sources: search_text = json.loads(request.POST.get('query_s', '')) entities = _search(user=request.user, search_text=search_text) response = { 'entities': [{ 'hue_name': _highlight(search_text, escape(e.name)), 'hue_description': _highlight(search_text, escape(e.description)), 'type': 'HUE', 'last_modified': e.last_modified, 'owner': escape(e.owner), 'doc_type': escape(e.type), 'originalName': escape(e.name), 'link': e.get_absolute_url() } for e in entities['documents'] ], 'count': len(entities['documents']), 'status': 0 } return JsonResponse(response) else: if has_catalog(request.user): return metadata_search_entities(request) else: return JsonResponse({'status': 1, 'message': _('Navigator not enabled')})
def search_entities_interactive(request): sources = json.loads(request.POST.get('sources')) or [] if 'documents' in sources: search_text = json.loads(request.POST.get('query_s', '')) limit = int(request.POST.get('limit', 25)) entities = _search(user=request.user, search_text=search_text, limit=limit) response = { 'results': [{ 'hue_name': _highlight(search_text, escape(e.name)), 'hue_description': _highlight(search_text, escape(e.description)), 'link': e.get_absolute_url(), 'doc_type': escape(e.type), 'type': 'HUE', 'uuid': e.uuid, 'parentUuid': e.parent_directory.uuid, 'originalName': escape(e.name) } for e in entities['documents'] ], 'count': len(entities['documents']), 'status': 0 } return JsonResponse(response) else: if has_catalog(request.user): return metadata_search_entities_interactive(request) else: return JsonResponse({'status': 1, 'message': _('Navigator not enabled')})