Esempio n. 1
0
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': e.name,
                'hue_description': e.description,
                'type': 'HUE',
                'originalName': e.name
            } for e in entities['documents']],
            'count':
            len(entities['documents']),
            'status':
            0
        }

        return JsonResponse(response)
    else:
        return metadata_search_entities_interactive(request)
Esempio n. 2
0
File: api2.py Progetto: dulems/hue-1
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': e.name,
                'hue_description': e.description,
                'link': e.get_absolute_url(),
                'doc_type': e.type,
                'type': 'HUE',
                'originalName': e.name
            } for e in entities['documents']],
            'count':
            len(entities['documents']),
            'status':
            0
        }

        return JsonResponse(response)
    else:
        if has_navigator(request.user):
            return metadata_search_entities_interactive(request)
        else:
            return JsonResponse({
                'status': 1,
                'message': _('Navigator not enabled')
            })
Esempio n. 3
0
File: api2.py Progetto: cloudera/hue
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": e.name, "hue_description": e.description, "type": "HUE", "originalName": e.name}
                for e in entities["documents"]
            ],
            "count": len(entities["documents"]),
            "status": 0,
        }

        return JsonResponse(response)
    else:
        return metadata_search_entities_interactive(request)