コード例 #1
0
def new_search(request, is_embeddable=False):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=collections[0])
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  template = 'search.mako'
  if is_embeddable:
    template = 'search_embeddable.mako'

  return render(template, request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
         'collections': collections,
         'layout': [
              {"size":2,"rows":[{"widgets":[]}],"drops":["temp"],"klass":"card card-home card-column span2"},
              {"size":10,"rows":[{"widgets":[
                  {"size":12,"name":"Filter Bar","widgetType":"filter-widget", "id":"99923aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]},
                                 {"widgets":[
                  {"size":12,"name":"Grid Results","widgetType":"resultset-widget", "id":"14023aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
                 "drops":["temp"],"klass":"card card-home card-column span10"},
         ],
         'is_latest': LATEST.get(),
     }),
    'is_owner': True,
    'can_edit_index': can_edit_index(request.user)
  })
コード例 #2
0
ファイル: views.py プロジェクト: qccash/hue
def new_search(request):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=collections[0])
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
         'collections': collections,
         'layout': [
              {"size":2,"rows":[{"widgets":[]}],"drops":["temp"],"klass":"card card-home card-column span2"},
              {"size":10,"rows":[{"widgets":[
                  {"size":12,"name":"Filter Bar","widgetType":"filter-widget", "id":"99923aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]},
                                 {"widgets":[
                  {"size":12,"name":"Grid Results","widgetType":"resultset-widget", "id":"14023aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
                 "drops":["temp"],"klass":"card card-home card-column span10"},
         ],
         'is_latest': LATEST.get(),
     }),
    'is_owner': True,
    'can_edit_index': can_edit_index(request.user)
  })
コード例 #3
0
def browse(request, name, is_mobile=False):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=name)
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  template = 'search.mako'
  if is_mobile:
    template = 'search_m.mako'

  return render(template, request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
      'autoLoad': True,
      'collections': collections,
      'layout': [
          {"size":12,"rows":[{"widgets":[
              {"size":12,"name":"Grid Results","id":"52f07188-f30f-1296-2450-f77e02e1a5c0","widgetType":"resultset-widget",
               "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
          "drops":["temp"],"klass":"card card-home card-column span10"}
      ],
      'is_latest': LATEST.get()
    }),
    'is_owner': True,
    'can_edit_index': can_edit_index(request.user),
    'mobile': is_mobile
  })
コード例 #4
0
ファイル: views.py プロジェクト: qccash/hue
def update_document(request):
  result = {'status': -1, 'message': 'Error'}

  if not can_edit_index(request.user):
    result['message'] = _('Permission to edit the document denied')
    return JsonResponse(result)

  try:
    collection = json.loads(request.POST.get('collection', '{}'))
    document = json.loads(request.POST.get('document', '{}'))
    doc_id = request.POST.get('id')

    if document['hasChanged']:
      edits = {
          "id": doc_id,
      }
      version = None # If there is a version, use it to avoid potential concurrent update conflicts

      for field in document['details']:
        if field['hasChanged']:
          edits[field['key']] = {"set": field['value']}
        if field['key'] == '_version_':
          version = field['value']

      if SolrApi(SOLR_URL.get(), request.user).update(collection['name'], json.dumps([edits]), content_type='json', version=version):
        result['status'] = 0
        result['message'] = _('Document successfully updated.')
    else:
      result['status'] = 0
      result['message'] = _('Document has no modifications to change.')

  except Exception, e:
    result['message'] = force_unicode(e)
コード例 #5
0
ファイル: views.py プロジェクト: qccash/hue
def browse(request, name):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=name)
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
         'autoLoad': True,
         'collections': collections,
         'layout': [
              {"size":12,"rows":[{"widgets":[
                  {"size":12,"name":"Grid Results","id":"52f07188-f30f-1296-2450-f77e02e1a5c0","widgetType":"resultset-widget",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
              "drops":["temp"],"klass":"card card-home card-column span10"}
         ],
         'is_latest': LATEST.get()
     }),
     'is_owner': True,
     'can_edit_index': can_edit_index(request.user)
  })
コード例 #6
0
def update_document(request):
  result = {'status': -1, 'message': 'Error'}

  if not can_edit_index(request.user):
    result['message'] = _('Permission to edit the document denied')
    return JsonResponse(result)

  try:
    collection = json.loads(request.POST.get('collection', '{}'))
    document = json.loads(request.POST.get('document', '{}'))
    doc_id = request.POST.get('id')

    if document['hasChanged']:
      edits = {
          "id": doc_id,
      }
      version = None # If there is a version, use it to avoid potential concurrent update conflicts

      for field in document['details']:
        if field['hasChanged']:
          edits[field['key']] = {"set": field['value']}
        if field['key'] == '_version_':
          version = field['value']

      if SolrApi(SOLR_URL.get(), request.user).update(collection['name'], json.dumps([edits]), content_type='json', version=version):
        result['status'] = 0
        result['message'] = _('Document successfully updated.')
    else:
      result['status'] = 0
      result['message'] = _('Document has no modifications to change.')

  except Exception, e:
    result['message'] = force_unicode(e)
コード例 #7
0
ファイル: views.py プロジェクト: cloudera/hue
def browse(request, name, is_mobile=False):
    collections = SearchController(request.user).get_all_indexes()
    if not collections:
        return no_collections(request)

    collection = Collection2(user=request.user, name=name)
    query = {"qs": [{"q": ""}], "fqs": [], "start": 0}

    template = "search.mako"
    if is_mobile:
        template = "search_m.mako"

    return render(
        template,
        request,
        {
            "collection": collection,
            "query": query,
            "initial": json.dumps(
                {
                    "autoLoad": True,
                    "collections": collections,
                    "layout": [
                        {
                            "size": 12,
                            "rows": [
                                {
                                    "widgets": [
                                        {
                                            "size": 12,
                                            "name": "Grid Results",
                                            "id": "52f07188-f30f-1296-2450-f77e02e1a5c0",
                                            "widgetType": "resultset-widget",
                                            "properties": {},
                                            "offset": 0,
                                            "isLoading": True,
                                            "klass": "card card-widget span12",
                                        }
                                    ]
                                }
                            ],
                            "drops": ["temp"],
                            "klass": "card card-home card-column span10",
                        }
                    ],
                    "is_latest": LATEST.get(),
                }
            ),
            "is_owner": True,
            "can_edit_index": can_edit_index(request.user),
            "mobile": is_mobile,
        },
    )
コード例 #8
0
ファイル: views.py プロジェクト: cloudera/hue
def update_document(request):
    result = {"status": -1, "message": "Error"}

    if not can_edit_index(request.user):
        result["message"] = _("Permission to edit the document denied")
        return JsonResponse(result)

    try:
        collection = json.loads(request.POST.get("collection", "{}"))
        document = json.loads(request.POST.get("document", "{}"))
        doc_id = request.POST.get("id")

        if document["hasChanged"]:
            edits = {"id": doc_id}
            version = None  # If there is a version, use it to avoid potential concurrent update conflicts

            for field in document["details"]:
                if field["hasChanged"] and field["key"] != "_version_":
                    edits[field["key"]] = {"set": field["value"]}
                if field["key"] == "_version_":
                    version = field["value"]

            result["update"] = SolrApi(SOLR_URL.get(), request.user).update(
                collection["name"], json.dumps([edits]), content_type="json", version=version
            )
            result["message"] = _("Document successfully updated.")
            result["status"] = 0
        else:
            result["status"] = 0
            result["message"] = _("Document has no modifications to change.")
    except RestException, e:
        try:
            result["message"] = json.loads(e.message)["error"]["msg"]
        except:
            LOG.exception("Failed to parse json response")
            result["message"] = force_unicode(e)
コード例 #9
0
ファイル: views.py プロジェクト: cloudera/hue
def new_search(request, is_embeddable=False):
    collections = SearchController(request.user).get_all_indexes()
    if not collections:
        return no_collections(request)

    collection = Collection2(user=request.user, name=collections[0])
    query = {"qs": [{"q": ""}], "fqs": [], "start": 0}

    template = "search.mako"
    if is_embeddable:
        template = "search_embeddable.mako"

    return render(
        template,
        request,
        {
            "collection": collection,
            "query": query,
            "initial": json.dumps(
                {
                    "collections": collections,
                    "layout": [
                        {
                            "size": 2,
                            "rows": [{"widgets": []}],
                            "drops": ["temp"],
                            "klass": "card card-home card-column span2",
                        },
                        {
                            "size": 10,
                            "rows": [
                                {
                                    "widgets": [
                                        {
                                            "size": 12,
                                            "name": "Filter Bar",
                                            "widgetType": "filter-widget",
                                            "id": "99923aef-b233-9420-96c6-15d48293532b",
                                            "properties": {},
                                            "offset": 0,
                                            "isLoading": True,
                                            "klass": "card card-widget span12",
                                        }
                                    ]
                                },
                                {
                                    "widgets": [
                                        {
                                            "size": 12,
                                            "name": "Grid Results",
                                            "widgetType": "resultset-widget",
                                            "id": "14023aef-b233-9420-96c6-15d48293532b",
                                            "properties": {},
                                            "offset": 0,
                                            "isLoading": True,
                                            "klass": "card card-widget span12",
                                        }
                                    ]
                                },
                            ],
                            "drops": ["temp"],
                            "klass": "card card-home card-column span10",
                        },
                    ],
                    "is_latest": LATEST.get(),
                }
            ),
            "is_owner": True,
            "can_edit_index": can_edit_index(request.user),
        },
    )
コード例 #10
0
ファイル: views.py プロジェクト: cloudera/hue
    template = "search.mako"
    if is_mobile:
        template = "search_m.mako"
    if is_embeddable:
        template = "search_embeddable.mako"

    return render(
        template,
        request,
        {
            "collection": collection,
            "query": json.dumps(query),
            "initial": json.dumps({"collections": [], "layout": [], "is_latest": LATEST.get()}),
            "is_owner": collection_doc.doc.get().can_write(request.user),
            "can_edit_index": can_edit_index(request.user),
            "mobile": is_mobile,
        },
    )


def index_m(request):
    return index(request, True)


def index_embeddable(request):
    return index(request, False, True)


def new_search(request, is_embeddable=False):
    collections = SearchController(request.user).get_all_indexes()
コード例 #11
0
      query['qs'][0]['q'] = request.GET.get('q')
    if 'qd' in request.GET:
      query['qd'] = request.GET.get('qd')

  template = 'search.mako'
  if is_mobile:
    template = 'search_m.mako'
  if is_embeddable:
    template = 'search_embeddable.mako'

  return render(template, request, {
    'collection': collection,
    'query': json.dumps(query),
    'initial': json.dumps({'collections': [], 'layout': [], 'is_latest': LATEST.get()}),
    'is_owner': collection_doc.doc.get().can_write(request.user),
    'can_edit_index': can_edit_index(request.user),
    'mobile': is_mobile
  })

def index_m(request):
  return index(request, True)

def index_embeddable(request):
  return index(request, False, True)

def new_search(request, is_embeddable=False):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=collections[0])
コード例 #12
0
ファイル: views.py プロジェクト: qccash/hue
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  if request.method == 'GET':
    if 'q' in request.GET:
      query['qs'][0]['q'] = request.GET.get('q')
    if 'qd' in request.GET:
      query['qd'] = request.GET.get('qd')


  return render('search.mako', request, {
    'collection': collection,
    'query': json.dumps(query),
    'initial': json.dumps({'collections': [], 'layout': [], 'is_latest': LATEST.get()}),
    'is_owner': collection_doc.doc.get().can_write(request.user),
    'can_edit_index': can_edit_index(request.user)
  })


def new_search(request):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=collections[0])
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({