Example #1
0
File: api2.py Project: ronwxy/hue
def delete_indexes(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  response = {'status': -1}

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

  if not indexes:
    response['message'] = _('No indexes to remove.')
  else:
    searcher = CollectionController(request.user)

    for index in indexes:
      if index['type'] == 'collection':
        searcher.delete_collection(index['name'])
      elif index['type'] == 'alias':
        searcher.delete_alias(index['name'])
      else:
        LOG.warn('We could not delete: %s' % index)

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

  return JsonResponse(response)
Example #2
0
File: api2.py Project: ronwxy/hue
def delete_indexes(request):
    if request.method != 'POST':
        raise PopupException(_('POST request required.'))

    response = {'status': -1}

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

    if not indexes:
        response['message'] = _('No indexes to remove.')
    else:
        searcher = CollectionController(request.user)

        for index in indexes:
            if index['type'] == 'collection':
                searcher.delete_collection(index['name'])
            elif index['type'] == 'alias':
                searcher.delete_alias(index['name'])
            else:
                LOG.warn('We could not delete: %s' % index)

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

    return JsonResponse(response)