当前位置: 首页>>代码示例>>Python>>正文


Python search_controller.SearchController类代码示例

本文整理汇总了Python中search.search_controller.SearchController的典型用法代码示例。如果您正苦于以下问题:Python SearchController类的具体用法?Python SearchController怎么用?Python SearchController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SearchController类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: admin_collections_import

def admin_collections_import(request):
  if request.method == 'POST':
    searcher = SearchController(request.user)
    imported = []
    not_imported = []
    status = -1
    message = ""
    importables = json.loads(request.POST["selected"])
    for imp in importables:
      try:
        searcher.add_new_collection(imp)
        imported.append(imp['name'])
      except Exception, e:
        not_imported.append(imp['name'] + ": " + unicode(str(e), "utf8"))

    if len(imported) == len(importables):
      status = 0;
      message = _('Collection(s) or core(s) imported successfully!')
    elif len(not_imported) == len(importables):
      status = 2;
      message = _('There was an error importing the collection(s) or core(s)')
    else:
      status = 1;
      message = _('Collection(s) or core(s) partially imported')

    result = {
      'status': status,
      'message': message,
      'imported': imported,
      'notImported': not_imported
    }

    return HttpResponse(json.dumps(result), mimetype="application/json")
开发者ID:Web5design,项目名称:hue,代码行数:33,代码来源:views.py

示例2: admin_collection_copy

def admin_collection_copy(request):
    if request.method != "POST":
        raise PopupException(_("POST request required."))

    collections = json.loads(request.POST.get("collections"))
    searcher = SearchController(request.user)
    response = {"result": searcher.copy_collections([collection["id"] for collection in collections])}

    return JsonResponse(response)
开发者ID:cloudera,项目名称:hue,代码行数:9,代码来源:views.py

示例3: admin_collection_delete

def admin_collection_delete(request):
    if request.method != "POST":
        raise PopupException(_("POST request required."))

    collections = json.loads(request.POST.get("collections"))
    searcher = SearchController(request.user)
    response = {"result": searcher.delete_collections([collection["id"] for collection in collections])}

    return HttpResponse(json.dumps(response), mimetype="application/json")
开发者ID:tp0101,项目名称:hue,代码行数:9,代码来源:views.py

示例4: admin_collection_copy

def admin_collection_copy(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  id = request.POST.get('id')
  searcher = SearchController(request.user)
  response = {
    'id': searcher.copy_collection(id)
  }

  return HttpResponse(json.dumps(response), mimetype="application/json")
开发者ID:Altiscale,项目名称:hue,代码行数:11,代码来源:views.py

示例5: admin_collection_copy

def admin_collection_copy(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  collections = json.loads(request.POST.get('collections'))
  searcher = SearchController(request.user)
  response = {
    'result': searcher.copy_collections([collection['id'] for collection in collections])
  }

  return JsonResponse(response)
开发者ID:QLGu,项目名称:hue,代码行数:11,代码来源:views.py

示例6: admin_collection_delete

def admin_collection_delete(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  collections = json.loads(request.POST.get('collections'))
  searcher = SearchController(request.user)
  response = {
    'result': searcher.delete_collections([collection['id'] for collection in collections])
  }

  return HttpResponse(json.dumps(response), mimetype="application/json")
开发者ID:bitsom,项目名称:hue,代码行数:11,代码来源:views.py

示例7: index

def index(request):
  hue_collections = SearchController(request.user).get_search_collections()
  collection_id = request.GET.get('collection')

  if not hue_collections or not collection_id:
    return admin_collections(request, True)

  try:
    collection = hue_collections.get(id=collection_id)
  except Exception, e:
    raise PopupException(e, title=_("Dashboard does not exist or you don't have the permission to access it."))
开发者ID:openedbox,项目名称:hue,代码行数:11,代码来源:views.py

示例8: admin_collections_import

def admin_collections_import(request):
  if request.method == 'POST':
    searcher = SearchController(request.user)
    status = 0
    err_message = _('Error')
    result = {
      'status': status,
      'message': err_message
    }
    importables = json.loads(request.POST["selected"])
    for imp in importables:
      try:
        searcher.add_new_collection(imp)
        status += 1
      except Exception, e:
        err_message += unicode(str(e), "utf8") + "\n"
      result['message'] = status == len(importables) and _('Imported successfully') or _('Imported with errors: ') + err_message
    return HttpResponse(json.dumps(result), mimetype="application/json")
开发者ID:branchp,项目名称:hue,代码行数:18,代码来源:views.py

示例9: admin_collection_properties

def admin_collection_properties(request, collection_id):
  hue_collection = Collection.objects.get(id=collection_id)
  solr_collection = SolrApi(SOLR_URL.get(), request.user).collection_or_core(hue_collection)

  if request.method == 'POST':
    collection_form = CollectionForm(request.POST, instance=hue_collection, user=request.user)
    if collection_form.is_valid():
      searcher = SearchController(request.user)
      hue_collection = collection_form.save(commit=False)
      hue_collection.is_core_only = not searcher.is_collection(hue_collection.name)
      hue_collection.save()
      return redirect(reverse('search:admin_collection_properties', kwargs={'collection_id': hue_collection.id}))
    else:
      request.error(_('Errors on the form: %s.') % collection_form.errors)
  else:
    collection_form = CollectionForm(instance=hue_collection)

  return render('admin_collection_properties.mako', request, {
    'solr_collection': solr_collection,
    'hue_collection': hue_collection,
    'collection_form': collection_form,
  })
开发者ID:atupal,项目名称:hue,代码行数:22,代码来源:views.py

示例10: _

      message = _('There was an error importing the collection(s) or core(s)')
    else:
      status = 1;
      message = _('Collection(s) or core(s) partially imported')

    result = {
      'status': status,
      'message': message,
      'imported': imported,
      'notImported': not_imported
    }

    return HttpResponse(json.dumps(result), mimetype="application/json")
  else:
    if request.GET.get('format') == 'json':
      searcher = SearchController(request.user)
      new_solr_collections = searcher.get_new_collections()
      massaged_collections = []
      for coll in new_solr_collections:
        massaged_collections.append({
          'type': 'collection',
          'name': coll
        })
      new_solr_cores = searcher.get_new_cores()
      massaged_cores = []
      for core in new_solr_cores:
        massaged_cores.append({
          'type': 'core',
          'name': core
        })
      response = {
开发者ID:Web5design,项目名称:hue,代码行数:31,代码来源:views.py


注:本文中的search.search_controller.SearchController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。