Esempio n. 1
0
def collections_remove(request):
    if request.method != 'POST':
        raise PopupException(_('POST request required.'))

    response = {'status': -1}

    collections = json.loads(request.POST.get('collections', '[]'))

    if not collections:
        response['message'] = _('No collections to remove.')

    if response.get('message', None) is None:
        searcher = CollectionManagerController(request.user)
        solr_collections = searcher.get_collections()

        for collection in collections:
            if collection.get('name') in solr_collections:
                # Remove collection and instancedir
                searcher.delete_collection(collection.get('name'),
                                           collection.get('isCoreOnly'))

        response['status'] = 0
        response['message'] = _('Collections removed!')

    return HttpResponse(json.dumps(response), mimetype="application/json")
Esempio n. 2
0
File: api.py Progetto: CrazyJvm/hue
def collections(request):
  searcher = CollectionManagerController(request.user)
  solr_collections = searcher.get_collections()

  response = {
    'status': 0,
    'collections': [{'name': collection} for collection in solr_collections]
  }

  return HttpResponse(json.dumps(response), mimetype="application/json")
Esempio n. 3
0
File: api.py Progetto: onimsha/hue
def collections(request):
    searcher = CollectionManagerController(request.user)
    solr_collections = searcher.get_collections()

    response = {
        'status': 0,
        'collections': [{
            'name': collection
        } for collection in solr_collections]
    }

    return HttpResponse(json.dumps(response), mimetype="application/json")
Esempio n. 4
0
def collections(request):
    searcher = CollectionManagerController(request.user)
    solr_collections = searcher.get_collections()
    massaged_collections = []
    for collection in solr_collections:
        massaged_collections.append({
            'name':
            collection,
            'isCoreOnly':
            solr_collections[collection]['isCoreOnly']
        })
    response = {'status': 0, 'collections': massaged_collections}

    return HttpResponse(json.dumps(response), mimetype="application/json")
Esempio n. 5
0
def collections(request):
    searcher = CollectionManagerController(request.user)
    solr_collections = searcher.get_collections()
    massaged_collections = []
    for collection in solr_collections:
        massaged_collections.append({
            'name':
            collection,
            'isCoreOnly':
            solr_collections[collection]['isCoreOnly']
        })
    response = {'status': 0, 'collections': massaged_collections}

    return JsonResponse(response)
Esempio n. 6
0
def collections(request):
  searcher = CollectionManagerController(request.user)
  solr_collections = searcher.get_collections()
  massaged_collections = []
  for collection in solr_collections:
    massaged_collections.append({
      'name': collection,
      'isCoreOnly': solr_collections[collection]['isCoreOnly']
    })
  response = {
    'status': 0,
    'collections': massaged_collections
  }

  return HttpResponse(json.dumps(response), mimetype="application/json")
Esempio n. 7
0
def collections(request):
  searcher = CollectionManagerController(request.user)
  solr_collections = searcher.get_collections()
  massaged_collections = []
  for collection in solr_collections:
    massaged_collections.append({
      'name': collection,
      'isCoreOnly': solr_collections[collection]['isCoreOnly']
    })
  response = {
    'status': 0,
    'collections': massaged_collections
  }

  return JsonResponse(response)
Esempio n. 8
0
File: api.py Progetto: Lt-Pone/hue
def collections_remove(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  response = {'status': -1}

  collections = json.loads(request.POST.get('collections', '[]'))

  if not collections:
    response['message'] = _('No collections to remove.')

  if response.get('message', None) is None:
    searcher = CollectionManagerController(request.user)
    solr_collections = searcher.get_collections()

    for collection in collections:
      if collection.get('name') in solr_collections:
        # Remove collection and instancedir
        searcher.delete_collection(collection.get('name'), collection.get('isCoreOnly'))

    response['status'] = 0
    response['message'] = _('Collections removed!')

  return JsonResponse(response)