Beispiel #1
0
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': e.name,
                'hue_description': e.description,
                'type': 'HUE',
                'originalName': e.name,
                'link': '/home?uuid=%s' % e.uuid
            } for e in entities['documents']],
            'count':
            len(entities['documents']),
            'status':
            0
        }

        return JsonResponse(response)
    else:
        if has_navigator(request.user):
            return metadata_search_entities(request)
        else:
            return JsonResponse({
                'status': 1,
                'message': _('Navigator not enabled')
            })
Beispiel #2
0
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": e.name,
                    "hue_description": e.description,
                    "type": "HUE",
                    "originalName": e.name,
                    "link": "/home?uuid=%s" % e.uuid,
                }
                for e in entities["documents"]
            ],
            "count": len(entities["documents"]),
            "status": 0,
        }

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