• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python search_controller.SearchController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python search_engine_base.SearchEngine类代码示例发布时间:2022-05-27
下一篇:
Python models.augment_solr_response函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap