Ejemplo n.º 1
0
Archivo: api2.py Proyecto: 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)
Ejemplo n.º 2
0
Archivo: api2.py Proyecto: 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)